OpenCV 特定物体检测
在做了一些研究并阅读了有关 OpenCV 对象检测的信息后,我仍然不确定如何检测视频帧中的棍子。即使用户移动它,我也可以检测到,最好的方法是什么。我将用这根棍子作为剑,并用它制作一把光剑。我可以从哪里开始?谢谢!
After doing some research and reading information about OpenCV object detection, I am still not sure on how can I detect a stick in a video frame. What would be the best way so i can detect even if the user moves it around. I'll be using the stick as a sword and make a lightsaber out of it. Any points on where I can start? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
对此的首选答案通常是霍夫线变换。霍夫变换旨在查找场景中的直线(或其他轮廓),OpenCV 可以对这些线进行参数化,以便您获得端点坐标。但是,明智的做法是,如果您正在制作光剑效果,则无需走那么远 - 只需将棍子涂成橙色并进行色度键即可。 Adobe Premiere、Final Cut Pro、Sony Vegas 等的标准功能。其 OpenCV 版本是将您的帧转换为 HSV 颜色模式,并隔离位于所需色调和饱和度区域的图片区域。
http://opencv.itseez.com/doc/tutorials/imgproc/ imgtrans/hough_lines/hough_lines.html?highlight=hough
这是我写的一个旧例程作为示例:
有点冗长,但你明白了!
The go-to answer for this would usually be the Hough line transform. The Hough transform is designed to find straight lines (or other contours) in the scene, and OpenCV can parameterize these lines so you get the endpoints coordinates. But, word to the wise, if you are doing lightsaber effects, you don't need to go that far - just paint the stick orange and do a chroma key. Standard feature of Adobe Premiere, Final Cut Pro, Sony Vegas, etc. The OpenCV version of this is to convert your frame to HSV color mode, and isolate regions of the picture that lie in your desired hue and saturation region.
http://opencv.itseez.com/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html?highlight=hough
Here is an old routine I wrote as an example:
A little verbose, but you get the idea!
我的老教授总是说,计算机视觉的第一定律是对图像尽一切努力,让你的工作变得更轻松。
如果您可以控制棍子的外观,那么您可能会很幸运地为棍子涂上非常特定的颜色(霓虹粉红色或不太可能出现在背景中的颜色),然后使用颜色分割与连接组件标记。那会非常快。
My old professor always said that the first law of computer vision is to do whatever you can to the image to make your job easier.
If you have control over the stick's appearance, then you might have the best luck painting the stick a very specific color --- neon pink or something that isn't likely to appear in the background --- and then using color segmentation combined with connected component labeling. That would be very fast.
您可以首先遵循为 OpenCV 编写的人脸识别(训练和检测)技术。
如果您正在寻找具体步骤,请告诉我。
You can start by following the face-recognition (training & detection) techniques written for OpenCV.
If you are looking for specific steps, let me know.