Creating a GUI with Tkinter

Helpful Links:

http://openbookproject.net/py4fun/gui/tkPhone.html

Install EasyGUI on MacOS X: http://www.alexrams.com/blog/2012/01/14/install-easygui-on-mac-os-x/

Download EasyGUI: http://easygui.sourceforge.net/download/index.html

EasyGUI video: http://www.youtube.com/watch?v=IanIuak1-Dg

Tkinter

TkDocs tutorial list: http://www.tkdocs.com/tutorial/

Tkinter tutorial video: http://www.youtube.com/watch?v=uh6AdDX7K7U&noredirect=1

tkdocs grid tutorial: http://www.tkdocs.com/tutorial/grid.html

**Simple Tkinter GUI examples: http://www.ittc.ku.edu/~niehaus/classes/448-s04/448-standard/simple_gui_examples/index.html

Tkinter GUI example: http://www.learningpython.com/2006/02/08/creating-a-gui-in-python-using-tkinter/

TutorialsPoint Tkinter GUI Examples: http://www.tutorialspoint.com/python/python_gui_programming.htm

FileDialog stackoverflow help: http://stackoverflow.com/questions/9239514/filedialog-tkinter-and-opening-files

ActiveState’s Python recipe for Tkinter dialog: http://code.activestate.com/recipes/438123-file-tkinter-dialogs/

http://forums.devshed.com/python-programming-11/browse-button-for-tkinter-159021.html

 

More Links:

http://kickstand.tv/den/?p=26

http://forums.cgsociety.org/archive/index.php/t-726650.html

Maya-Python book: http://www.maya-python.com/chapter-7/

***Building Qt with Maya: http://www.maya-python.com/2011/09/building-and-installing-pyqt/#OSX

Advertisements

Sprint to the Finish

Update

The last day to defend for my thesis is October 12th. Therefore, I need to wrap this project up and write my ass off (along with making one hell of a presentation). Remaining objectives with timelines:

  • Establish User Controls
  • Hip/Shoulder Motion tracking
  • Analyze and Synthesize Horse 1, 2, and 3
  • Compare the results from the FFT
    • Is there enough information to create “general” equations for a horse walk given limb lengths?
  • Develop the mathematical equations for a horse walk (define the rotations for the legs)
  • Answer the question: What good does is the mathematical definition of each joint? What can I do with the results from this analysis?
  • Why is it better to have the math equation when you have to rotoscope the animation anyways? This gives you natural looking animation. The idea is that it provides the animator with a foundation of natural looking animation. Controls need to be established that allow for modulation like time shifts, time scales, etc. but maintain the walk’s synchronicity.

Create the presentation and walk through. Write the thesis paper.

Horse 1 walk analysis

Working on horse 1’s rear legs. As expected, there’s a period of 30 frames for the joint’s rotation signal. If this wasn’t the case, there movement would be out of synch. This whole signal analysis problem makes me think about mixing music. There has to be an interface for manipulating the joint signals and keeping everything in synch that’s similar to audio modulation.

Here’s how I manually select the characteristic signal that will represent the raw signal. I look at the peaks of the signal and jot down the frame where they appear. For the front legs, the overall period was 30 frames. I’m looking for a 30-frame period of the sampled signal that characterizes the overall signal. Then I’ll periodically extend the signal, save it out as an “adjusted” signal and call the FFT to better analyze the frequencies.

Theta 1 Peaks: 69, 97, 129, 161, 191, 221, 251

Theta 2 Peaks: 69, 99, 131, 163, 193, 223, 253

Theta 3 Peaks: 63, 94, 127, 159, 189, 219, 249

Theta 3 Troughs: 87, 117, 151, 181, 211, 241, 273

Theta 4 Peaks: 87, 117, 149, 181, 210

Python GUI Options

I googled “gui options in python” and one of the top links was from StackOverflow where a user asked if Python was suitable for GUI development. The replies look very helpful and are worth following up. The consensus pointed to wxPython as a very stable and well supported library for GUIs.

wxPython home site —> wxpython.org

wxDesigner home site —> http://www.wxdesigner-software.de/

wxPython tutorial —> http://zetcode.com/wxpython/
This dude seems to have a good handle on Maya and Python: http://www.rtrowbridge.com/blog/2010/02/maya-python-ui-example/
What I need to do next is finishing going through the differences for creating GUIs in Python and what I need from a GUI. First I need to reorganize for the semester so I can graduate and find a job!

A Qt GUI for Python scripts

What’s the point?

I want to use Qt to create a GUI for the Python scripts that I’ve written so far; extraction, analysis, and synthesis of a quadruped’s motion. The Python scripts need some cleaning up, but they’re working. I want to start by just creating a standalone widget for the scripts, but eventually turn the GUI and scripts into a plugin for Maya 2012.

What’re my options?

I’m seeing two main routes: PySide or PyQt. After searching for the differences between the two and looking at what was said on stackoverflow questions, I’ll go with PyQt. I’m not doing anything too intense. What I’m focused on now is ensuring that everything’s going to install and work together.

PyQt

Before installing, I went through the install directions and noticed that there might be a compatibility issue regarding my system’s versions of OSX and Python and the versions from the instructions. Now I’m trying to find out more information about what’s under Python’s hood. I’m starting with the Python documentation, here. Also, it might be as simple as changing the Qt paths after the installation of the QtSDK as mentioned here.

To install PyQt on my system (OS X 10.6.8), with Xcode installed, download and install SIP and PyQt4 following these directions here.

Getting Started with PyQt (from PyQtWiki)

PySide Binaries for Mac OS X: http://qt-project.org/wiki/PySide_Binaries_MacOSX

