【问题标题】:How can I detect multiple signs using haar training如何使用 haar 训练检测多个迹象
【发布时间】:2014-03-15 06:44:13
【问题描述】:

我正在做一个检测标志的项目,我目前正在使用haar 训练来获得手部检测。我已经针对不同的标志训练了XML 文件。我无法在我的检测程序中使用多个XML 文件。无论如何我可以包含不同的XML 文件来检测不同的迹象或我可以遵循的其他方法来检测多个迹象

提前致谢。

代码:

if( cascade1)
{

    // There can be more than one hand in an image. So create a growable sequence of hands.
    // Detect the objects and store them in the sequence
    CvSeq* hands1 = cvHaarDetectObjects( img, cascade1, storage,
                                        1.1, 2, CV_HAAR_DO_CANNY_PRUNING,
                                        cvSize(40, 40) );
     // Loop the number of hands found.
    for( i = 0; i < (hands1 ? hands1->total : 0); i++ )
    {
       // Create a new rectangle for drawing the hand
        CvRect* r = (CvRect*)cvGetSeqElem( hands1, i );

        // Find the dimensions of the hand,and scale it if necessary
        pt1.x = r->x*scale;
        pt2.x = (r->x+r->width)*scale;
        pt1.y = r->y*scale;
        pt2.y = (r->y+r->height)*scale;

        // Draw the rectangle in the input image
        cvRectangle( img, pt1, pt2, CV_RGB(230,20,232), 3, 8, 0 );
        //text



          // Show the image in the window named "result"
cvShowImage( "result", img );
}
}
else if (cascade2)
{
    CvSeq* hands2 = cvHaarDetectObjects( img, cascade2, storage,
                                        1.1, 2, CV_HAAR_DO_CANNY_PRUNING,
                                        cvSize(40, 40) );
     // Loop the number of hands found.
    for( i = 0; i < (hands2 ? hands2->total : 0); i++ )
    {
       // Create a new rectangle for drawing the hand
        CvRect* r = (CvRect*)cvGetSeqElem( hands2, i );

        // Find the dimensions of the hand,and scale it if necessary
        pt3.x = r->x*scale;
        pt4.x = (r->x+r->width)*scale;
        pt3.y = r->y*scale;
        pt4.y = (r->y+r->height)*scale;

        // Draw the rectangle in the input image
        cvRectangle( img, pt3, pt4, CV_RGB(230,20,232), 3, 8, 0 );
        //text


         // Show the image in the window named "result"
cvShowImage( "result", img );

它只检测onexml 文件

【问题讨论】:

  • 请停止生活在岩石下,并使用 opencv 的 c++ api 代替已弃用的 c api

标签: opencv image-processing computer-vision haar-classifier


【解决方案1】:

最简单的方法是用不同的XML文件依次检测标志,然后组合结果。

【讨论】:

  • 我试过这样做,我创建了两个级联分类器,但只检测到一个图像..我在上面添加了代码段
猜你喜欢
  • 1970-01-01
  • 2015-07-26
  • 2020-02-06
  • 1970-01-01
  • 2017-12-13
  • 1970-01-01
  • 1970-01-01
  • 2019-01-21
  • 2017-11-11
相关资源
最近更新 更多