none
Skeletal Viewer "R610 abort() has been called" when using OpenCV cvShowImage RRS feed

  • Question

  • From this thread: http://social.msdn.microsoft.com/Forums/en-US/kinectsdknuiapi/thread/7a1a3569-b83b-4bd9-9b73-718c44992df1

    I modified the SkeletalViewer to produce a rgb stream with opencv.

     

    void CSkeletalViewerApp::Nui_GotVideoAlert( )
    {
     const NUI_IMAGE_FRAME * pImageFrame = NULL;
    
    	IplImage* kinectColorImage = cvCreateImage(cvSize(640,480),IPL_DEPTH_8U, 4);
    
     HRESULT hr = NuiImageStreamGetNextFrame(
     m_pVideoStreamHandle,
     0,
     &pImageFrame );
     if( FAILED( hr ) )
     {
     return;
     }
    
     NuiImageBuffer * pTexture = pImageFrame->pFrameTexture;
     KINECT_LOCKED_RECT LockedRect;
     pTexture->LockRect( 0, &LockedRect, NULL, 0 );
     if( LockedRect.Pitch != 0 )
     {
     BYTE * pBuffer = (BYTE*) LockedRect.pBits;
     m_DrawVideo.DrawFrame( (BYTE*) pBuffer );
    
     	cvSetData(kinectColorImage, (BYTE*) pBuffer,kinectColorImage->widthStep);
    	cvShowImage("Color Image", kinectColorImage);
    	cvWaitKey(10);
     }
     else
     {
     OutputDebugString( L"Buffer length of received texture is bogus\r\n" );
     }
    
     NuiImageStreamReleaseFrame( m_pVideoStreamHandle, pImageFrame );
    }
    


    It runs smoothly for the first 30 seconds until I get the abort error.

    What's going wrong?

    Wednesday, August 10, 2011 12:10 AM

Answers

  • Makes no sense that memory usage starts growing after you set it to NULL on the IplImage, because the data should be released by NuiImageStreamReleaseFrame anyways. Still, if that didnt crash, my guess is that somehow the sdk blocks  the memory of the image, and its giving an error when trying to deallocate it.

    I mean C++ inteface for OpenCV (2), which uses cv::Mat as a replacement for IplImages and other kinds of matrixes in the C one.

    Friday, August 12, 2011 9:49 AM

All replies

  • What do you mean with "the abort error"? Is the program generating an exception? If so, what is the callstack that you see when program has an exception.

    I can't provide expert advice on OpenCV, but I'm guessing that you could be running out of memory if you're not freeing the memory you allocate with cvCreateImage. From http://www.cs.iit.edu/~agam/cs512/lect-notes/opencv-intro/opencv-intro.html#SECTION00051000000000000000, it looks like you should call cvReleaseImage(kinectColorImage); when you're done with it, just like you call NuiImageStreamReleaseFrame when you're done with the frame.

    Eddy


    I'm here to help
    Wednesday, August 10, 2011 7:23 PM
  • Yea, I noticed that my memory was increasing as I was running the program. I tried releasing the image as you suggested but still get an error. =( I get a  cv::Exception (doesn't specify it?) as I execute it.

     

     else
     {
      OutputDebugString( L"Buffer length of received texture is bogus\r\n" );
     }
    
    	cvReleaseImage(&kinectColorImage);
     NuiImageStreamReleaseFrame( m_pVideoStreamHandle, pImageFrame );
    	
    }

    Referring to the call stack, I was wondering how to view it in Visual Studios?

     


    Thursday, August 11, 2011 12:33 AM
  • When you launch a program that causes an exception from VisualStudio, you should get an option to "Break" into the program to debug it, and from there you can open the Call Stack window through menu

    Debug|Windows|Call Stack

    Is that not possible? If so, what is the UI that you see when this thing aborts as you say?

    I don't know why cvReleaseImage would crash. I've never used OpenCV and can't provide support for it. I'd suggest seeing if calling cvCreateImage and cvReleaseImage right after each other (i.e.: without any code in between) also causes problems for you. If so, then you'll have to ask CV for support. If that scenario works, then maybe something that the code is doing is invalidating or corrupting memory. You'll have to investigate.

    Eddy


    I'm here to help
    Thursday, August 11, 2011 1:19 AM
  • Hum, maybe releasing the image after NuiImageStreamReleaseFrame or setting the data pointer to NULL on the iplImage before releasing?. Anyways, as I said in other threads, if youre already using c++, why not use the c++ interface instead of the c one?, I find it much easier to handle.

    Thursday, August 11, 2011 1:45 AM
  • Tried releasing the image after NuiImageStreamReleaseFrame  and it still crashed.

    I also tried setting it to NULL but once I executed, I realized by setting it to NULL I lose the address of what to release so Memory Usage started building up regardless. 

    I don't understand what you mean by using the C++ interface. I am already using C++ and not using any C.

    Thursday, August 11, 2011 4:33 AM
  • Makes no sense that memory usage starts growing after you set it to NULL on the IplImage, because the data should be released by NuiImageStreamReleaseFrame anyways. Still, if that didnt crash, my guess is that somehow the sdk blocks  the memory of the image, and its giving an error when trying to deallocate it.

    I mean C++ inteface for OpenCV (2), which uses cv::Mat as a replacement for IplImages and other kinds of matrixes in the C one.

    Friday, August 12, 2011 9:49 AM