选择区域OpenCV

编程入门 行业动态 更新时间:2024-10-28 08:29:19
本文介绍了选择区域OpenCV的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是OpenCV的新手,我想选择视频/图像中的特定区域进行检测.以我为例,我想检测仅在道路上而不在停车场内的汽车.

I am new to OpenCV and I want to select a particular region in the video/image for detection. In my case I want to detect cars that are only in the road not in the parking lot.

推荐答案

好吧,选择汽车需要使用训练数据.但是选择ROI(感兴趣的区域)非常简单:

Well, selecting cars requires use of training data. But to select an ROI (region of interest) is fairly simple:

考虑img = cv2.imread(image)

在这种情况下,您可以在代码中的某处以这种方式指定区域:

In that case, somewhere in your code, you can specify a region this way:

sub_image = img[y:y+h, x:x+w]

一旦您指定了值,则将获得ROI,当然,不使用'x'或'y',其中h是高度,w是宽度.请记住,图像只是2D矩阵.

That will get the ROI once you specify the values, of course, not using 'x' or 'y', where h is the height and w is the width. Remember that images are just 2D matrices.

使用CascadeClassifier()从图像中选择汽车.在> 此处 中找到文档. OpenCV随附了培训数据,您可以使用这些培训数据以XML文件的形式进行分类.

Use CascadeClassifier() to select the car(s) from the image(s). Documentation is found here. OpenCV comes packed with training data you can use to make classifications in the form of XML files.

更多推荐

选择区域OpenCV

本文发布于:2023-05-26 09:46:52,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/252240.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:区域   OpenCV

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!