Webcam plugin crash on exit

futnuh

09-07-2006 07:59:12

I've been playing around with Timme's webcam plugin (latest beta release as mentioned near the end of this message thread, http://www.ogre3d.org/phpBB2/viewtopic.php?t=16572). I've compiled both the plugin and the included demo program from source against the Dagon OgreSDK.. It works nicely.

Copying the plugin DLL over to my pyogre installation (built against the same OgreSDK release), my test script successfully shows the webcam output as a background image (texture on a Rectangle2D). The only problem is that I get a Python "invalid memory access" crash when exiting. Note, there is nothing in the Ogre.log and this problem doesn't arise with the above-mentioned C++ demo program.

As this is most likely a python issue, I thought I'd ask for advice here before going into the main forums. Any thoughts?

futnuh

12-07-2006 04:32:54

Asl discussed in this thread, http://www.ogre3d.org/phpBB2/viewtopic.php?p=161747#161747, calling the PlugIn's shutDown() method prior to exit has seemingly solved the problem.

dermont

14-07-2006 17:55:47

Hi funtuh thanks for bringing this up, must have missed it on the main board. I've just been playing around with this on pyOgre, pretty neat. I've just tried attaching the material to a tiled plane (probably not what it's intended for) and the results were pretty cool.

plane = ogre.Plane()
plane.normal = ogre.Vector3.UNIT_Z
plane.d = 200

mm = ogre.MeshManager.getSingleton()
mm.createPlane('FloorPlane', 'General', plane, 640.0, 480.0,
5, 5, True, 1, 5.0, 5.0, (0, 1, 0))

entity = sceneManager.createEntity('floor', 'FloorPlane')
entity.setMaterialName('Plane/Background')
sceneManager.rootSceneNode.createChildSceneNode().attachObject(entity)


Noticed you were using ExternalTextureSource/Manager. Are you planning on submitting a patch for these interface files?. If not I'll submit a patch tomorrow.

futnuh

14-07-2006 18:44:12


Noticed you were using ExternalTextureSource/Manager. Are you planning on submitting a patch for these interface files?. If not I'll submit a patch tomorrow.


Yes, it's pretty cool, isn't it? I was going to submit the patches - please go ahead though since you can commit and I've been mucking heavily with the VS project file.

Two issues that I'm fighting with:

1) I need to get access to the image data. While the plugin's Webcam.h defines getCvImage() and getOgreImage() methods, these are obviously not exposed by the pyOgre bindings. I'm wondering how to do this? Perhaps at runtime via ctypes?

2) I discovered that the actual image returned by the CV::QueryFrame(mCVCapture) call in the plugin's inner loop (Webcam.cpp) is only 320x240.


while(!get_signaled())
{
mCvCaptureImage = CV::cvQueryFrame( mCvCapture );
assert(mCvCaptureImage);
std::cout << "inside plugin: " << std::endl;
std::cout << " size: " << mCvCaptureImage->imageSize << std::endl;
std::cout << " width: " << mCvCaptureImage->width << std::endl;
std::cout << " height: " << mCvCaptureImage->height << std::endl;
std::cout << " depth: " << mCvCaptureImage->depth << std::endl;
std::cout << " origin: " << mCvCaptureImage->origin << std::endl;
std::cout << " data order: " << mCvCaptureImage->dataOrder << std::endl;
[...]


This is with a Logitech Quickcam Orbit, a camera that has a 1.3 MegaPixel sensor and can easily do video at 640x480. I wonder if you are seeing the same small size? There's lots of discussion of this in OpenCV Yahoo forums http://groups.yahoo.com/group/OpenCV/msearch?query=640x480&pos=110&cnt=10. I'm trying to find a programmatic way of getting higher resolution.

My aim in all this is to get pyOgre working with the ARToolkitPlus to do Ogre rendering over a tracked marker tile ...

futnuh

14-07-2006 19:22:20

I'm using the webcam image as a 2D background ...


self.rect = ogre.Rectangle2D(True)
self.rect.setCorners(-1.0, 1.0, 1.0, -1.0)
v = ogre.Vector3.UNIT_SCALE
num = 10000.0
minval = ogre.Vector3(v.x*-num, v.y*-num, v.z*-num)
maxval = ogre.Vector3(v.x*num, v.y*num, v.z*num)
self.rect.boundingBox = ogre.AxisAlignedBox(minval,maxval)
self.rect.boundingBox.setExtents(-1.0, 1.0, 0, 1.0, -1.0, 0)
self.rect.setMaterial("AR/Rectangle")
self.rect.renderQueueGroup = ogre.RENDER_QUEUE_BACKGROUND

self.node = self.rootnode.createChildSceneNode("Background")
self.node.attachObject(self.rect)



material AR/Rectangle
{
technique
{
pass
{
ambient 0.7 0.7 0.7
cull_hardware none
depth_check off
depth_write off

texture_unit
{
texture_source webcam_video
}
}
}
}

dermont

14-07-2006 20:55:34

Yep I've already done the 2D background background. Maybe others would be interested in the plugin and associated dll's.

futnuh wrote:

I was going to submit the patches - please go ahead though since you can commit and I've been mucking heavily with the VS project file.

Sorry I can't commit I'm no longer officially involved in pyOgre / pyCegui. As for submitting patches I don't think there is anything wrong with creating a patch from the pyogre-dev.1.2/pyogre/ogre directory. I too have to make changes to my VS project files to reflect my own build environment. Anyway I'll submit tomorrow.

On a side note I did implement your Quaternion changes and reflected that in the pyOgreTODO for which you shoiuld be listed as a contributor. Sorry for not replying. Thanks for all the positive feedback you provided.

1) Sorry I haven't really looked into this, exposing the methods is probably going to be tricky. Maybe some proxy classes?

2) Yes I'm seeing pretty poor resoulution due to scaling but I'm using an ancient logitech QuickCam Express. I'll try and see if I can find my digital camera/webcam and test using that.

I implemented your code and it appears to be showing the correct maximum capture resolution of 352 by 288 pixels.

inside plugin:
size: 304128
width: 352
height: 288
depth: 8
origin: 1
data order: 0

Here's a screenshot of pyCegui using render to texture with 3 different schemes:

http://img166.imageshack.us/img166/372/ ... ot05jd.jpg

Good luck with the implementation of ARToolkitPlus, let us know how it goes.