mardi 31 juillet 2018

Undefined references to librealsense classes and function

I have installed Intel OpenVino toolkit to my Xubuntu 16.04, its samples are designed for use with webcam or similar uvcvideo sources.

I have been trying to update these samples to work with Intel Realsense R200 camera.

I have tried my R200 with ros, and it is working with out any problems. Also I installed librealsense legacy library.

Everything seems fine but I have some troubles with porting.

I have added library:

// librealsense C++ header file
#include <librealsense/rs.hpp>

Then created necessary variables:

using namespace rs;

// Window size and frame rate
int const INPUT_WIDTH   = 320;
int const INPUT_HEIGHT  = 240;
int const FRAMERATE     = 60;

// Named windows
char const *WINDOW_DEPTH = "Depth Image";
char const *WINDOW_RGB   = "RGB Image";


context     _rs_ctx;
//device * _rs_camera = _rs_ctx.get_device(0);
device*     _rs_camera = NULL;

intrinsics  _depth_intrin;
intrinsics  _color_intrin;
bool        _loop = true;

Also I added some functions:

    bool display_next_frame( )
{
    // Get current frames intrinsic data.
    _depth_intrin   = _rs_camera->get_stream_intrinsics( rs::stream::depth );
    _color_intrin   = _rs_camera->get_stream_intrinsics( rs::stream::color );

    // Create depth image
    cv::Mat depth16( _depth_intrin.height,
                     _depth_intrin.width,
                     CV_16U,
                     (uchar *)_rs_camera->get_frame_data( rs::stream::depth ) );

    // Create color image
    cv::Mat rgb( _color_intrin.height,
                 _color_intrin.width,
                 CV_8UC3,
                 (uchar *)_rs_camera->get_frame_data( rs::stream::color ) );

    // < 800
    cv::Mat depth8u = depth16;
    depth8u.convertTo( depth8u, CV_8UC1, 255.0/1000 );

    imshow( WINDOW_DEPTH, depth8u );
    cvWaitKey( 1 );

    cv::cvtColor( rgb, rgb, cv::COLOR_BGR2RGB );
    imshow( WINDOW_RGB, rgb );
    cvWaitKey( 1 );

    return true;
}


// Initialize the application state. Upon success will return the static app_state vars address
bool initialize_streaming( )
{
    bool success = false;
    if( _rs_ctx.get_device_count( ) > 0 )
    {
        _rs_camera = _rs_ctx.get_device( 0 );

        _rs_camera->enable_stream( rs::stream::color, INPUT_WIDTH, INPUT_HEIGHT, rs::format::rgb8, FRAMERATE );

        _rs_camera->start( );

        success = true;
    }
    return success;
}

But while compiling my edited main.cpp with ./build_samples.sh script which is came with toolkit.

I couldn't solve these undefined references issues:

[100%] Linking CXX executable ../intel64/Release/interactive_face_detection_sample CMakeFiles/interactive_face_detection_sample.dir/main.cpp.o: In function display_next_frame()': main.cpp:(.text+0x6af): undefined reference tors_get_stream_intrinsics' main.cpp:(.text+0x72e): undefined reference to rs_get_stream_intrinsics' main.cpp:(.text+0x7ae): undefined reference tors_get_frame_data' main.cpp:(.text+0x8d8): undefined reference to rs_get_frame_data' CMakeFiles/interactive_face_detection_sample.dir/main.cpp.o: In functioninitialize_streaming()': main.cpp:(.text+0xed9): undefined reference to rs_get_device_count' main.cpp:(.text+0xf07): undefined reference tors_get_device' main.cpp:(.text+0xf49): undefined reference to rs_enable_stream_ex' main.cpp:(.text+0xf6e): undefined reference tors_start_source' CMakeFiles/interactive_face_detection_sample.dir/main.cpp.o: In function rs::context::~context()': main.cpp:(.text._ZN2rs7contextD2Ev[_ZN2rs7contextD5Ev]+0x6): undefined reference tors_delete_context' CMakeFiles/interactive_face_detection_sample.dir/main.cpp.o: In function rs::error::error(rs_error*)': main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x2e): undefined reference tors_get_error_message' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x68): undefined reference to rs_get_failed_function' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0x79): undefined reference tors_get_failed_function' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0xad): undefined reference to rs_get_failed_args' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0xbe): undefined reference tors_get_failed_args' main.cpp:(.text._ZN2rs5errorC2EP8rs_error[_ZN2rs5errorC5EP8rs_error]+0xf5): undefined reference to rs_free_error' CMakeFiles/interactive_face_detection_sample.dir/main.cpp.o: In functionrs::log_to_console(rs::log_severity)': main.cpp:(.text._ZN2rs14log_to_consoleENS_12log_severityE[_ZN2rs14log_to_consoleENS_12log_severityE]+0x22): undefined reference to rs_log_to_console' CMakeFiles/interactive_face_detection_sample.dir/main.cpp.o: In functionmain': main.cpp:(.text.startup+0x134): undefined reference to rs_get_frame_data' main.cpp:(.text.startup+0xdeb): undefined reference tors_is_device_streaming' main.cpp:(.text.startup+0xe1b): undefined reference to rs_wait_for_frames' CMakeFiles/interactive_face_detection_sample.dir/main.cpp.o: In function_GLOBAL__sub_I__ZN3fLB7FLAGS_hE': main.cpp:(.text.startup+0x496f): undefined reference to `rs_create_context' collect2: error: ld returned 1 exit status interactive_face_detection_sample/CMakeFiles/interactive_face_detection_sample.dir/build.make:117: recipe for target 'intel64/Release/interactive_face_detection_sample' failed make[2]: * [intel64/Release/interactive_face_detection_sample] Error 1 CMakeFiles/Makefile2:254: recipe for target 'interactive_face_detection_sample/CMakeFiles/interactive_face_detection_sample.dir/all' failed make[1]: * [interactive_face_detection_sample/CMakeFiles/interactive_face_detection_sample.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2

Full of my code is: https://gist.github.com/mustafaxfe/7a3b26da2d28e72c933f15a05f5db85c

Aucun commentaire:

Enregistrer un commentaire