Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java OpenCV+;安卓&x2B;车牌识别_Java_Android_Opencv_Vector - Fatal编程技术网

Java OpenCV+;安卓&x2B;车牌识别

Java OpenCV+;安卓&x2B;车牌识别,java,android,opencv,vector,Java,Android,Opencv,Vector,我正在开发一个Android应用程序来检测车牌。我做了图像处理,直到找到了图像的轮廓。现在我需要将C++代码转换为基于OpenCV的Android java。p> 这是原创的 这是在大津阈值之后 这是我的andoid+opencv代码(工作100%) 现在我需要提取车牌号 请帮助我将C++代码转换为java + opencv:./p> std::vector rects; std::vector<std::vector >::iterator itc = contours.b

我正在开发一个Android应用程序来检测车牌。我做了图像处理,直到找到了图像的轮廓。现在我需要将C++代码转换为基于OpenCV的Android java。p> 这是原创的

这是在大津阈值之后

这是我的andoid+opencv代码(工作100%)

现在我需要提取车牌号

请帮助我将C++代码转换为java + opencv:./p>
std::vector rects;  
std::vector<std::vector >::iterator itc = contours.begin();  
while (itc != contours.end())  
{  
    cv::RotatedRect mr = cv::minAreaRect(cv::Mat(*itc)); 
    float area = fabs(cv::contourArea(*itc));  
    float bbArea=mr.size.width * mr.size.height;  
    float ratio = area/bbArea;  
    if( (ratio < 0.45) || (bbArea < 400) ){  
        itc= contours.erase(itc);  
    }else{  
        ++itc;  
        rects.push_back(mr);  
    }  
} 
std::vector rects;
std::vector::iterator itc=contours.begin();
while(itc!=contours.end())
{  
cv::RotatedRect mr=cv::Minarealect(cv::Mat(*itc));
浮动面积=晶圆厂(cv::轮廓面积(*itc));
浮动面积=mr.size.width*mr.size.height;
浮动比率=面积/bb面积;
如果((比率<0.45)| |(bbArea<400)){
itc=等高线。擦除(itc);
}否则{
++国贸中心;
矩形。推回(mr);
}  
} 
查看,尤其是

而不是

std::vector<std::vector<cv::Point> > contours;

那代码不能编译。您需要
std::vector::iterator itc=contours.begin(),这是因为没有从double到float的隐式转换
std::vector<std::vector<cv::Point> > contours;
java.util.ArrayList<MatOfPoint> contours;
import java.util.*;
import org.opencv.imgproc.Imgproc;
import org.opencv.core.*;

/* ... */
ArrayList<RotatedRect> rects = new  ArrayList<RotatedRect>()
ArrayList<MatOfPoint> contours = new ArrayList<MatOfPoint>();
Imgproc.findContours(image, contours, new Mat(), Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

ListIterator<MatOfPoint> itc = contours.listIterator();
while(itc.hasNext())
{
     MatOfPoint2f mp2f = new MatOfPoint2f(itc.next().toArray());
     RotatedRect mr = Imgproc.minAreaRect(mp2f);
     double area = Math.abs(Imgproc.contourArea(mp2f));

     double bbArea= mr.size.area();  
     double ratio = area / bbArea;  
     if( (ratio < 0.45) || (bbArea < 400) )
     {  
         itc.remove();  // other than deliberately making the program slow,
                        // does erasing the contour have any purpose?
     }
     else
     {  
         rects.add(mr);  
     }  

}