检测不同形状的动态象(圆形,方形和矩形)从相机? [英] Detection of different shape's dynamically like ( Circle, square and Rectangle ) from the camera?

查看:436
本文介绍了检测不同形状的动态象(圆形,方形和矩形)从相机?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建一个应用程序,以检测像(圆形,方形和矩形只有几何形状),其不应该使用的标记少边缘基于的方法来检测在扩增的形状

I want to create an application to detect the shape of the objects like ( circle, square and rectangle only geometry shapes ) that should not be using Marker less or Edge based way to detect the shape in augmentation.

我已经使用下面的东西为这个想通过那些已经在metaio SDK现有有教程的步骤走了

I have used the following things for this like gone through the procedures of the tutorial that are already existing there in the metaio sdk

1)Metaio: http://dev.metaio.com/sdk/tutorials /你好世界/

1) Metaio : http://dev.metaio.com/sdk/tutorials/hello-world/

2)的OpenCV:<一href="http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.html#canny-detector" rel="nofollow">http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.html#canny-detector

2) OpenCV : http://docs.opencv.org/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.html#canny-detector

这些都是事我试图实现。

these are the thing i have tried to implement.

几何形状: 1)圈中实时可以是任何圆形物体 - >

Geometry shapes: 1) Circle in realtime could be any circular object-->

2)广场,在实时可以是任何方形物体 - >

2) Square in realtime could be any square object-->

3)矩形实时可以是任何矩形对象 - >

3) Rectangle in realtime could be any rectangle object-->

我怎样才能实现这个场景中增强的。

How can i achieve this scenario of the augmentation.

在此先感谢

推荐答案

更新::此计算器后(有一些很好的示例图片在内)似乎已经解决了<一href="http://stackoverflow.com/questions/6416117/simple-object-detection-using-opencv-and-machine-learning">circles你的问题的检测 -part最少。的优秀写了他指着参考可以在本作中找到<一href="http://web.archive.org/web/20130504190215/http://cgi.cse.unsw.edu.au/~cs4411/wiki/index.php?title=OpenCV_Guide#Detecting_circles">wiki页面(只能通过Wayback机器不幸)。

Update: This StackOverflow post (with some nice sample pictures included) seems to have solved the circles detection-part of your problem at least. The reference of the excellent write-up he's pointing to can be found on this wiki page (only through the wayback machine unfortunately).

如果说<一href="http://web.archive.org/web/20130504190215/http://cgi.cse.unsw.edu.au/~cs4411/wiki/index.php?title=OpenCV_Guide#Detecting_circles">new链接不成立或者,这里是有关部分:

In case that new link doesn't hold either, here is the relevant section:

检测图片:

有需要照顾到检测圆中的图像数繁琐比特。在你处理与 cvHoughCircles 图像 - 的功能,圆检测,您不妨先转换成灰度图像和流畅的。以下是你需要与他们的用法的示例使用函数的一般程序。

There are a few fiddly bits that need to taken care of to detect circles in an image. Before you process an image with cvHoughCircles - the function for circle detection, you may wish to first convert it into a gray image and smooth it. Following is the general procedure of the functions you need to use with examples of their usage.

创建图像

假如你有处理所谓的IMG初始图像,首先要创建一个名为灰色与使用相同尺寸的img cvCreateImage 图像变量。

Supposing you have an initial image for processing called 'img', first you want to create an image variable called 'gray' with the same dimensions as img using cvCreateImage.

IplImage* gray = cvCreateImage( cvGetSize(img), 8, 1 ); 
                 // allocate a 1 channel byte image

CvMemStorage* storage = cvCreateMemStorage(0);


IplImage* cvCreateImage(CvSize size, int depth, int channels);

  size:  cvSize(width,height);

  depth: pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16U,
    IPL_DEPTH_16S, IPL_DEPTH_32S, IPL_DEPTH_32F, IPL_DEPTH_64F

  channels: Number of channels per pixel. Can be 1, 2, 3 or 4. The channels 
    are interleaved. The usual data layout of a color image is
    b0 g0 r0 b1 g1 r1 ...

转换为灰色

现在你需要将其转换为用灰色 cvCvtColor 该色彩空间之间进行转换。

Now you need to convert it to gray using cvCvtColor which converts between colour spaces.

