夜间车辆检测感兴趣区域 [英] Region of Interest in nighttime vehicle detection

查看:348
本文介绍了夜间车辆检测感兴趣区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个在夜间检测车辆头灯的项目。我正在开发一个关于MATLAB的演示。我的问题是,我需要找到感兴趣的区域(ROI),以获得低计算要求。我在许多论文中研究过,他们只是使用一个固定的投资回报率像这样,上部被忽略,底部被用于后来分析。

I am developing a project of detecting vehicles' headlights in night scene. I am working on a demo on MATLAB. My problem is that I need to find region of interest (ROI) to get low computing requirement. I have researched in many papers and they just use a fixed ROI like this one, the upper part is ignored and the bottom is used to analysed later.

但是,如果相机不稳定,我认为这种做法是不恰当的。我想找到一个更灵活的,在每一帧交替。我的实验图片如下所示:

However, if the camera is not stable, I think this approach is inappropriate. I want to find a more flexible one, which alternates in each frame. My experiments images are shown here:


如果任何人有任何想法,请给我一些建议。

If anyone has any idea, plz give me some suggestions.

推荐答案

我会改变问题,对于头灯
上方某条线而不是说头灯低于某一线即地平线

I would turn the problem around and say that we are looking for headlights ABOVE a certain line rather than saying that the headlights are below a certain line i.e. the horizon,

您的图像在停机坪上有非常高的反射我们可以利用它来获得我们的优势。我们知道,图像中的最大光量在反射和前大灯附近。因此,我们寻找具有最大光线的行,并使用它作为我们的地板。然后在这个楼层之上寻找头灯。

Your images have a very high reflection onto the tarmac and we can use that to our advantage. We know that the maximum amount of light in the image is somewhere around the reflection and headlights. We therefore look for the row with the maximum light and use that as our floor. Then look for headlights above this floor.

这里的想法是,我们在逐行的基础上查看强度的配置文件,最大值。

The idea here is that we look at the profile of the intensities on a row-by-row basis and finding the row with the maximum value.

这将只适用于暗的图像(例如夜晚),以及大灯在停机坪上的反射很大。

This will only work with dark images (i.e. night) and where the reflection of the headlights onto the tarmac is large.

它不适用于在日光下拍摄的图像。

It will NOT work with images taking in daylight.

我用Python和OpenCV写了这个文件,但我相信你可以把它翻译成一种语言您选择。

I have written this in Python and OpenCV but I'm sure you can translate it to a language of your choice.

import matplotlib.pylab as pl
import cv2

# Load the image
im = cv2.imread('headlights_at_night2.jpg')

# Convert to grey.
grey_image = cv2.cvtColor(im, cv2.COLOR_BGR2GRAY)

大幅平滑影像以隐藏任何局部峰或谷
我们正试图平滑车灯和反射,以便有一个很好的峰值。理想情况下,前大灯和反射将合并为一个区域。

Smooth the image heavily to mask out any local peaks or valleys We are trying to smooth the headlights and the reflection so that there will be a nice peak. Ideally, the headlights and the reflection would merge into one area

grey_image = cv2.blur(grey_image, (15,15))

逐行合计强度

intensity_profile = []
for r in range(0, grey_image.shape[0]):
    intensity_profile.append(pl.sum(grey_image[r,:]))

平滑配置文件并将其转换为numpy数组以方便处理数据

Smooth the profile and convert it to a numpy array for easy handling of the data

window = 10
weights = pl.repeat(1.0, window)/window
profile = pl.convolve(pl.asarray(intensity_profile), weights, 'same')

查找配置文件的最大值。这表示前灯的y坐标和反射区域。左边的热图显示了分布。右图显示每行的总强度值。

Find the maximum value of the profile. That represents the y coordinate of the headlights and the reflection area. The heat map on the left show you the distribution. The right graph shows you the total intensity value per row.

我们可以清楚地看到,强度的总和有一个峰。y坐标是371,热图中的红点和图中的红色虚线。

We can clearly see that the sum of the intensities has a peak.The y-coordinate is 371 and indicated by a red dot in the heat map and a red dashed line in the graph.

max_value = profile.max()
max_value_location = pl.where(profile==max_value)[0]
horizon =  max_value_location

最右边的蓝色曲线表示变量 profile

The blue curve in the right-most figure represents the variable profile

我们找到最大值的行是我们的楼层。然后我们知道车头在这条线之上。我们也知道,大部分的图像的上部将是天空的,因此是黑暗的。

The row where we find the maximum value is our floor. We then know that the headlights are above that line. We also know that most of the upper part of the image will be that of the sky and therefore dark.

我显示以下结果。
我知道两个图像中的线几乎处于相同的坐标,但我认为这只是一个巧合。

I display the result below. I know that the line in both images are on almost the same coordinates but I think that is just a coincidence.


这篇关于夜间车辆检测感兴趣区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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