Hi, What I did: I created a class in which I setted frames from the video as textures (using setImage), and refreshed these textures using a callback. It works fine, but is maybe unadapted to your problem.
About setImage: I used GL_RGB8 where you tried "3", and GL_BGR as the following argument (I guess OpenCV has a different convention). Ugras Erdogan wrote: > Dear All, > I am using openCV and OSG together in my project. What the problem is as > follows: > 1) When I try to convert the IplImage to osg::Image the following command > line trace occurs. Except the last three lines, the trace shows the openCV > and osg image properties. > > Pixel Bits: 32, Image Size (Byte): 307200 > Video Depth: 1 > cv Channels = 3 > Convert_OpenCV_to_OSG_IMAGE()::Origin Passed 2... > Mutex w/r : 0 > error pixelFormat = error pixelFormat = 33 > Warning: detected OpenGL error 'invalid operation' after RenderBin::draw(,) > Warning: detected OpenGL error 'invalid operation' after RenderBin::draw(,) > > 2) I lock the mutex in order to prevent simultaneous writes to osg::Image > data and as you can see at 5th line above it returns the correct value 0. > Then use the following code: > > void Convert_OpenCV_to_OSG_IMAGE(IplImage* cvImg, osg::Image* osgImg) > { > //..... > osgImg->setImage(cvImg->width, > cvImg->height, > 1, > 3, > GL_RGB, > GL_UNSIGNED_BYTE, > (unsigned char*)(cvImg->imageData), > osg::Image::AllocationMode::NO_DELETE, > 1); > //..... > } > The above code segment is similar to the one in a post I encountered in this > forum (John Steinbis jsteinbis at gmail.com > (osg-users%40lists.openscenegraph.org?Subject=%5Bosg-users%5D%20Convertion%20to%20osg%3A%3AImage%20from%20IplImage%20%28OpenCV%29%20for%0A%09useas%20texture&In-Reply-To=E4D07AB09F5F044299333C8D0FEB45E9042314AE%40nrccenexb1.nrc.ca) > Mon Sep 17 11:04:04 PDT 2007) but there are modifications for my needs. I can > be sure that cvImg->imageData contains the actual processed video data > because I can see the results in a seperate window. But the above problem > occurs when I try to render the processed video as a texture onto a surface. > > 3) The above function Convert_OpenCV_to_OSG_IMAGE() is called in the main > loop as follows: > > while(!viewer.done()) > { > //..... > getPixelBufferObject()->setImage(Convert_OpenCV_to_OSG_IMAGE(pImage, > ((osg::Image*)(video.get())))); > > > //..... > } > What might be the problem? When I disable the code segment > > > osgImg->setImage(cvImg->width, > cvImg->height, > 1, > 3, > GL_RGB, > GL_UNSIGNED_BYTE, > (unsigned char*)(cvImg->imageData), > osg::Image::AllocationMode::NO_DELETE, > 1); > > everything is OK but as you can guess I cannot use the processed frame as a > texture in 3D environment. > Thanks for your helps... > Best Regards > Ugras Erdogan > > ------------------ > Post generated by Mail2Forum ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12381#12381 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org