Gazebo | Ignition | Community
Ask Your Question
0

image in OnNewFrame to opencv

asked 2019-11-01 07:19:03 -0500

PeterHer gravatar image

updated 2019-11-01 07:57:02 -0500

Hi All,

I have the following code:

 void OnNewFrame(const unsigned char *_image,
    unsigned int _width, unsigned int _height, unsigned int _depth,
    const std::string &_format)
{
        // show in opencv
        char *data;
        data = new char[(_height * _width * 3) + 1]; // rgb 8 bit data
        memcpy(data, _image, _height * _width * 3);
        cv::Mat image(_height, _width, CV_8UC3, data);
        cv::imshow("camera", image);
        delete data;
  }

I want to try to copy an image into opencv, but Gazebo show an error on cv::imshow("camera", image); Something with undefined symbol: _ZN2cv6imshowERKNS_6StringERKNS_11_InputArrayE. Any special compiler flags I need to set in my ROS launch file or CMakeList / package file?

Thanks in advance, Peter

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-21 03:58:51 -0500

kumpakri gravatar image
find_package(OpenCV REQUIRED)

.

include_directories(
   ...
  ${OpenCV_INCLUDE_DIRS}
)

.

target_link_libraries(MyPlugin ${GAZEBO_LIBRARIES}  ${OpenCV_LIBRARIES} ... )
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-11-01 07:19:03 -0500

Seen: 68 times

Last updated: Apr 21