WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 4.75 average. Display Modes
  #1  
Old 03-10-2010, 05:52 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Thank you

Thanks you very much that worked perfectly.

Now I, like the original poster, just need to sort a method for converting frame buffer images to IPLImage!!

Came across this -

http://www.depthfirstsearch.net/blog...cv-and-python/

- which seems to address this prob however I am unable to utilize this at the moment due to my severe lack of C or C++ know-how. Any windows/C++ wizards out there who could help?
Reply With Quote
  #2  
Old 03-10-2010, 06:40 AM
sircedric4 sircedric4 is offline
Member
 
Join Date: Aug 2009
Posts: 22
Quote:
Originally Posted by nige777 View Post
Thanks you very much that worked perfectly.

Now I, like the original poster, just need to sort a method for converting frame buffer images to IPLImage!!

Came across this -

http://www.depthfirstsearch.net/blog...cv-and-python/

- which seems to address this prob however I am unable to utilize this at the moment due to my severe lack of C or C++ know-how. Any windows/C++ wizards out there who could help?
I am still trying to find a better way to do the conversion myself, but in the meantime I was able to get something to "work" using the actual screen capture and file save capability in Vizard.

I used the viztask schedule capability and basically saved each image to a bitmap and then loaded the bitmaps into the squares example. It is slow, only average 2 -3 frames per second which doesn't work for me, but might work for your application. I am attaching the code I used in squares for you to look at. Maybe it'll help you.

Like, you I found that same link that might address the problem but I couldn't figure out how to do anything with it. I do know C++, but only as a language. Getting all the plugins, modules, and runtime environments setup is beyond my capability. I'd kill for some sort of class to attend that would cover all the setup stuff that people assume you know just because you know a language.

Code:
def SquareIt():
	global img, storage

	while True:
		name = 'C:/DK Files/OpenCV Learn/test1.bmp'
		yield viz.window.screenCapture(name)
#
		# create memory storage that will contain all the dynamic data
		storage = cvCreateMemStorage(0);
		img0 = cvLoadImage( name, 1 );
		if not img0:
			print "Couldn't load %s" % name
		img = cvCloneImage( img0 );
		# force the image processing
		on_trackbar(0);
		# Also the function cvWaitKey takes care of event processing
		cvWaitKey(5);
			# clear memory storage - reset free space position
		cvClearMemStorage( storage );

t = viztask.schedule( SquareIt() )
vizact.onkeyup('s',t.kill)
Reply With Quote
  #3  
Old 03-10-2010, 09:38 AM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
Yes, figuring out how to build complex C/C++ projects is a hideous nightmare, particularly on Windows with its plethora of compilers. That's why sane people prefer Python.

You might have a look at ctypes_opencv. It's not intended for Python 2.4, but as it's pure python code it might be made to work. Requires the ctypes module, and there are quite a few lines of the form:

Code:
min_val_p = c_double() if min_val is True else min_val
that need to be converted to e.g.:
Code:
if min_val is True:
  min_val_p = c_double()
else:
  min_val_p = min_val
Those are the difficulties that appear right off the bat, anyway...
Reply With Quote
  #4  
Old 03-10-2010, 09:48 AM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
Quote:
You might have a look at ctypes_opencv. It's not intended for Python 2.4, but as it's pure python code it might be made to work.
Sorry, that was perhaps not clear. It's still a wrapper around the C dlls, but ctypes allows you to write the wrapper directly in Python rather than in some C-like (SWIG) or C++-like (SIP) dialect...If the problem is in the original pyopencv wrapper code, then this might provide a workaround...
Reply With Quote
  #5  
Old 03-10-2010, 10:56 AM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
Thumbs up

OK, I got interested and got it to work (at least, I got capture-cam and a couple others to run). Download. The src/ctypes_opencv folder goes in Vizard's site-packages directory, there's also a folder of modified demos (I assume the syntax is a bit different). Let me know if the PIL conversion works...
Reply With Quote
  #6  
Old 03-11-2010, 04:12 AM
nige777 nige777 is offline
Member
 
Join Date: Nov 2007
Location: UK
Posts: 78
Thumbs up

Wow, you really are the man . I'm itching to try this out - will report back as soon as I have.
Reply With Quote
  #7  
Old 03-11-2010, 12:32 PM
JimC JimC is offline
Member
 
Join Date: Jun 2009
Posts: 42
I wrote to the author of ctypes-opencv and ended up applying the fixes to the bleeding-edge version and mailing that to him. Interestingly, it looked like there might be some code added to the bleeding-edge version relevant to exactly the problem you've been writing about, so you might want to look at that. It's here.
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Native WorldViz support for character animation luakt Vizard 10 09-15-2008 11:39 PM
Incampatible CAL3D files luakt Vizard 4 09-14-2008 11:28 PM
WorldViz support of callada luakt Vizard 2 09-14-2008 10:59 PM


All times are GMT -7. The time now is 10:50 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC