Running Voodoo blender 2.5+ script fails

Scripting in Blender with Python, and working on the API

Moderators: jesterKing, stiv

Post Reply
superqd
Posts: 4
Joined: Mon Jun 27, 2011 6:16 am

Running Voodoo blender 2.5+ script fails

Post by superqd » Mon Jun 27, 2011 8:36 am

Hi,

I'm somewhat new to Blender, and even newer to Voodoo, and I ran into a problem executing the Voodoo script in Blender. Here is what I'm running into:

My machine is Windows 7 (64 bit) with 8 cores and 8 GB of RAM.

1) I launch Voodoo 1.1.0 beta and load my image sequence (select first image of sequence).

2) I set the "Move Type" to "Free Move" and accept the other values as is in the "Sequence Select" dialog. I click "OK" and then click "Track" in the main view.

3) It takes a while to track, there are 1650 images in the sequence. It finishes eventually (successfully).

4) I click File->Save->Blender Python Script. In the save dialog, I specify a name and the type as "Blender 2.5x and higher". It saves successfully (I chose to save all rather than limit the frames to 1500).

5) I launch Blender v2.58.0 r37702. I delete all the items from the default view, and now there's nothing.

6) I switch the 3D view to Text Editor view and click Text->Open Text Block. I select the file exported in step #4 and it loads successfully.

7) I click "Run Script" in Text Editor and and error dialog pops up that says "Python script fail, look in the console for now...".

8) I switch the view to "Python Console" and don't see any errors, just the info that always shows up there (stuff about import modules, etc).

9) The line highlighted in step #7 says:

scene.set_frame(42)

I don't see anything wrong with that line. My first frame in Blender is set to 42, so I don't see what the issue is. I've tried changing both to 1, and got the same result.


10) I'd never been able to bring up the second window in Blender (Blender used to always have a python window or something that would launch first, but it no longer shows this window and I didn't know how to bring it back up). I just went to Help->Toggle System Console and up popped a window that said:

found bundled python: C:\Program Files\Blender Foundation\Blender\2.58\python
Traceback (most recent call last):
File "\camera motion.py", line 42, in <module>
AttributeError: 'Scene' object has no attribute 'set_frame'
Traceback (most recent call last):
File "\camera motion.py", line 42, in <module>
AttributeError: 'Scene' object has no attribute 'set_frame'


I'm guessing that Blender changed it's Python bindings or something, and Voodoo isn't up to date? Is that the issue? Is this an easy thing to change/fix?

Thanks
-Q

superqd
Posts: 4
Joined: Mon Jun 27, 2011 6:16 am

here is the first bit of code that fails

Post by superqd » Mon Jun 27, 2011 8:50 am

I don't see a way to attach a file to this thread, so here is the first few lines of the code that fails:

# blender export (blender version 2.5x and higher)
# created by voodoo camera tracker - www.digilab.uni-hannover.de
# Creation date: Sun Jun 26 20:35:41 2011
# USAGE: load this python script into Blender's text editor and execute the script with ALT-P
# use the 'voodoo_render_cam' for rendering your scene
# use the helper object 'voodoo_scene' to rotate, translate and scale the scene

import bpy
import mathutils
import string
import math
scene = bpy.context.scene
dummy = bpy.data.objects.new('voodoo_scene', None)
dummy.location = (0.0, 0.0, 0.0)
dummy.rotation_euler = ( -3.141593/2, 0.0, 0.0)
dummy.scale = (0.2, 0.2, 0.2)
scene.objects.link(dummy)
data = bpy.data.cameras.new('voodoo_render_cam')
data.lens_unit = 'DEGREES'
vcam = bpy.data.objects.new('voodoo_render_cam', data)
vcam.location = (0.0, 0.0, 0.0)
vcam.rotation_euler = (0.0, 0.0, 0.0)
vcam.scale = (1.0, 1.0, 1.0)
data.lens = 35.0
data.shift_x = 0.0
data.shift_y = 0.0
data.dof_distance = 0.0
data.clip_start = 0.1
data.clip_end = 1000.0
data.draw_size = 0.5
scene.objects.link(vcam)
vcam.parent = dummy
data = bpy.data.meshes.new('voodoo_FP3D_cloud')
mesh = bpy.data.objects.new('voodoo_FP3D_cloud', data)
mesh.location = (0.0, 0.0, 0.0)
mesh.rotation_euler = (0.0, 0.0, 0.0)
mesh.scale = (1.0, 1.0, 1.0)
scene.objects.link(mesh)
mesh.parent = dummy

