Hi Ugras, Did you try to run your code in single threaded mode? This could give you a hint whether problem is a race.
It's difficult to guess what's going on, but did you try to lock mutex while you read data as well? This might effectively make your program serial during those phases (which defeats the whole purpose of running concurrent) but would at least indicate Ismail On Mon, May 18, 2009 at 5:49 PM, Ugras Erdogan <ugraserdo...@yahoo.com> wrote: > Hi, > First of all thanks for all the replies. But problem remains the > same. Yes, OpenCV uses BGR format instead of RGB and the image origin should > be flipped. Do you think there might be a multithreading issue as I use the > same memory space for incoming video data from cam and for the processed > video texturing. But I use a mutex synchronization object during > modifications. But I do not know at the low level, if DirectShow (as I > remember OpenCV relies on that for Win32 platforms)takes care of the > threading issues when building the scene graph for video capture. > What happens at best is this: I see the live unprocessed video as a > texture on 3D object when I do not use setImage function and processed video > at the openCV window. > I will be working on this. I will be appreciate further > suggestions.... > Best Regards > Ugras > > ________________________________ > From: Maxime BOUCHER <m.boucher...@gmail.com> > To: osg-users@lists.openscenegraph.org > Sent: Monday, May 18, 2009 3:27:47 PM > Subject: Re: [osg-users] OSG_OpenCV Help > > 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 > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org