导航:首页 > 车辆百科 > opencv车辆跟踪

opencv车辆跟踪

发布时间:2021-08-08 21:16:42

1、用opencv实现车辆计数的问题

cvFindcounters()返回参数能计数的,你把返回值加到计数器里就行啦

2、谁能告诉我怎么用opencv 实现对视频中的车辆进行跟踪和计数啊,谢啦

o

3、opencv车辆检测都用什么方法

常规的车辆检测使用机器学习或者深度学习方法。通过为相关的分类器或者神经网进行大量的车辆图片进行训练最终训练出可以识别车辆的模型。使用模型对图像中的车辆进行检测。

4、现在想用OPENCV作运动目标的识别和跟踪,用什么方法最好,最快入门?

你的意思是:机器人在摄像头监视的范围内运动,用这个摄像头来捕捉该机器人的运动,是吗?
(1)背景中只有机器人这一个物体运动吗?
(2)背景的光线会不会有较大的变化?(例如:晴天,阴天......)
=========================================================
我说两个比较简单的方法吧:
(1)如果背景的光线变化较小且其中只有机器人这一个运动的物体:
a. 单独拍摄一张同角度的背景图片(上无机器人),记为 background.jpg
b. 用这张背景图片 background.jpg 与 摄像机捕捉画面的每一帧图片 “做差”
c. 用一个threshold 滤去“差值”图片上微弱的“噪音”
d. 在对这个“降噪”后的差值图片用 cvFindContours()找到轮廓
e. 用while迭代出每一个轮廓
f. 对每次迭代出的轮廓用 cvBoundingRect() 来获得每个轮廓的外接矩形,记为rect
g. 求出每个矩形的面积,用面积筛选出 “哪个是机器人”
h. 那么这个机器人的位置信息为: rect.x rect.y rect.width rect.height
--------------------------------------------------
(2)如果背景中有多个运动物体,那么:
你给机器人上画一个 “鲜艳一些的矩形” ,然后用OpenCV来找到画面中的所有矩形,然后用过颜色判断来从这些矩形中筛选出“哪个是你的机器人”即可。OpenCV识别矩形的代码,网上有的是,用Google搜一下吧............
=========================================================
Learning OpenCV那本书,中文翻译的太烂,很容易把人弄糊涂,看英文的吧,讲的挺清楚的,另外看那本书,最好不要泛泛的读,那样会很打击人的,因为它讲了很多原理性的东东,如果你不研究算法,只是想实现应用的话,有些对原理的解释可以略读一下。
=========================================================
我留个邮箱,常联系: lzninchina (at) sina 点卡姆

5、opencv如何识别有车进入视野

OpenCV

整个项目的结构图:

编写DetectFaceDemo.java,代码如下:

[java] view
plaincopyprint?

package com.njupt.zhb.test;

import org.opencv.core.Core;

import org.opencv.core.Mat;

import org.opencv.core.MatOfRect;

import org.opencv.core.Point;

import org.opencv.core.Rect;

import org.opencv.core.Scalar;

import org.opencv.highgui.Highgui;

import org.opencv.objdetect.CascadeClassifier;

//

// Detects faces in an image, draws boxes around them, and writes the results

// to "faceDetection.png".

//

public class DetectFaceDemo {

public void run() {

System.out.println("\nRunning DetectFaceDemo");

System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());

// Create a face detector from the cascade file in the resources

// directory.

//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());

//Mat image = Highgui.imread(getClass().getResource("lena.png").getPath());

//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误

/*

* Detected 0 faces Writing faceDetection.png libpng warning: Image

* width is zero in IHDR libpng warning: Image height is zero in IHDR

* libpng error: Invalid IHDR data

*/

//因此,我们将第一个字符去掉

String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);

CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);

Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));

// Detect faces in the image.

// MatOfRect is a special container class for Rect.

MatOfRect faceDetections = new MatOfRect();

