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;
yarpImage.resize(300,200);
yarpImage.zero();
yarpImage.width()/2,yarpImage.height()/2,
yarpImage.height()/4);
yarpImage.width()/2,yarpImage.height()/2,
yarpImage.height()/5);
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;
}