PyQt4 UI Development for Maya
Just released my 3rd python-based online training video through cmiVFX.com
Introduction
Getting Started With PyQt4
PyQt4 Fundamentals
General Examples
PyQt4 And Maya Introduction
Replicating Maya’s UI Components

Just released my 3rd python-based online training video through cmiVFX.com

In a recent python project where I was sending multiple messages per second of data over a basic socket, I had initially just grabbed the cPickle module to get the prototype proof-of-concept functioning properly. cPickle is awesome for easily serializing more complex python objects like custom classes, even though in my case I am only sending basic types.
My messages were dicts with some nested dicts, lists, floats, and string values. Roughly 500-1000 bytes. cPickle was doing just fine, but there came a point where I wanted to investigate the areas that could be tightened up. The first thing I realized was that I had forgotten to encode cPickle in the binary format (the default is ascii). That saved me quite a bit of time. But then I casually searched online to see if any json options might be better since my data is pretty primitive anyways.
I found UltraJSON, which is a pure C json parsing library for python, and ran some tests. There are benchmarks on the project page for ujson, as well as other articles on the internet, but I just wanted to post up my own results using a mixed type data container. ujson came out extremely fast (faster than cPickle in binary)
This test included the following:

A recent project of mine involves research and development with an XBOX 360 Kinect Sensor. Being a python guy, I started searching for python bindings to some OSX-supported framework. When you just get started looking into this area it can be a little confusing. There are a number of layers to the software stack to enable one to accomplish anything meaningful. This is just a short and general blog post outlining the basics of what I have discovered thus far, to help anyone else that might also be getting started.
At the lowest level, you need a driver. Something that can talk to the USB device that is the Kinect sensor. When you purchase the XBOX Kinect for Windows version of the sensor, and you are going to be developing on windows, much of this whole stack is provided to you by way of the Kinect SDK. But for the open source folks with the standard XBOX 360 sensor, you need to piece together your own solution.
Two drivers that I have discovered thus far:
I had started OpenKinect (libfreenect) because it comes with a python wrapper included. There were a few dependencies (I will talk about specific build steps in just a moment), but once I got this installed I was able to fire up the included glview app and see both depth and rgb data streaming in from my sensor. The role of these drivers is to provide simply the basic streams. That is, the depth, rgb, audio, and a few other sensor data streams. If your goal is to start tracking players, seeing skeletons, and registering gestures, the drivers are not enough. You would be required to make your own solution from this raw data at this phase in the game.
You would now want to look into middleware that can take the raw data and provide to you an API with higher level information. This would include finding users in the scene for you, tracking their body features, and giving you various events to watch for as the data streams.
Being that my goal was to have python bindings, I found my options to be much more limited than if I were going to be developing in C++. Wrappers have to exist for the framework you want. This is where my research really started ramping up. I spent a few days dealing wtih compiling issues, as well as having an actual bad power adapter that had to be exchanged. But all said and done, here is what I have settled on thus far…
http://mxcl.github.com/homebrew/
|
1 2 3 4 5 |
brew install cmake brew install boost |
|
1 2 3 4 |
brew install python --framework |
This is not a requirement. But I recommend using virtualenv to set up an environment that specifically uses python2.7 so that you don’t have to fight with mixed dependencies and versions.
Create a virtualenv called “kinect”
|
1 2 3 4 5 6 7 |
pip install virtualenv virtualenv --no-site-packages -p python2.7 kinect cd kinect source bin/activate |
There is a special patched version of the libusb library, in the form of a homebrew formula.
|
1 2 3 4 |
git clone https://github.com/OpenKinect/libfreenect.git |
Now copy platform/osx/homebrew/libusb-freenect.rb -> /usr/local/Library/Formula/
|
1 2 3 4 |
brew install libusb-freenect |
|
1 2 3 4 |
git clone https://github.com/avin2/SensorKinect.git |
Then uncompress Bin/SensorKinect093-Bin-MacOSX-v*tar.bz2
|
1 2 3 4 |
sudo ./install.sh |
Be aware that on OSX, PyOpenNI requires a framework build of python 2.7+ and that you must build it for x86_64 specifically. Also, I was having major problems with cmake properly finding the python includes location. I had to suggest a fix, so please see here for the necessary corrections. I have referenced a patched fork of the repository below.
|
1 2 3 4 5 6 7 8 9 |
export CPPFLAGS="-arch x86_64" git clone git://github.com/justinfx/PyOpenNI.git mkdir PyOpenNI-build cd PyOpenNI-build cmake -D PYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Headers ../PyOpenNI make |
copy the lib/openni.so module to the python2.7 site-packages
Once you have everything installed, you can try out the examples that are included both in the NITE source location that you downloaded and also in the PyOpenNI source location:
A question came up in the Maya-Python mailing list that I thought was a really good topic, and should be reposted.
Someone asked how you can create maya UI objects and embed them within your main PyQt application. Specifically he wanted to create a modelPanel and embed it so that he would have a camera view within his own PyQt window.
Here is my example of how to achieve this…
You need sip and the MQtUtil functions to convert between maya node paths and python Qbjects. Its the same idea as having to use those functions to get a reference to the maya MainWindow, in order to parent your dialog.
Second video in the python for maya series, just released through cmiVFX!
If you watched the first video, you now have a good grasp on Python. Sweet. Let’s plow through some more involved concepts like python juggernauts!
With a working knowledge of the python scripting language, and the Maya Python commands API, we can continue to learn new ways to solve more challenging problems, create complete scripts, and build user interfaces around our tools. We also introduce the Maya Python API; a lower-level interface into Maya.
This video focuses more on breaking down full scripts, as opposed to typing out syntax. Its jam packaged with information and moves fast to deliver you as much brain food as possible. The first segment of the video transitions from beginning to intermediate level, with the majority of the video being intermediate, and finishing out by touching on advanced concepts. The included project files are abundant, complete, and full of helpful documentation so that you can take your time and learn about each piece of the tools.
If you check it out, leave me feedback!
http://cmivfx.com/tutorials/view/328/Python+For+Maya+Vol+02
First video can be found here
This is a follow up post to my previous one on Installing PyQt4 for Maya 2011
Recently while putting together my next video tutorial for Python for Maya, I came to a section where I wanted to demo PyQt4 in Maya2012. But I was concerned that viewers would have to go through the complicated steps of building PyQt4. I noticed that other people have made available precompiled PyQt installers for windows (here) but I could not find any for OSX or linux. So I decided to put together a build.
I created a new project on github called MyQt4
https://github.com/justinfx/MyQt4
Its a Makefile for completely downloading and building PyQt4 for maya, and generating a .pkg installer. Hopefully someone can contribute improvements since I dont have a ton of experience writing makefiles, and also that someone might create a linux version.
Here is a link to the latest pkg build:
Snow Leopard:
Lion:
Mountain Lion:
Here are builds other people have made:
Just released my first online video tutorial, through cmiVFX
Amazing at Animation? Master of Modeling? Conquistador of Character Rigging?
But how is your Python?
This course brings the talented artist into the fold of the technical-side of Maya. Learn the basics of Python, and its place in your 3D workflow, with visual examples and real world problems. Get a kick-start on adding some automation into your life, and solving common problems in a fraction of the time. By the end of this video, you should have a deeper understanding of one of the languages Maya speaks under the hood, and how to start viewing your scenes in terms of glorious Python code!
Check it out: http://cmivfx.com/tutorials/view/320/Python+Introduction+Vol+01+-+Maya
If you check out this course, please leave me some feedback! I would love to hear your thoughts.
Stay tuned for more installments to come!

