An example of using OpenCV with YARP.
An example of using OpenCV with YARP.
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(
int argc,
char *argv[]) {
std::cout<<"Show a circle for 3 seconds..."<<std::endl;
std::cout<<"Creating a YARP image of a nice circle"<<std::endl;
std::cout<<"Saving YARP image to test-1.ppm"<<std::endl;
std::cout<<"Showing OpenCV image"<<std::endl;
cv::namedWindow("test",1);
cv::imshow("test",cvImage1);
std::cout<<"Taking image back into YARP..."<<std::endl;
cv::Mat cvImage2=cvImage1.clone();
auto yarpReturnImage=yarp::cv::fromCvMat<yarp::sig::PixelRgb>(cvImage2);
std::cout<<"Saving YARP image to test-2.ppm"<<std::endl;
cv::waitKey(3000);
cv::destroyWindow("test");
std::cout<<"...done"<<std::endl;
return 0;
}
size_t width() const
Gets width of image in pixels.
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
void zero()
Set all pixels to 0.
size_t height() const
Gets height of image in pixels.
int main(int argc, char *argv[])
::cv::Mat toCvMat(yarp::sig::Image &yarpImage)
Convert a yarp::sig::FlexImage to a cv::Mat object.
void addCircle(ImageOf< T > &dest, const T &pix, int i, int j, int r)
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)