cvCvtColor( img, gray, CV_BGR2GRAY );

cvCvtColor(src,dst,code); // src -> dst

  code    = CV_<X>2<Y>
  <X>/<Y> = RGB, BGR, GRAY, HSV, YCrCb, XYZ, Lab, Luv, HLS

e.g.: CV_BGR2GRAY, CV_BGR2HSV, CV_BGR2Lab

平滑图像

这是这样做的,以prevent被检测到了大量的虚假圈。您可能需要与最后两个参数周围玩,并指出,他们需要乘以为奇数。

This is done so as to prevent a lot of false circles from being detected. You might need to play around with the last two parameters, noting that they need to multiply to an odd number.

cvSmooth( gray, gray, CV_GAUSSIAN, 9, 9 ); 
// smooth it, otherwise a lot of false circles may be detected

void cvSmooth( const CvArr* src, CvArr* dst,
               int smoothtype=CV_GAUSSIAN,
               int param1, int param2);

的src

  • 在源图像。

DST

  • 目标图像。

smoothtype

平滑类型:

  • CV_BLUR_NO_SCALE(无结垢简单的模糊) - 求和像素的param1×param2的附近。的如果邻域大小是不固定的,人们可以使用cvIntegral功能
  • CV_BLUR(简单模糊) - 求和像素的param1×param2的附近,随后进行缩放,1 /(参数1•参数2)
  • CV_GAUSSIAN(高斯模糊) - 卷积图像参数1×param2的高斯
  • CV_MEDIAN(中位数模糊) - 发现参数1的值×参数1个居委会(即邻里广场)
  • CV_BILATERAL(双边滤波器) - 应用双侧3x3的过滤与颜色差=参数1 空间差=参数2
  • CV_BLUR_NO_SCALE (simple blur with no scaling) - summation over a pixel param1×param2 neighborhood. If the neighborhood size is not fixed, one may use cvIntegral function.
  • CV_BLUR (simple blur) - summation over a pixel param1×param2 neighborhood with subsequent scaling by 1/(param1•param2).
  • CV_GAUSSIAN (gaussian blur) - convolving image with param1×param2 Gaussian.
  • CV_MEDIAN (median blur) - finding median of param1×param1 neighborhood (i.e. the neighborhood is square).
  • CV_BILATERAL (bilateral filter) - applying bilateral 3x3 filtering with color sigma=param1 and space sigma=param2

参数1

  • 平滑操作的第一个参数。

参数2

  • 平滑操作的第二个参数。

在情况下,如果参数2 为零,它设置为参数1

In case of simple scaled/non-scaled and Gaussian blur if param2 is zero, it is set to param1

检测使用哈夫圆

功能 cvHoughCircles 用于检测灰度图像的圆圈。此外,可能需要在最后两个参数来摆弄周围。

The function cvHoughCircles is used to detect circles on the gray image. Again the last two parameters might need to be fiddled around with.

CvSeq* circles = 
 cvHoughCircles( gray, storage, CV_HOUGH_GRADIENT, 2, gray->height/4, 200, 100 );


CvSeq* cvHoughCircles( CvArr* image, void* circle_storage,
                       int method, double dp, double min_dist,
                       double param1=100, double param2=100,
                       int min_radius=0, int max_radius=0 );

=======相关章节结束=========

这是维基页面的其余部分实际上是很不错(不过,我不会把它重新复制在这里,因为剩下的就是题外话原来的问题和计算器有大小限制的答案)。我们希望,该<一href="http://web.archive.org/web/20130504190215/http://cgi.cse.unsw.edu.au/~cs4411/wiki/index.php?title=OpenCV_Guide">link到Wayback机器上的缓存副本将继续工作下去。

