Android OpenCV -转换OpenCV c++代码到Android,以检测QR码对齐方块
Android OpenCV - Converting OpenCV C++ Code to Android in order to detect QR Code Alignment Squares
我正在构建一个Android应用程序,我的目标是使用OpenCV扫描Android表单。我计划使用与QR码相同的概念,对齐方块,以确保我每次都能正确扫描。
我知道我可以使用ZXing库,但是,我没有使用QR码。在我对它进行图像处理之前,我只是借用了对齐方形的想法。
我发现了这个博客,其中他使用OpenCV c++库找到对齐方块,然后他重新对齐图像并输出重新对齐的QR码。他的c++代码可以在他的github找到。除了我在大学里学过的课程之外,我对c++没有太多的背景知识,我也没有在c++中使用OpenCV的经验。我理解大多数代码都试图这样做,然而,当我在主函数之外转换他的函数时,我有一个问题:
void cv_getVertices(ArrayList<ArrayList<Point>> contours, int c_id, float slope, ArrayList<Point> quad){
Rect box = Imgproc.boundingRect(contours.get(c_id)); //<-- problematic code
//more code here
}
原代码为:
void cv_getVertices(vector<vector<Point> > contours, int c_id, float slope, vector<Point2f>& quad){
Rect box;
box = boundingRect( contours[c_id]);
//more code here
}
然而,我得到一个错误,因为Imgproc.boundingRect(contours.get(c_id));
正在寻找一个MatOfPoint
对象,我的contours
数组列表是由点组成的。
注意:我不得不改变很多他的代码,如改变vectors
到ArrayLists
,以及重写当他做Points
的操作。
boundingRect()
的c++变体期望InputArray<T>
具有接受const vector<T> &
的构造函数,因此它隐式地将给定的vector<T>
转换为boundingRect()
到InputArray<T>
。这在JAVA中不起作用。你必须明确地将数组列表转换为MatOfPoint
可以通过MatOfPoint.fromList(java.util.List<Point> lp)
相关文章:
- Android opencv 3.4.1 Build 命令失败.未定义的引用
- Android OpenCV Linked CXX 共享库失败
- Android OpenCV 应用程序的内存问题
- 自动驾驶汽车 Android "opencv.dir"未在本地媒体资源中设置 - Android Studio
- Android -OpenCV模板与阈值匹配
- Android OpenCV未定义的本地类别
- 在Android OpenCV中使用FindFundaMentalMat时会出现错误,并且无法解决
- 将C OpenCV Iplimage Imagedata和widthstep转换为Android OpenCV垫子
- Android OpenCV - 每次旋转是否有可能捕捉到不同的3D对象点击?
- Android OpenCV Create Rect
- 如何:Android OpenCV视频捕获与文件
- Android OpenCV并行循环
- Android OpenCV - 在矩阵上应用数学运算符
- Android+OpenCV:如何向项目添加.cpp文件
- 获取旧版本的android opencv (2.4.7)
- Android OpenCV port C++ to Java
- 需要用android opencv在柜台区域绘制一个矩形
- Android OpenCV Fatal Signal 11,(糟糕的编码实践?)
- Android OpenCV imread 标志致命异常,imread 在没有标志的情况下工作正常,像素输出与 MATLAB 不匹配
- Android OpenCV颜色分割显示在ImageView上