我在使用opencv 2.4 for Android检测速度交通标志时遇到问题.我做以下事情:
"捕获帧 - >将其转换为HSV - >提取红色区域 - >检测带椭圆检测的符号"
到目前为止,只要图像质量好,椭圆检测就能完美.但正如你在图片中看到的那样,红色提取不能正常工作,因为相框质量差,我认为.
将原始图像转换为HSV:
Imgproc.cvtColor(this.source, this.source, Imgproc.COLOR_RGB2HSV, 3);
Run Code Online (Sandbox Code Playgroud)
提取红色:
Core.inRange(this.source, new Scalar(this.h,this.s,this.v), new Scalar(230,180,180), this.source);
Run Code Online (Sandbox Code Playgroud)
所以我的问题是有另一种方法来检测这样的交通标志或从中提取出红色区域,顺便说一句,这可能会像上一张图片一样微弱吗?
这是原始图片:
这被转换为HSV,因为您可以看到红色区域看起来与附近的树木颜色相同.多数民众赞成我怎么想知道它是红色但我不能.
转换为HSV:
这是用红色提取的.如果颜色是正确的,我应该在符号周围得到几乎完美的圆/椭圆,但由于错误的颜色,它是不完整的.
提取后的结果:
椭圆法:
private void findEllipses(Mat input){
Mat thresholdOutput = new Mat();
int thresh = 150;
List<MatOfPoint> contours = new ArrayList<MatOfPoint>();
MatOfInt4 hierarchy = new MatOfInt4();
Imgproc.threshold(source, thresholdOutput, thresh, 255, Imgproc.THRESH_BINARY);
//Imgproc.Canny(source, thresholdOutput, 50, 180);
Imgproc.findContours(source, contours, hierarchy, Imgproc.RETR_LIST, Imgproc.CHAIN_APPROX_SIMPLE);
RotatedRect minEllipse[] = new RotatedRect[contours.size()];
for(int i=0; i<contours.size();i++){
MatOfPoint2f temp=new MatOfPoint2f(contours.get(i).toArray());
if(temp.size().height …Run Code Online (Sandbox Code Playgroud)