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,                                    
(unsignedchar*)(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 
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
{
 //.....getPixelBufferObject()->setImage(Convert_OpenCV_to_OSG_IMAGE(pImage, 
                                                            
((osg::Image*)(video.get()))));
 
 //.....
}(!viewer.done())

   What might be the problem? When I disable the code segment 

osgImg->setImage(cvImg->width,                                   cvImg->height, 
                                   1,                                   3,      
                              GL_RGB,                                  
GL_UNSIGNED_BYTE,                                    
(unsignedchar*)(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


      
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to