#Camera Parameters
scene.set_frame(42)
vcam.data.lens = 16.076587
vcam.matrix_world = mathutils.Matrix([0.992738,0.112815,-0.041751,0.000000], [0.110513,-0.992414,-0.053854,0.000000], [-0.047509,0.048849,-0.997676,0.000000], [3.806755,-19.574036,9.838935,1.000000])
vcam.keyframe_insert('location')
vcam.keyframe_insert('scale')
vcam.keyframe_insert('rotation_euler')
vcam.data.keyframe_insert('lens')

superqd
Posts: 4
Joined: Mon Jun 27, 2011 6:16 am

checked the api docs

Post by superqd » Mon Jun 27, 2011 9:08 am

Ok, I started searching for the 2.58 Python API docs (not easy to find), and I'm still not sure I had the latest version, but apparently the API call set_frame() is now frame_set(). W.T.F.

Anyway, I replaced all set_frame() calls with frame_set() and voila no more set_frame error.

Ha, not so fast. I now get the following (at line 44):

TypeError: mathutils.Matrix(): expects no args or 2-4 numeric sequences.

The offending line is this:

vcam.matrix_world = mathutils.Matrix([0.992738,0.112815,-0.041751,0.000000], [0.110513,-0.992414,-0.053854,0.000000], [-0.047509,0.048849,-0.997676,0.000000], [3.806755,-19.574036,9.838935,1.000000])


I looked at the docs and still have no clear idea at the moment how to fix this. I can't find the docs that show the Matrix constructors, I just see other methods. Or maybe not, I've never coded in Python so I have no idea what I'm looking at.

Anybody have any ideas on this one?

superqd
Posts: 4
Joined: Mon Jun 27, 2011 6:16 am

This looks like it's going to suck

Post by superqd » Mon Jun 27, 2011 9:15 am

OK, from what I can tell, the Voodoo exported script uses an older Matrix constructor that specified rotation and translation and scale all in the constructor. Now, Blender only supports these as separate matrices. So, the Voodoo script is pretty broken.

Anyone know of an easy way to break the Voodoo Matrix constructor apart into the separate constructors for Matrix.Rotation, Matrix.Translation, etc, ?

darietto
Posts: 1
Joined: Thu Jul 07, 2011 12:08 pm

Re: This looks like it's going to suck

Post by darietto » Thu Jul 07, 2011 12:11 pm

Some blender-pyython changes.
I've tried this and it seems to work
vcam.matrix_world = ((0.992738,0.112815,-0.041751,0.000000), (0.110513,-0.992414,-0.053854,0.000000), (-0.047509,0.048849,-0.997676,0.000000), (3.806755,-19.574036,9.838935,1.000000))

so:
- remove the mathutils.Matrix
- replace [] to ()


hope it works

-(0_0)-
Posts: 3
Joined: Fri Jul 08, 2011 3:32 am
Location: Hong Kong

Post by -(0_0)- » Fri Jul 08, 2011 3:37 am

Try this Add-on. It works for me on Blender 2.58 / Windows7.

Voodoo camera Import
http://wiki.blender.org/index.php/Exten ... doo_camera

HawkpathAS
Posts: 10
Joined: Sat Aug 06, 2011 4:20 am

Post by HawkpathAS » Sat Aug 06, 2011 5:20 am

-(0_0)- wrote:Try this Add-on. It works for me on Blender 2.58 / Windows7.

Voodoo camera Import
http://wiki.blender.org/index.php/Exten ... doo_camera
How do you use/run these plugins? I'm a newbie to scripting and when I went to your link there was another link to the download site, and I went there and it was a script, but what do I do with it?

-(0_0)-
Posts: 3
Joined: Fri Jul 08, 2011 3:32 am
Location: Hong Kong

Post by -(0_0)- » Mon Aug 08, 2011 3:18 am

Just download the file (io_import_voodoo_camera.py) and place it in the "addons" folder.

Then, in Blender, the import voodoo option should be available in Preferences > Add-ons.
Activated it, and it should be able to be found in File > Import .

