image in OnNewFrame to opencv
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: ZN2cv6imshowERKNS6StringERKNS11InputArrayE. Any special compiler flags I need to set in my ROS launch file or CMakeList / package file?
Thanks in advance, Peter
Asked by PeterHer on 2019-11-01 07:19:03 UTC
Answers
find_package(OpenCV REQUIRED)
.
include_directories(
...
${OpenCV_INCLUDE_DIRS}
)
.
target_link_libraries(MyPlugin ${GAZEBO_LIBRARIES} ${OpenCV_LIBRARIES} ... )
Asked by kumpakri on 2020-04-21 03:58:51 UTC
Comments