gpt4 book ai didi

opencv - 如何在opencv中识别标注轮廓

转载 作者:行者123 更新时间:2023-12-02 16:42:39 24 4
gpt4 key购买 nike

我的附加代码仅标识未标记的轮廓,仅对1和0标记的蒙版执行。我输入的蒙版图像实际上是用每个轮廓的1,2,3,4 ....标记的。例如,第一个轮廓标记为1,第二个轮廓标记为2,对于所有轮廓而言,仅1个。如何修改我的代码,以便我可以基于标记的图像分别分离每个轮廓。例如,contour1是一个单独的图像,contour2是另一个单独的图像。

cvFindContours(maskImg,storage,&contours,sizeof(CvContour),CV_RETR_CCOMP,CV_CHAIN_APPROX_NONE,cvPoint(0,0));

CvSeq *r;
int objectIndex = 0;
int fov = atoi(seriesName) + 1;
for(r = contours; r != NULL; r = r->h_next){
/* Save each object in separate mask file. */

/* Clear the mask object image buffer. */
cvSet(objectMaskImg, cvScalarAll(0), NULL);
/* Set the color of the external area and hole area of object. */
CvScalar externalColor = cvScalarAll(0xff);
CvScalar holeColor = cvScalarAll(0x00);
/* Recognize child contour. */
int maxLevel = -1;
/* Fill interiors */
int thinkness = CV_FILLED;
int lineType = 8; /* 8-connected */
cvDrawContours(objectMaskImg, r, externalColor, holeColor, maxLevel, thinkness, lineType, cvPoint(0,0));

最佳答案

您可以在蒙版和FindContours返回的轮廓之间使用逻辑AND吗?也许我不太了解您在做什么。

关于opencv - 如何在opencv中识别标注轮廓,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11513036/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com