View my account

Create own intelrealsense project using opencv in Visual Studio

Comments

5 comments

  • MartyG

    Hi Pink Spear  I researched all the cases I could find on the internet regarding this particular error, which I have not seen before.  Of all the cases, the only one with a suggested solution advised to "add oleautomation to the IBar attributes".

    https://stackoverflow.com/questions/53617518/casting-to-an-interface-from-a-com-library-fails-on-the-16th-managed-thread-with

    0
    Comment actions Permalink
  • Pink Spear

    Hi Mr.MartyG,today I restarted my computer and commented out the function I wrote myself, leaving only the main function for turning on the camera. Visual Studio still prompts the same bug as yesterday. The program can open a "co sets" window, but it cannot display images and the window interface will also get stuck. May I ask what I should do?

    here is my code:

    int main(int argc, char* argv[])
    try
    {
        rs2::pipeline pipe;
        rs2::config pipe_config;
        pipe_config.enable_stream(RS2_STREAM_COLOR, 1280, 800, RS2_FORMAT_RGB8, 30);
        //pipe_config.enable_stream(RS2_STREAM_DEPTH, 640, 480, RS2_FORMAT_Z16, 30);
        pipe.start(pipe_config);
        int frame_count = 0;
        namedWindow("co-test", WINDOW_AUTOSIZE);
        while (getWindowProperty("co-test", WND_PROP_AUTOSIZE))
        {
            rs2::frameset frameset = pipe.wait_for_frames();
            rs2::video_frame video = frameset.get_color_frame();
            const int color_w = video.as<rs2::video_frame>().get_width();
            const int color_h = video.as<rs2::video_frame>().get_height();
            Mat color_image(Size(color_w, color_h), CV_8UC3, (void*)video.get_data(), Mat::AUTO_STEP);
            cvtColor(color_image, color_image, COLOR_RGB2BGR);
            imshow("co-test", color_image);
            frame_count++;
            cout << frame_count << endl;
        }
        return EXIT_SUCCESS;

    }
    catch (const std::exception &e)
    {
        std::cerr << e.what() << '\n';
    }

    0
    Comment actions Permalink
  • MartyG

    Can you confirm whether you are using C++ or C# language please?

    0
    Comment actions Permalink
  • Pink Spear

    I'm using C++ language

    0
    Comment actions Permalink
  • MartyG

    A C++ guide at the link below for setting up a new RealSense project in Visual Studio using .props property sheet files provided by the RealSense SDK may be useful to confirm whether your project has necessary linkages to the librealsense library set up.

    https://github.com/EduardoWang/visual-studio-real-sense-record-and-playback-project

    0
    Comment actions Permalink

Please sign in to leave a comment.