Installing PyQt on Mac OS X: here (2009)

Before I follow the above links, I need to determine whether installing SIP and PyQt4 will cause any compatibility issues with my current setup; Python 2.7 on OS X 10.6.8?

QtSDK (Qt Creator? I thought it was called Qt Designer?)

Downloaded and installed the QtSDK and was confused as to where the Qt Designer was located. So much of what I found online was focused on Qt Designer, but after installing and opening the QtSDK, the main application seemed to be called Qt Creator. I started searching for the difference between Creator and Designer, if there was one, and found the following video. It shows that once you’ve created a Qt Widget project for a Desktop GUI and you’re in the project tree to view the hierarchy (in edit mode), open the Forms folder and double click the mainwindow.ui file. This opens the Qt Designer with the visual library.

Maya + Python + Qt

Apparently I need to go over the Maya+Python Book some more. Here’s the book’s website: http://www.maya-python.com/2011/09/building-and-installing-pyqt/

Also, I need to find an answer to this question: What’s Qt modified for Maya 2012 Gold? http://usa.autodesk.com/adsk/servlet/item?id=14561324&siteID=123112

This might be a helpful project to start from also: Codeproject, Intro to QT in Maya 2012 http://www.codeproject.com/Articles/361231/Intro-to-QT-in-Maya-2012

Getting Started With Qt Designer

From Qt’s documents, http://doc.trolltech.com/4.3/designer-getting-started.html

Tutorial looks helpful as well, “Tutorial: Creating GUI Applications in Python with Qt”, http://www.cs.usfca.edu/~afedosov/qttut/

Tutorial from Zetcode.com: http://zetcode.com/tutorials/pyqt4/

“A Simple Tutorial On GUI Programming Using Qt Designer With PyQt4”, (2010) http://lionel.textmalaysia.com/a-simple-tutorial-on-gui-programming-using-qt-designer-with-pyqt4.html#.UDu0S0SEw5I

Synthesized Four Legs

I removed the translational influence and have only the rotational information for the four legs. So far, this looks pretty natural. Time to work on creating a GUI with Python and Qt for the tool.

Front Legs Animated

Above is a gif of simulated locomotion of the front legs for the horse walk. I’m trying to think of a more intelligent approach to generate the right side’s motion (left side was the analyzed side). Above was the brainless approach of computing the same signal for the left side, but manually adding a time shift of 10 frames (10 frames/24 frames per second). Maybe I’ve been staring at this too long, but I can’t think of how to extract this time shift from the earlier analysis. Anyways, I’ll remember this and come back to it, or just leave it for “Future Work”.

What I really want to focus on with this work is determining a mathematical definition for the gaits through analyzing the results of multiple gait analysis. If I look at the shoulder rotation signal for 4 different horses, is there some sort of comparative analysis that can tell me an “average” signal of all of them? I searched briefly and found information on cross correlation and coherence analysis.

I’ll have to check these out soon.

Time Shift Questions Answered

So when I ran the Synthesize script to key the rotation values for the synthesis rig’s joints, I was wondering how to account for the time offset in the signals and make sure that they were synchronized. It’s probably not too clear how I’m doing everything, so let me confuse things ever more.

After the Extraction script (sample the values for each joint’s rotation) I condition each signal. Conditioning or “adjusting” the signal so that it’s characteristic of the raw signal and preparing the signal so that it’s ready for the Fast Fourier Transform. This preparation leaves me with an offset and a time shift. The offset is from me removing the bias of the signal before sending it on its way to the FFT factory. The time shift is from my selection of beginning/end samples for the signal. Once the conditioning is complete, I have an “adjusted” signal ready for the FFT analysis.

 

 

 

The good news is that when these time shifts and the biases are accounted in the Synthesize script, the resulting motion looks nearly correct. However, there’s an offset in the knee signal that requires the adjustment node’s rotation to be tweaked by about 84 degrees. I won’t focus on solving this issue now, just document it and keep going…

Added the Knee to the Mix

The joint segment on the left is the synthesized one:


Had issues when applying the Fourier Series result to the signal. There’s an obvious time-shift issue when synchronizing all of the signals for the one leg. Ended up having to adjust the values for the knee.

Synthesizing the Front Left Leg

Steps

  1. Rotoscope Animation
  2. Run the Extraction.py script to query the joint angle values. (exports .txt files with the data)
  3. Open the sampled data in Microsoft Excel and condition (periodically extend). Note the bias (‘bias_init’) and the time shift (‘t_shift’)
  4. For each signal file, run the FFT.py script. This script exports extra values, amplitudes, and phases for the fourier series.
  5. Open these .txt files and reformat to .csv files.
  6. Follow the notes above to create the rig for synthesis
  7. Run the Synthesis.py script for each component to be animated.
  8. Adjust the signal (time shift and maybe an offset shift?)

Analysis to Synthesis

One point that I wanted to illustrate was the importance of using enough components when forming the Fourier Series. Below is a video of the Fourier Series for the shoulder rotation signal converging to the desired signal as the number of components increases.

Below are images of the frequency spectrum, the discrete frequency bins, and the discrete phase bins for the same shoulder rotation signal (‘Theta_01’):

Synthesis in Maya

With the first 100 components, the Fourier Series was calculated and used to key frame the shoulder joint in the following video. The purple-ish joint has been synthesized in order to match the black joint.

 

I’m still working on determining how to synchronize all of the signals to get the proper fluid motion. Here’s the synthesis with the shoulder and elbow rotation values calculated using Fourier Analysis:

 

Good progress has been made, but still lots to do. I’ll update tomorrow regarding the remaining future tasks before a (hopeful) September defense!
I’m out!

Advertisements