Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

#include "stdafx.h"

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


/*IplImage* GetThresholdedImage(IplImage* imgHSV){        
       IplImage* imgThresh=cvCreateImage(cvGetSize(imgHSV),IPL_DEPTH_8U, 1);
       cvInRangeS(imgHSV, cvScalar(170,160,60), cvScalar(180,256,256), imgThresh); 
       return imgThresh;
} */
IplImage* GetThresholdedImage(IplImage* imgHSV, CvScalar lower, CvScalar upper)
{       
    IplImage* imgThresh=cvCreateImage(cvGetSize(imgHSV),IPL_DEPTH_8U, 1);
    cvInRangeS(imgHSV, lower, upper, imgThresh); 
    return imgThresh;
}

IplImage* hsv;


CvScalar blue_upper = cvScalar(120,256,256);
CvScalar green_lower = cvScalar(40,60,10);
CvScalar green_upper = cvScalar(71,256,256);

IplImage* blue_mask = GetThresholdedImage(hsv, blue_lower, blue_upper);
IplImage* green_mask = GetThresholdedImage(hsv, green_lower, green_upper);

int main(){
      CvCapture* capture =0;       

      capture = cvCaptureFromCAM(0);
      if(!capture){
            printf("Capture failure
");
            return -1;
      }

      IplImage* frame=0;
      cvNamedWindow("Video");      
      cvNamedWindow("Ball");


      while(true){

            frame = cvQueryFrame(capture);            
            if(!frame) break;

            frame=cvCloneImage(frame); 
            cvSmooth(frame, frame, CV_GAUSSIAN,3,3); 

            IplImage* imgHSV = cvCreateImage(cvGetSize(frame), IPL_DEPTH_8U, 3); 
            cvCvtColor(frame, imgHSV, CV_BGR2HSV); 
            IplImage* imgThresh = GetThresholdedImage(imgHSV);

            cvSmooth(imgThresh, imgThresh, CV_GAUSSIAN,3,3);

            cvShowImage("Ball", imgThresh);            
            cvShowImage("Video", frame);


            cvReleaseImage(&imgHSV);
            cvReleaseImage(&imgThresh);            
            cvReleaseImage(&frame);


            int c = cvWaitKey(10);
            if((char)c==27 ) break;      
      }

      cvDestroyAllWindows() ;
      cvReleaseCapture(&capture);     

      return 0;
}

above is my code to tell different colors but turns out something wrong with the main function. basically the main function is just active the cam. the error is: "GetThresholdedImage does not take 1 arguments". can someone give me some hints?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
232 views
Welcome To Ask or Share your Answers For Others

1 Answer

The line

IplImage* imgThresh = GetThresholdedImage(imgHSV);

is what causes the error. The interface to your function

GetThresholdedImage

has three parameters, as used in

IplImage* blue_mask = GetThresholdedImage(hsv, blue_lower, blue_upper);
IplImage* green_mask = GetThresholdedImage(hsv, green_lower, green_upper);

You will have to add the other two parameters, say:

IplImage* imgThresh = GetThresholdedImage(imgHSV, blue_lower, blue_upper);

depending on what you want to do with the image.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...