#HSLIDE
#HSLIDE
- find Wally :-)
- integrating YARP with OpenCV
- yarp::os::RFModule
- Thrift services
- performing simple image processing operations
#VSLIDE
- Change CMakeLists.txt to find OpenCV correctly
- Load image containing the full scene.
- Display it: stream it through a yarp port to a yarpviewer.
- Load wally's template and run the template matching algorithm with correct method to figure out where wally is in the scene
- Modify the streamed image to display the location of wally.
#HSLIDE
#VSLIDE
######
CMakeLists additions
find_package(YARP 3.1.101 REQUIRED)
find_package(ICUBcontrib REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${YARP_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} ${YARP_LIBRARIES}
${OpenCV_LIBS})
######
Code headers additions
#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>#HSLIDE
#VSLIDE
######
IDL Services
/**
* Load the two required images.
* @param mainImage name of the image to be loaded.
* @return true/false on success/failure.
*/
bool load(1:string image);######
Code
yarp::os::ResourceFinder rf;
rf.setVerbose();
rf.setDefaultContext(this->rf->getContext().c_str());
std::string imageStr = rf.findFile(image.c_str());
cv::Mat inputImage;
inputImage = cv::imread(imageStr, CV_LOAD_IMAGE_COLOR);#HSLIDE
#VSLIDE
yarp::os::BufferedPort<yarp::sig::ImageOf<yarp::sig::PixelRgb>> imageOutPort;
imageOutPort.open(("/"+getName("/image:o")).c_str());imageOutPort.close();yarp::sig::ImageOf<yarp::sig::PixelRgb> &outImg = imageOutPort.prepare();
outImg = yarp::cv::fromCvMat<yarp::sig::PixelRgb>(out_image);
imageOutPort.write();#HSLIDE
#VSLIDE
######
IDL Services
/**
* use template matching on image with desired template and
* desired method
* @param template name of the image to be loaded.
* @param name of method: 0=SQDIFF, 1=SQDIFF NORMED,
* 2=TM CCORR, 3=TM CCORR NORMED, 4=TM COEFF, 5=TM COEFF NORMED
* @return Bottle containing the 2D position.
*/
Bottle templateMatch(1:string image, 2:i32 method);######
template methods
//Use the OpenCV function matchTemplate to search for matches between an
//image patch and an input image
void matchTemplate(InputArray image, InputArray templ, OutputArray result, int method);
//Use the OpenCV function minMaxLoc to find the maximum and minimum values
//(as well as their positions) in a given array.
void minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, cv::Mat() );#HSLIDE The End :)