加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – OpenCV:检测具有特定颜色的猫.不重要的?

发布时间:2020-12-14 01:53:41 所属栏目:Linux 来源:网络整理
导读:我有一个问题,我的猫被一只猫的猫欺负,以至于猫在夏天进入我们家,吃我们的猫食,睡在我们的家具里. 我的猫是灰色的,问题猫是棕色的. 我想在Linux机箱上使用WiFi动作凸轮和OpenCV检测制作警报系统, 但我不再做太多编码了. 所以我的问题是.这是使用标准OpenCV模
我有一个问题,我的猫被一只猫的猫欺负,以至于猫在夏天进入我们家,吃我们的猫食,睡在我们的家具里.

我的猫是灰色的,问题猫是棕色的.

我想在Linux机箱上使用WiFi动作凸轮和OpenCV检测制作警报系统,
但我不再做太多编码了.

所以我的问题是.这是使用标准OpenCV模块的一项微不足道的任务吗?

或者它需要大量的原始代码?

我知道有OpenCV级联分类器,但从未使用过它.

亲切的问候

雅各

解决方法

这是一个非常初步的答案,只是为了展示一个开始你的项目的方法.

你可以尝试找到训练有素的猫分类器.例如我找到了this
并使用下面的代码测试了一些猫图像.

#include <iostream>

#include "opencv2/highgui.hpp"
#include "opencv2/objdetect.hpp"
#include "opencv2/imgproc.hpp"

using namespace std;
using namespace cv;

int main( int argc,const char** argv )
{
    if (argc < 3)
    {
    cerr << "usage:n" << argv[0] << " <image_file_name> <model_file_name>" << endl;
    return 0;
    }

    // Read in the input arguments
    string model = argv[2];

    CascadeClassifier detector(model);
    if(detector.empty())
    {
        cerr << "The model could not be loaded." << endl;
    }

    Mat current_image,grayscale;

    // Read in image and perform preprocessing
    current_image = imread(argv[1]);
    cvtColor(current_image,grayscale,CV_BGR2GRAY);

    vector<Rect> objects;
    detector.detectMultiScale(grayscale,objects,1.05,1);

    for(int i = 0; i < objects.size(); i++)
    {
        rectangle(current_image,objects[i],Scalar(0,255,0),2);
    }

    imshow("result",current_image);
    waitKey();
    return 0;
}

我得到的一些结果图像

enter image description here


enter image description here


enter image description here

当你找到一个令人满意的分类器时,你可以将它用于视频帧,你可以用检测到的猫用它们的颜色进行过滤.

also you can take a look at

07004

07005 (no idea if it works)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读