Showing posts with label swig. Show all posts
Showing posts with label swig. Show all posts

Saturday, November 26, 2011

Fun with SWIG

Spent a long while trying to figure out user input from a mouse click. Looked into C++, openCV, and python options, none were working out very well so I've decided to leave that for now. I'll get the system working with text or argument input first.

I've been working and testing the code by just compiling the C++ code, time to make sure I can still swig it into python code. Still worked great just running from the mintty window, but then I tried creating a python file that would call the wrapped code. This proved more difficult that anticipated. In the wrapper commands I was somehow not creating the necessary file for the wrapped code to be treated as an importable module. Lots of googling and reading later I discovered distutils, a python setup file that takes care of all of the necessary flags, files, etc. It builds the file necessary to make an importable module and cuts down on my compilation code as well :
swig -c++ -python example.i
python setup.py build_ext --inplace

sorry no pictures this post :(

[EDIT: 27 Nov 2011]
Well I got a system in maya working that generates a wonderful SSS shader based on user selected images.
Went to build in the flushing generation and even though I got the import working yesterday apparently it only works in a Unix environment. Trying to run through a windows environment I'm back with the same "No module named _example" error...

References:
http://www.swig.org/Doc1.3/Python.html#Python_nn9 (31.2.2 - 31.2.6)


Python GUI References:
http://download.autodesk.com/us/maya/2010help/CommandsPython/textField.html
http://www.rtrowbridge.com/blog/2010/02/maya-python-ui-example/
http://download.autodesk.com/us/maya/2011help/CommandsPython/fileBrowserDialog.html
Good Code to Have: http://mail.python.org/pipermail/python-list/2010-August/1252307.html

Mouse Click Input References:
http://dasl.mem.drexel.edu/~noahKuntz/openCVTut3.html
http://www710.univ-lyon1.fr/~bouakaz/OpenCV-0.9.5/docs/ref/OpenCVRef_Highgui.htm#decl_cvSetMouseCallback
http://www.ida.liu.se/~ETE257/timetable/LecturePythonPygame2.html
GetCursorPos()
http://www.daniweb.com/software-development/cpp/threads/123456
http://www.cplusplus.com/forum/windows/21620/

Tuesday, November 1, 2011

Image Editing (pt 2)

With help from Joe Kider, we got swig and openCV up working together nicely.
I'm working on writing the code in C++ using openCV, then using swig to wrap it in python.
Look I can make a red circle!
Now to add falloff..

[EDIT: 9 Nov 2011]
OMG
blended with the texture map to give:
although it's blending the black as well, which is making the texture much darker..

[EDIT: 10 Nov 2011]
OOH YEAHH


and bloopers!

Friday, September 30, 2011

Swig

Thanks to Matt Kuruc for directing me towards this
http://www.swig.org/ - "super easy way to generate python bindings for c++ code."

I already have quite a bit of code ready written in python.
I had been planning on converting it over to C++ with the aim of creating a maya plugin.
With this I might be able to keep a large portion of that existing code, which would be lovely.

Additional References: 
http://www.swig.org/Doc1.3/Python.html