从四点绘制填充形状 [英] Draw Filled Shape from Four Points
问题描述
我有四点(在图像处理后从扑克牌中取出)我想用绿色面具覆盖那张卡片的表面。所以我正在寻找一种方法来绘制一个基本上在这四个点之间有直线的形状,然后用绿色填充形状的中间。我试图使用OpenCV来完成任务,但是矩形方法只需要两个点(所以除非卡完全对齐,否则掩模会覆盖周围区域或卡不够),fillPoly方法没有效果(尽管我可以如果需要,发布代码)。有关方法的任何建议吗?
@Miki回答的补充:
你也可以使用
I've got four points (taken from a playing card after image processing) and I want to cover the surface of that card with a green mask. So I'm searching for a way to draw a shape that essentially has straight lines between those four points and then fills the middle of the shape with green. I was trying to use OpenCV for the task, but the rectangle method takes only two points (so unless the card is perfectly aligned the mask covers surrounding area or not enough of the card), and the fillPoly method had no effect (although I can post the code if need be). Any suggestions for a method to do this job?
an addition to @Miki 's answer:
you can also use fillConvexPoly to get same result
Mat img = Mat::zeros( 200, 200, CV_8UC3 );
Point pts[4] = {Point(10,20),Point(60,20),Point(180,130),Point(60,150)};
fillConvexPoly( img, pts, 4, Scalar(0,255,0) );
这篇关于从四点绘制填充形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!