Search code examples
opencvimage-resizing

opencv resize + free kinect


I am trying to use opencv and freekinect library and I am building it with cmake in ubuntu 16 and there is no error or warning. But when I use resize function my code crashes. This is the part of the code that cause problem.

libfreenect2::Frame *rgb2 = frames2[libfreenect2::Frame::Color];
    libfreenect2::Frame *ir2 = frames2[libfreenect2::Frame::Ir];
    libfreenect2::Frame *depth2 = frames2[libfreenect2::Frame::Depth];


    //////////////////////to show 
        ///depth
        cv::Mat depthmat = cv::Mat(depth->height, depth->width, CV_32FC1, depth->data);
        cv::Mat depthmat2 = cv::Mat(depth2->height, depth2->width, CV_32FC1, depth2->data);

        //rgb
        cv::Mat RGBmat = cv::Mat(rgb->height, rgb->width, CV_8UC4, rgb->data);
        cv::Mat RGBmathalf =cv::Mat(rgb->height/2, rgb->width/2, CV_8UC4);
        cv::Mat RGBmat2 = cv::Mat(rgb2->height, rgb2->width, CV_8UC4, rgb2->data);
        //cv::resize(RGBmat, RGBmathalf, Size(512, 424),0,0,INTER_LINEAR);

    cv::imshow("depth_device1", depthmat );
        cv::imshow("depth_device2", depthmat2 );

        cv::imshow("RGB1", RGBmat );
        cv::imshow("RGB2", RGBmat2 );

Without resize function I can see the RGB stream but when I add the resize it crashes with the error of "Segmentation fault (core dumped)". Any help would be appreciate.


Solution

  • I solved my problem. I had a problem with VAAPI and nvidia gtx 1060 driver, since I have dual GPU. I just uninstall the default driver of nvidia and install the one mentioned here https://askubuntu.com/a/836504 and uninstall VAAPI. Now, it is working fine. Thank you so much for all the helps.