The rest of that wiki page is actually very good (although, I'm not going to recopy it here since the rest is off-topic to the original question and StackOverflow has a size limit for answers). Hopefully, that link to the cached copy on the Wayback machine will keep on working indefinitely.

previous回答我的更新之前:

太棒了!现在,您张贴一些例子,我可以看到,你不仅长方形,正方形长方形和圆形后,你也想找到一个3D环境的形状,从而潜在地狩猎的的平行四边形特殊情况下椭圆的,从视频帧的视频帧可以最终揭示自己是长方形,正方形和/或圆(取决于你如何平移相机)。

Great! Now that you posted some examples, I can see that you're not only after rectangles, square rectangles, and circles, you also want to find those shapes in a 3D environment, thus potentially hunting for special cases of parallelograms and ovals that from video frame to video frame can eventually reveal themselves to be rectangles, squares, and/or circles (depending on how you pan the camera).

就个人而言,我觉得它更容易通过问题的工作比我试图了解如何利用现有的(很多时候是很成熟)库。这是不是说我自己的工作会比一个成熟的库更好,这肯定不会。这只是一次我可以通过一个问题,自己的工作,那么它变得更容易为我理解和使用库(库本身,这往往会运行得更快,比我自己的解决方案更聪明)。

Personally, I find it easier to work through a problem myself than trying to understand how to use an existing (often times very mature) library. This is not to say that my own work will be better than a mature library, it certainly won't be. It's just that once I can work myself through a problem, then it becomes easier for me to understand and use a library (the library itself which will often run much faster and smarter than my own solution).

所以,下一步我会采取的是改变位图的颜色空间为灰度。彩色位图,我听不太懂,我有麻烦操作,特别是因为有这么多不同的方式可以重新presented,而是一个灰度位图,这是双方更容易理解和操作。对于灰度位图,试想值的网格,每个价值重新presenting 不同的光线强度。

So the next step I would take is to change the color space of the bitmap into grayscale. A color bitmap, I have trouble understanding and I have trouble manipulating, especially since there are so many different ways it can be represented, but a grayscale bitmap, that's both much easier to understand and manipulate. For a grayscale bitmap, just imagine a grid of values, with each value representing a different light intensity.

和现在,让我们来限制这一问题的范围,找到平行四边形和椭圆内的静态2D环境中(我们担心处理3D环境和以后移动视频帧,或者我应该说,你会担心分开自己,因为这个问题已经变得过于复杂,对我来说)。

And for now, let's limit the scope of the problem to finding parallelograms and ovals inside a static 2D environment (we'll worry about processing 3D environments and moving video frames later, or should I say, you'll worry about that part yourself since that problem is already becoming too complicated for me).

和现在也是,让我们不要担心什么工具或使用的语言。只需使用什么是最简单,最expeditive。例如,几乎什么都可以编写脚本来自动将图像转换为灰度假设时间是没有问题的。 ImageMagick的,瘸子,马文,的处理,Python和Ruby,Java等

And for now also, let's not worry about what tool or language you use. Just use whatever is easiest and most expeditive. For instance, just about anything can be scripted to automatically convert an image to grayscale assuming time is no issue. ImageMagick, Gimp, Marvin, Processing, Python, Ruby, Java, etc.

和与任何这些工具,它应该容易像素组具有相似足够强度(使计算更容易管理),并进行排序在不同的阵列为每个光强度桶每个像素坐标。换句话说,它不应该太难安排某种数组排序强度包含每个像素的x和y位置粗直方图。

And with any of those tools, it should be easy to group pixels with similar enough intensities (to make the calculations more manageable) and to sort each pixel coordinates in a different array for each light intensity bucket. In other words, it shouldn't be too difficult to arrange some sort of crude histogram of arrays sorted by intensity that contain each pixel's x and y positions.

在此之后,问题变得更像这个(可上计算器可以找到),因此可以用其建议解决方案工作时。

After that, the problem becomes a problem more like this one (which can be found on StackOverflow) and thus can be worked upon with its suggested solution.

和一旦你能够通过这个问题来工作的方式,然后将你拿出一个更好的语言适合的任务应该不会太困难的解决方案。它要容易得多也理解和使用你最终选择的任务以及任何现有的库的基本功能。至少,这就是我希望的,因为我没有足够的熟悉,我真的不能帮你OpenCV的库本身。

And once you're able to work through the problem in that way, then converting the solution you come up with to a better language suited for the task shouldn't be too difficult. And it should be much easier also to understand and use the underlying function of any existing library you end choosing for the task as well. At least, that's what I'm hoping for, since I'm not familiar enough and I can't really help you with the OpenCV libraries themselves.

这篇关于检测不同形状的动态象(圆形,方形和矩形)从相机?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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