Hi Praveena,

You say the program crashes but provide absolutely no guidance on
where and when it crashes.  This gives us nothing to go on.  Please
use a debugger to get a stack trace of where it is crashing and then
pass on this info.

Robert.

On 4 June 2012 06:52, Praveena Sarathchandra <[email protected]> wrote:
> Hi,
>
> So far I've been successful in showing the first captured frame using
> OpenCV, in OSG.
>
>> // IplImage* cvImg is the webcam output image captured using
>> cvQueryFrame(capture)
>> osg::ref_ptr<osg::Image> osgImage = new osg::Image;
>> osgImage->setImage(cvImg->width,cvImg->height, 3,
>>                GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,
>>                (BYTE*)(cvImg->imageData),
>>                osg::Image::AllocationMode::NO_DELETE,1);
>
>
>>
>> osg::ImageStream* imageStream = dynamic_cast<osg::ImageStream*>(
>> osgImage.get() );
>> if( imageStream ) imageStream->play();
>
>
>>
>> osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
>> texture->setImage( osgImage.get() );
>
>
>>
>> osg::ref_ptr<osg::Drawable> quad = osg::createTexturedQuadGeometry(
>>         osg::Vec3(), osg::Vec3(1.0f, 0.0f, 0.0f), osg::Vec3(0.0f, 0.0f,
>> 1.0f) );
>> quad->getOrCreateStateSet()->setTextureAttributeAndModes(0,texture.get()
>> );
>
>
>>
>> osg::ref_ptr<osg::Geode> geode = new osg::Geode;
>> geode->addDrawable( quad.get() );
>
>
>
> But I want the entire webcam stream in OSG, after preprocessing in OpenCV.
> After googling I found this answer as a guide:
> http://markmail.org/message/txqiv4plykf3bm3r#query:+page:1+mid:txqiv4plykf3bm3r+state:results
>
> According to that I made my Camera class inherit from osg::ImageStream and
> called dirty() whenever a new frame is captured. But when I run the program
> it crashes! How can I get this to work?
>
>> class Camera : public QObject, public osg::ImageStream
>> {
>>     Q_OBJECT
>> public:
>>     Camera();
>>     ~Camera();
>>     IplImage* getFrame();
>> private:
>>     CvCapture* capture;
>>     IplImage* frame;
>>     int timerId;
>> public slots:
>>     void timerEvent(QTimerEvent *);
>> private slots:
>>     void initialize();
>> };
>
>
>> Camera::Camera() : QObject(), osg::ImageStream()
>> {
>>     capture = cvCreateCameraCapture(0);
>>     frame = cvQueryFrame(capture);
>>     QTimer::singleShot(0,this,SLOT(initialize()));
>> }
>>
>> void Camera::initialize(){
>>     frame = cvQueryFrame(capture);
>>     timerId = startTimer(10);
>> }
>> void Camera::timerEvent(QTimerEvent *){
>>    frame = cvQueryFrame(capture);
>>
>>    dirty();
>> }
>
>
> Thanks
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to