AtomSplitter has been updated to v1.6, available through cmivfx.com
Updates:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
COMMAND LINE HELP OSX: AtomSplitter.app/Contents/MacOS/AtomSplitter <chan file> [out file] Linux: AtomSplitter <chan file> [out file] Windows: AtomSplitter.exe <chan file> [out file] ========================================= HELP: >>> AtomSplitter -h Usage: AtomSplitter <chan file> [out file] Options: -h, --help show this help message and exit -o OBJ, --obj=OBJ Optional nuke-exported pointCloud .obj file -f FPS, --fps=FPS Set FPS rate (default 24) -x WIDTH, --width=WIDTH Set frame width (default 2048) -y HEIGHT, --height=HEIGHT Set frame height (default 1556) --filmwidth=FILMWIDTH Set film aperature width in mm (default 24.576) --filmheight=FILMHEIGHT Set film aperature height in mm (default 18.672) -s SCALE, --scale=SCALE Scale the translation values by this amount -F FORMAT, --format=FORMAT Output format (fbx, action, terragen) |

AtomSplitter has been updated to v1.5, available through cmivfx.com
Updates:

AtomSplitter (chanToFbx) has been updated to v1.2, available through cmivfx.com
Updates:
If you haven’t visited cmiVFX.com before, PLEASE check them out. Chris Maynard does an amazing job rounding up top talent in the industry to create these outstanding visual fx tutorials. The information is always cutting edge.