0

OpenCV/C++ を使用して複数の色を追跡する例はありますか? 私はPythonでいくつか見つけましたが、C++ではまだ見つけていません。を使用して黄色を追跡できました:

IplImage *imgHSV= cvCreateImage (cvGetSize(img),8,3);
cvCvtColor(img,imgHSV,CV_BGR2HSV);

IplImage*imgThreshed =cvCreateImage(cvGetSize(img),8,1);

//track yellow
cvInRangeS(imgHSV,cvScalar(20,100,100), cvScalar(30,255,255), imgThreshed);

//saved the points 
double area=cvGetCentralMoment(moment, 0, 0);
double moment10=cvGetSpatialMoment(moment, 1, 0);
double moment01=cvGetSpatialMoment(moment, 0, 1);

私は青で似たようなことをしようとしています:

cvInRangeS(imgHSV,cvScalar(100,100,100), cvScalar(120,255,255), imgblue);

次に、ポイントを保存します。

double area1=cvGetCentralMoment(moment1, 0, 0);
double moment05=cvGetSpatialMoment(moment1, 1, 0);
double moment02=cvGetSpatialMoment(moment1, 0, 1);

//線を引く

   static int posF=0;
    static int posE=0;

  posE=moment05/area1;
    posF=moment02/area1;

    int lastF=posF;
    int lastE=posE
 if (lastF>=0 && lastE>=0 && posF>=0 && posE>=0){

        cvLine(imgScribble, cvPoint(posF,posE),cvPoint(lastF,lastE), cvScalar(255,0,0),16);

    }

青のポイントは、私が問題を抱えているものです。複数の色を追跡してポイントを保存するためのアドバイスはありますか? ![黄色の線は黄色を追跡しており、青い点は青を示していますが、これらも線1である必要があります

4

0 に答える 0