HawkpathAS
Posts: 10
Joined: Sat Aug 06, 2011 4:20 am

Post by HawkpathAS » Mon Aug 08, 2011 4:58 am

-(0_0)- wrote:Just download the file (io_import_voodoo_camera.py) and place it in the "addons" folder.

Then, in Blender, the import voodoo option should be available in Preferences > Add-ons.
Activated it, and it should be able to be found in File > Import .
Yeah, I know what to do with the file, but how do I download it? I went to the link and clicked on the download link when I got there, but it displayed the script, but I couldn't figure out where to download.

HawkpathAS
Posts: 10
Joined: Sat Aug 06, 2011 4:20 am

Re: This looks like it's going to suck

Post by HawkpathAS » Mon Aug 08, 2011 5:17 am

superqd wrote:OK, from what I can tell, the Voodoo exported script uses an older Matrix constructor that specified rotation and translation and scale all in the constructor. Now, Blender only supports these as separate matrices. So, the Voodoo script is pretty broken.

Anyone know of an easy way to break the Voodoo Matrix constructor apart into the separate constructors for Matrix.Rotation, Matrix.Translation, etc, ?
Also something that you can try, I just copied the the whole script and pasted it into Microsoft Word (you could also use Wordpad or some text editing software with a find and replace all feature) and used the find and replace feature to replace set_frame with frame_set, replace [ with (, replace ] with ), and replace Mathulis.Matrix with blank (replace it with a blank, therefore deleting it.

-(0_0)-
Posts: 3
Joined: Fri Jul 08, 2011 3:32 am
Location: Hong Kong

Post by -(0_0)- » Mon Aug 08, 2011 7:50 am

That's the script you need. If the script is displayed in the browser, just [Ctrl + S] to save it.

Or, right-click on the link and save it. ("Save link as..." in Firefox)

HawkpathAS
Posts: 10
Joined: Sat Aug 06, 2011 4:20 am

Post by HawkpathAS » Mon Aug 08, 2011 3:04 pm

-(0_0)- wrote:That's the script you need. If the script is displayed in the browser, just [Ctrl + S] to save it.

Or, right-click on the link and save it. ("Save link as..." in Firefox)
Ahh, okay. I did try to save the link, but it messed up, like usual on my computer. So I'll try ctrl-s. Thanks!

HawkpathAS
Posts: 10
Joined: Sat Aug 06, 2011 4:20 am

Post by HawkpathAS » Mon Aug 08, 2011 3:13 pm

-(0_0)- wrote:That's the script you need. If the script is displayed in the browser, just [Ctrl + S] to save it.

Or, right-click on the link and save it. ("Save link as..." in Firefox)
Well, I did Ctrl-S, but it could only save it as an HTML, an MHT, or a txt file. I don't think that any of those would substitute for a Python file, but I don't know.

syw
Posts: 1
Joined: Thu Sep 22, 2011 1:04 pm

Post by syw » Thu Sep 22, 2011 1:11 pm

HawkpathAS wrote:
-(0_0)- wrote:That's the script you need. If the script is displayed in the browser, just [Ctrl + S] to save it.

Or, right-click on the link and save it. ("Save link as..." in Firefox)
Well, I did Ctrl-S, but it could only save it as an HTML, an MHT, or a txt file. I don't think that any of those would substitute for a Python file, but I don't know.
find another link for the script:
http://projects.blender.org/scm/viewvc. ... threv=1877

I came across the same problem and this script work out all right.

HawkpathAS
Posts: 10
Joined: Sat Aug 06, 2011 4:20 am

Post by HawkpathAS » Thu Sep 22, 2011 1:15 pm

syw wrote:
HawkpathAS wrote:
-(0_0)- wrote:That's the script you need. If the script is displayed in the browser, just [Ctrl + S] to save it.

Or, right-click on the link and save it. ("Save link as..." in Firefox)
Well, I did Ctrl-S, but it could only save it as an HTML, an MHT, or a txt file. I don't think that any of those would substitute for a Python file, but I don't know.
find another link for the script:
http://projects.blender.org/scm/viewvc. ... threv=1877

I came across the same problem and this script work out all right.
Thanks, but I actually just realized that I can just type .py at the end of the file name.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests