[英]JavaCV Warning sign detection?
I've looked at JavaCV wrapper for OpenCV library and I saw that it is possible to use that library in Java for face detection on an image, but I was wondering is it possible to use that library for detecting traffic warning signs on an image and how? 我看过OpenCV库的JavaCV包装器,我看到可以在Java中使用该库对图像进行面部检测,但我想知道是否可以使用该库来检测图像上的交通警告标志 ,怎么样?
I have pictures taken from the road that look like this: http://www.4shared.com/photo/5QxoVDwd/041.html and the result of detection should look sometning like this or similar: http://www.4shared.com/photo/z_pL0lSK/overlay-0.html 我有看起来像这样的道路拍摄的照片: http://www.4shared.com/photo/5QxoVDwd/041.html和检测应该sometning这样的或类似的结果: HTTP://www.4shared。 COM /照片/ z_pL0lSK /叠加0.html
EDIT: After I detect red color I get this image: 编辑:我检测到红色后,我得到这个图像:
And I have a problem detecting just the warning sign triangle shape and ignore all other shapes. 我只是检测警告标志三角形形状而忽略所有其他形状。 I tried changing the cvApproxPoly parameters but with no result. 我尝试更改cvApproxPoly参数,但没有结果。 This is my code: 这是我的代码:
public void myFindContour(IplImage image)
{
IplImage grayImage = cvCreateImage(cvGetSize(image), IPL_DEPTH_8U, 1);
cvCvtColor(image, grayImage, CV_BGR2GRAY);
CvMemStorage mem;
CvSeq contours = new CvSeq();
CvSeq ptr = new CvSeq();
cvThreshold(grayImage, grayImage, 150, 255, CV_THRESH_BINARY);
mem = cvCreateMemStorage(0);
cvFindContours(grayImage, mem, contours, Loader.sizeof(CvContour.class) , CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE, cvPoint(0,0));
Random rand = new Random();
while (contours != null && !contours.isNull()) {
if (contours.elem_size() > 0) {
CvSeq points = cvApproxPoly(contours, Loader.sizeof(CvContour.class),
mem, CV_POLY_APPROX_DP, cvContourPerimeter(contours)*0.02, 0);
Color randomColor = new Color(rand.nextFloat(), rand.nextFloat(), rand.nextFloat());
CvScalar color = CV_RGB( randomColor.getRed(), randomColor.getGreen(), randomColor.getBlue());
cvDrawContours(image, points, color, CV_RGB(0,0,0), -1, CV_FILLED, 8, cvPoint(0,0));
}
contours = contours.h_next();
}
cvSaveImage("myfindcontour.png", image);
}
This is the output that i get (I used different colors for every shape, but in the final output i will use only white for detected warning sign and everything other left black): 这是我得到的输出(我为每个形状使用不同的颜色,但在最终输出中,我将仅使用白色检测警告标志,其他所有其他颜色为黑色):
You have to do the following: 您必须执行以下操作:
approxPoly
function. 你可以使用approxPoly
函数来做到这approxPoly
。 see ,the first find the contour area. 看,首先找到轮廓区域。 compare it with the precalculated value and keep it with in a range like 将它与预先计算的值进行比较,并将其保持在类似的范围内
if(area>Mincontourarea && area<maxcontourare)
{
thats it now we have the signboard do
}
the value if calculated wouldnot be bigger than the car conotur, to get the contoutr up to my knowledge u need Moments operator 如果计算的值不会大于汽车的轮廓,为了获得我的知识,你需要Moments算子
code for the momnts operator: 妈妈运营商的代码:
Moments moment = moments((cv::Mat)contours[index]);
area = moment.m00; //m00 gives the area of the detected contour
put the above code before the if block discussed above 将上面的代码放在上面讨论的if块之前
if you want the x and y coordinates put a post again.. 如果你想让x和y坐标再次贴一个帖子..
take a look of my answer, it is in c++ but using opencv it is able to detect road signs, you can take it as a good example. 看看我的答案,它是在c ++中,但使用opencv它能够检测道路标志,你可以把它作为一个很好的例子。 https://stackoverflow.com/a/52651521/8035924 https://stackoverflow.com/a/52651521/8035924
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.