I teach OpenCV, and I want to write a small test app. And have a question. What algorithm would you advise to fill the contour (close to a rectangle) with image?
Thanks a lot!Answer1:
Assuming you know the location of the rectangle you would like to fill, you could simply set a ROI (region of interest) and perform some processing on that region (maybe a grayscale conversion), or even copy another image to that location. I've already demonstrated <a href="https://stackoverflow.com/questions/10881397/setting-roi-with-mouse-from-a-rectangle-on-a-video/10883266#10883266" rel="nofollow">how to set a ROI and perform some processing on that area</a>.
If you want to add 2 images I suggest you check <a href="http://opencv.itseez.com/doc/tutorials/core/adding_images/adding_images.html" rel="nofollow">the official tutorial</a>, <a href="http://www.developerstation.org/2011/02/adding-two-images-in-opencv.html" rel="nofollow">this post</a>, and <a href="http://dasl.mem.drexel.edu/~noahKuntz/openCVTut2.html" rel="nofollow">this demo</a>: the magic happens through
A combination of <a href="http://opencv.willowgarage.com/documentation/cpp/geometric_image_transformations.html#cv-warpperspective" rel="nofollow">warp</a> to deform the src image to match the shape of the contour and <a href="http://opencv.willowgarage.com/documentation/cpp/core_operations_on_arrays.html?highlight=addweighted" rel="nofollow">addWeighted</a> to replace destination image pixels with the source in the new shape