Gazebo | Ignition | Community
Ask Your Question
0

image in OnNewFrame to opencv

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

PeterHer gravatar image

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

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

2 Answers

Sort by ยป oldest newest most voted
0

answered 2021-07-02 02:02:56 -0600

Did you find the solution to this?

edit flag offensive delete link more
0

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

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

Question Tools

1 follower

Stats

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

Seen: 266 times

Last updated: Jul 02 '21