Re: WebCam with wxEuphoria
- Posted by mattlewis (admin) Mar 28, 2011
- 1271 views
Thanks for the help so far! I've tried the following:
1) Saving the image to disk from OpenCV and opening the image in my EU code to display on screen
2) Drawing the individual pixel values of the image using draw_point
3) The method suggested by raseunew that creates wxImage from the pixels in memory
Method 2 works better but also has a noticeable lag from drawing the individual pixels.
There might be some ways to speed it up. For instance, since you're capturing video, many of the pixels may not be changing in each frame. You could possibly skip updating those. You might also detect if you have the same color pixel multiple times, and use draw_line() to reduce the number of calls. There might also be some micro optimizations possible in your euphoria code. Finally, you might compare the difference interpreted vs translated.
I like what raseunew suggested but I'm getting strange results. I'm working with 320 by 240 images from my webcam and using the code below, the picture shrinks and is tiled when displayed in my EU program. I thought there might be a problem with how I'm interfacing with my C++ code, but Method 2 would not work if there was a problem there. I can make things slightly better by playing with set_user_scale but this does not seem like the appropriate solution. Any help is appreciated!
- Ira
--// create image from converted bgr surface atom img = wx:create(wxImage, { openCVImageWidth, openCVImageHeight, bgr }) --// free converted bgr surface free(bgr) --// create bitmap from image atom bmp = wx:create(wxBitmap,{ BM_FROM_IMAGE, img, -1 })
I'm really surprised that works at all. The "data" parameter is supposed to be XPM data. If you're not familiar with XPM, there are several used in the demos. When they're created, the wxEuphoria library converts the euphoria sequences into "raw" xpm char data. It's basically an array of pointers to C strings.
You can pass the euphoria sequence versions to the wxBitmap constructor, and the library converts it, or you can convert it yourself and pass it to the wxImage constructor.
Matt