阅读与复选框的OpenCV [英] Reading checkboxes with openCV

查看:333
本文介绍了阅读与复选框的OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的Andr​​oid应用程序OpenCV库。从相机拍摄的图像,我想读一个复选框(我已经有复选框的位置),并查看是否复选框被填满。即我想知道如果复选框内的区域已被填充在部分或完全黑暗的像素。

我使用JNI接口,所以我现在用的是C ++语言。我想知道我怎么可以找到对应的复选框,这样我就知道,大部分的复选框充满黑暗(黑)像素的像素值。


解决方案

如果您知道完整的形式是什么样子,让我们假设你有地方存放它的一个形象。然后,我们可以使用特征点来检测形式的另一实例作为摄像机图像内的平面物体,如图中的 find_obj.cpp样品。该locatePlanarObject()函数实际上给了我们一个单应矩阵,我们可以cvWarpPerspective()直接使用翘曲回拍摄的图像,使其与存储的图像。假设你知道哪里有复选框存储的图像中,我们可以简单和直接比较的像素值。一些对黑暗的像素数量门槛应该IMO工作。

呵呵,我想你想知道更多关于如何访问像素值。这已经覆盖在很多地方,例如:在OpenCV中2.2 <像素访问/ p>

I am using the opencv library on an android app. From an image taken from the camera, I want to read a check box (I already have the location of the checkbox), and see if the check box has been filled. i.e. i want to know if the area within the check box has been filled in partially or completely with dark pixels.

I am using the jni interface so i am using the c++ language. I want to know how i can find the values of those pixels in the check box such that i will know that most the check box is filled with dark (black) pixels.

解决方案

If you know what the complete form looks like, lets assume you have an image of it stored somewhere. We can then use feature points to detect another instance of that form as a planar object inside the camera image, as shown in the find_obj.cpp sample. The locatePlanarObject() function actually gives us a homography matrix, which we can use directly with cvWarpPerspective() to warp back the captured image to match with your stored image. Assuming you know where the check boxes are in the stored image, we can simply and directly compare the pixels values. Some sort of threshold on the amount of "dark" pixels should work IMO.

Oh, I think you want to know more about how to access pixel values. This has been covered in many places, e.g.: Pixel access in OpenCV 2.2

这篇关于阅读与复选框的OpenCV的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