diff --git a/factory.c/factory.c b/factory.c/factory.c index 06e2269..5ff5120 100644 --- a/factory.c/factory.c +++ b/factory.c/factory.c @@ -12,13 +12,17 @@ using namespace cv; using namespace std; -int detector(int x, int y, int width, int height, int thresholdValue); +int detector(int x, int y, int width, int height, int thresholdValue, CvCapture* capture); int main(int argc, char const *argv[]) { + CvCapture* capture = cvCaptureFromCAM(0); + cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,640); + cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,480); wiringPiSetup(); pinMode(21,OUTPUT); pinMode(20,OUTPUT); + digitalWrite(20,LOW); digitalWrite(21,LOW); int DELAY_FOR_PIC = atoi(argv[1]); int DELAY_FOR_ROBOT = atoi(argv[2]); @@ -37,7 +41,7 @@ int main(int argc, char const *argv[]) //int resultado = detector(100, 80, 150, 150,140); digitalWrite(20,LOW); digitalWrite(21,LOW); - int resultado = detector(x,y,width,height,thresholdValue); + int resultado = detector(x,y,width,height,thresholdValue, capture); printf("%d\n", resultado); if (resultado == LATA) { @@ -59,17 +63,13 @@ int main(int argc, char const *argv[]) return 0; } -int detector(int x, int y, int width, int height, int thresholdValue) { +int detector(int x, int y, int width, int height, int thresholdValue, CvCapture* capture) { Mat img; Rect r; vector channels; r = Rect(x,y,width,height); - CvCapture* capture = cvCaptureFromCAM(0); - cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_WIDTH,640); - cvSetCaptureProperty(capture,CV_CAP_PROP_FRAME_HEIGHT,480); - if ( !capture ) { fprintf( stderr, "ERROR: capture is NULL \n" ); getchar();