导航:首页 > 车辆百科 > hog车辆检测

hog车辆检测

发布时间:2021-09-03 22:10:32

1、opencv中的利用HOG特征的svm进行的行人检测,能把HOG变为其他的特征描述子检测其他物体吗?求大神指导指导

可以的。特征描述子只是一些数值而已。

2、HOG特征与Haar-like特征哪种特征更好些??

应该说,泛泛的说没有一个定论。
不同模型的特征提取方法针对于不同的检测目标会有大相径庭的效果的
像HOG就比较适用于人整体的检测,而HAAR更倾向于人脸的识别
至于这其中原因,一部分是因为数学(这个真的超复杂,不是一两句就能讲明白的),另一部分便是大量的经验所致,你可以看到每一篇外文的论文最后都会有一个专门的部分是将testresult的,会有效果比较。

3、opencv hog detectmultiscale参数怎么调

1.首先确保你输入的图片中包含行人,如果没有,那found为空是自然的事情。 2.然后,即使你输入的图片中包含行人,OpenCV自带的hog+svm检测函数也不一定能够把行人检测出来,毕竟它的训练样本数目也是有限的

4、hog多尺度检测和单尺度检测有什么区别

hog描述子在opencv中为HOGDescriptor。

2. 可以调用该描述子setSVMDetector方法给用于对hog特征进行分类的svm模型的系数赋值,这里的参数为HOGDescriptor::getDefaultPeopleDetector()时表示采用系统默认的参数,因为这些参数是用很多图片训练而来的。

3. 对输入图片进行行人检测时由于图片的大小不一样,所以要用到多尺度检测。这里是用hog类的方法detectMultiScale。参数解释如下:

HOGDescriptor::detectMultiScale(const GpuMat img, vector<Rect> found_locations, doublehit_threshold=0, Size win_stride=Size(), Size padding=Size(), double scale0=1.05, int group_threshold=2)

该函数表示对输入的图片img进行多尺度行人检测 img为输入待检测的图片;found_locations为检测到目标区域列表;参数3为程序内部计算为行人目标的阈值,也就是检测到的特征到SVM分类超平面的距离;参数4为滑动窗口每次移动的距离。它必须是块移动的整数倍;参数5为图像扩充的大小;参数6为比例系数,即滑动窗口每次增加的比例;参数7为组阈值,即校正系数,当一个目标被多个窗口检测出来时,该参数此时就起了调节作用,为0时表示不起调节作用。

4.  最后对检测出来的目标矩形框,要采用一些方法处理,比如说2个目标框嵌套着,则选择最外面的那个框。

5.  因为hog检测出的矩形框比实际人体框要稍微大些,所以需要对这些矩形框大小尺寸做一些调整。

5、如何实现HOG和LBP特征的融合

针对禁令交通标志牌提出了一种基于HOG-LBP自适应融合特征的交通标志检测方法,将标志图片等分为多个不重叠的块,每块内将加权后的HOG和LBP特征进行串行融合作为

6、OPENCV中detectMultiScale()函数返回的值是什么?

对输入图片进行行人检测时由于图片的大小不一样,所以要用到多尺度检测。这里是用hog类的方法detectMultiScale。参数解释如下:
HOGDescriptor::detectMultiScale(const GpuMat& img, vector<Rect>& found_locations, doublehit_threshold=0, Size win_stride=Size(), Size padding=Size(), double scale0=1.05, int group_threshold=2)

该函数表示对输入的图片img进行多尺度行人检测 img为输入待检测的图片;

found_locations为检测到目标区域列表;

参数3为程序内部计算为行人目标的阈值,也就是检测到的特征到SVM分类超平面的距离;

参数4为滑动窗口每次移动的距离。它必须是块移动的整数倍;

参数5为图像扩充的大小;

参数6:scale0为比例系数,即被检测图像每一次被压缩的比例,这个可以从OPENCV的hog.cpp源文件中看出:


 for( levels = 0; levels < nlevels; levels++ )
  {
      //若待检测图像的尺寸小于检测窗口的尺寸,则停止检测
  levelScale.push_back(scale);
      if( cvRound(img.cols/scale) < winSize.width ||
          cvRound(img.rows/scale) < winSize.height ||
          scale0 <= 1 )
          break;
      scale *= scale0;
  }
之前一直理解的是检测窗口会不断的按照比例系数放大,其实检测窗口是固定不变的,是待检测图像按照比例系数缩小。

参数7为组阈值,即校正系数,当一个目标被多个窗口检测出来时,该参数此时就起了调节作用,为0时表示不起调节作用。

 最后对检测出来的目标矩形框,要采用一些方法处理,比如说2个目标框嵌套着,则选择最外面的那个框。 因为hog检测出的矩形框比实际人体框要稍微大些,所以需要对这些矩形框大小尺寸做一些调整。

在进行交通灯检测的程序编写中,经过各种调整,还是使用detectMultiScale(src, found,0,Size(8,8), Size(32,32), 1.05, 2)最终通过了,其他的参数一直报错。其中第五个参数为Size(0,0)时,检测出的矩形框数量为65个,Size(32,32)时检测出的矩形框为83个,调整为Size(64,64)后检测到的矩形框增加为109个,说明这个参数的尺寸越大,好像检测量越大,检测出的矩形框越多。暂时是这么认为的,以后想清楚了再来更新吧。

下面的一组实验结果是对第4个参数的理解,第四个参数越大,检测窗口移动的步长越大,检测的目标个数越小。(检测是在训练样本数量很少的情况下完成的,提高训练样本数量可以增加检测的精度)

下图是参数为detectMultiScale(src, found,0,Size(4,4), Size(0,0), 1.05, 2)的检测结果,矩形框个数为38个

下图是参数为detectMultiScale(src, found,0,Size(16,16), Size(0,0), 1.05, 2)的检测结果,矩形框个数为88个

当第4个参数为Size(64,64)时,检测窗口仅为12个。detectMultiScale(src, found,0,Size(32,32), Size(0,0), 1.05, 2)

7、svm+hog 目标被多次检测时 怎样进行筛选

1. hog描述子在opencv中为HOGDescriptor。 2. 可以调用该描述子setSVMDetector方法

8、你好,你要matlab版的hog行人检测代码吗?O(∩_∩)O谢谢

抱歉,没有Matlab版,我用的是OpenCV自带的HOG代码。

9、求opencv中Hog行人检测视频中实现的C++代码!

整个项目的结构图:

编写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


与hog车辆检测相关的内容