小编use*_*085的帖子

使用opencv和c++同时搜索多种颜色

我试图让下面的代码同时搜索多种颜色,例如红色、黄色和橙色。我已经在代码中添加了蒙版,但无法让它们正确应用我做错了什么我不确定将蒙版添加到框架的行是否在正确的位置。

    #include "stdafx.h"
#include <cv.h>
#include <highgui.h>

using namespace std;

using namespace cv::gpu;



IplImage* GetThresholdedImage(IplImage* imgHSV){       
    IplImage* imgThresh=cvCreateImage(cvGetSize(imgHSV),IPL_DEPTH_8U, 1);
    cvInRangeS(imgHSV, cvScalar(170,160,60), cvScalar(180,255,256), imgThresh); 
    return imgThresh;
} 
int main(){
    //Char Firetype = type;
     CvCapture* capture = cvCaptureFromCAM(1);
     if(!capture){
        printf("Capture failure\n");
        return -1;
    }
    IplImage* frame=0;

    cvNamedWindow("Video");     
    cvNamedWindow("Fire");
    cvNamedWindow("Info");
    //iterate through each frame of the video     
    while(true){
        frame = cvQueryFrame(capture);           
        if(!frame) break;
        frame=cvCloneImage(frame); 
        cvSmooth(frame, frame, CV_GAUSSIAN,3,3); //smooth the original image using Gaussian kernel
        cv::Mat imgMat(frame);
        cv::Mat mask1;
        cv::inRange(imgMat, cv::Scalar(20, 100, 100), cv::Scalar(30, …
Run Code Online (Sandbox Code Playgroud)

opencv mask colors image-processing detection

2
推荐指数
1
解决办法
2421
查看次数

标签 统计

colors ×1

detection ×1

image-processing ×1

mask ×1

opencv ×1