faceDetector.detectMultiScale(image, faceDetections);

System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));

// Draw a bounding box around each face.

for (Rect rect : faceDetections.toArray()) {

Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));

}

// Save the visualized detection.

String filename = "faceDetection.png";

System.out.println(String.format("Writing %s", filename));

Highgui.imwrite(filename, image);

}

}
package com.njupt.zhb.test;
import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.core.MatOfRect;
import org.opencv.core.Point;
import org.opencv.core.Rect;
import org.opencv.core.Scalar;
import org.opencv.highgui.Highgui;
import org.opencv.objdetect.CascadeClassifier;

//
// Detects faces in an image, draws boxes around them, and writes the results
// to "faceDetection.png".
//
public class DetectFaceDemo {
public void run() {
System.out.println("\nRunning DetectFaceDemo");
System.out.println(getClass().getResource("lbpcascade_frontalface.xml").getPath());
// Create a face detector from the cascade file in the resources
// directory.
//CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("lbpcascade_frontalface.xml").getPath());
//Mat image = Highgui.imread(getClass().getResource("lena.png").getPath());
//注意:源程序的路径会多打印一个‘/’,因此总是出现如下错误
/*
* Detected 0 faces Writing faceDetection.png libpng warning: Image
* width is zero in IHDR libpng warning: Image height is zero in IHDR
* libpng error: Invalid IHDR data
*/
//因此,我们将第一个字符去掉
String xmlfilePath=getClass().getResource("lbpcascade_frontalface.xml").getPath().substring(1);
CascadeClassifier faceDetector = new CascadeClassifier(xmlfilePath);
Mat image = Highgui.imread(getClass().getResource("we.jpg").getPath().substring(1));
// Detect faces in the image.
// MatOfRect is a special container class for Rect.
MatOfRect faceDetections = new MatOfRect();
faceDetector.detectMultiScale(image, faceDetections);

System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));

// Draw a bounding box around each face.
for (Rect rect : faceDetections.toArray()) {
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
}

// Save the visualized detection.
String filename = "faceDetection.png";
System.out.println(String.format("Writing %s", filename));
Highgui.imwrite(filename, image);
}
}

3.编写测试类:

[java] view
plaincopyprint?

package com.njupt.zhb.test;

public class TestMain {

public static void main(String[] args) {

System.out.println("Hello, OpenCV");

// Load the native library.

System.loadLibrary("opencv_java246");

new DetectFaceDemo().run();

}

}

//运行结果:

//Hello, OpenCV

//

//Running DetectFaceDemo

///E:/eclipse_Jee/workspace/JavaOpenCV246/bin/com/njupt/zhb/test/lbpcascade_frontalface.xml

//Detected 8 faces

//Writing faceDetection.png
package com.njupt.zhb.test;
public class TestMain {
public static void main(String[] args) {
System.out.println("Hello, OpenCV");
// Load the native library.
System.loadLibrary("opencv_java246");
new DetectFaceDemo().run();
}
}
//运行结果:
//Hello, OpenCV
//
//Running DetectFaceDemo
///E:/eclipse_Jee/workspace/JavaOpenCV246/bin/com/njupt/zhb/test/lbpcascade_frontalface.xml
//Detected 8 faces
//Writing faceDetection.png

6、Opencv对视频中出现的车辆分类时,有什么办法可以使得对每个车辆进行一次分类?

你的意思是特征提取了,特征有好多种,一般监控系统中是根据车牌定位与跟踪,而且摄像机会根据监控的车道数选择是200w还是500w的高清摄像机,一般对车牌提取时借用车牌区域的宽高比,并做形态学处理,然后做分割和数字的匹配处理,车牌是车辆的唯一性标识,当然也有车体分析,驾驶人的特征分析,这些不具有代表性,也不具有唯一性,容易定位错误和跟踪丢失。


与opencv车辆跟踪相关的内容