Commit 1ffb16f8 authored by Aylen Ricca's avatar Aylen Ricca
Browse files

for tests

parent 67a8085c
......@@ -2,4 +2,10 @@
# unset auto exposure - RPI camera
v4l2-ctl --list-ctrls
v4l2-ctl --set-ctrl white_balance_temperature_auto=0
v4l2-ctl --set-ctrl exposure_auto=1
v4l2-ctl --set-ctrl exposure_absolute=250
v4l2-ctl --set-ctrl exposure_auto_priority=0
v4l2-ctl --set-ctrl focus_auto=0
v4l2-ctl --set-ctrl white_balance_temperature=3000
......@@ -8,31 +8,54 @@
#include "vision.h"
#include <stdio.h>
#define CANT_ITER 5
#define ROBOT_H 29.5
int main() {
FILE *fileOut = fopen("salidaTEST", "w");
int iter = 0;
if (!vision_initialize(DEFAULT_HAVIMO_ID, DEFAULT_BAUDNUM, MAGENTA_COLOR))
return -1;
if(vision_checkVision(0)) {
unsigned short int i;
char buffer [33];
for(i = 0; i < obj_size; i++) {
printf("::");
printf("%hu",objects[i].type);
printf(" ");
printf("%d",objects[i].x);
printf(" ");
printf("%u",objects[i].y);
printf(" ");
printf("%u",objects[i].z);
printf(" ");
printf("%hu",objects[i].likeness_level);
printf("\n");
vision_setPanAndTiltInDegrees(0,0);
vision_setRobotHeight(ROBOT_H);
fprintf(fileOut,"START TEST\n");
do {
fprintf(fileOut,"ITER %d\n",iter);
if(vision_checkVision(0)) {
unsigned short int i;
char buffer [33];
for(i = 0; i < obj_size; i++) {
fprintf(fileOut,"::");
fprintf(fileOut,"%hu",objects[i].type);
fprintf(fileOut," ");
fprintf(fileOut,"%d",objects[i].x);
fprintf(fileOut," ");
fprintf(fileOut,"%u",objects[i].y);
fprintf(fileOut," ");
fprintf(fileOut,"%u",objects[i].z);
fprintf(fileOut," ");
fprintf(fileOut,"%hu",objects[i].likeness_level);
fprintf(fileOut,"\n");
}
} else {
fprintf(fileOut,"error getting frame");
}
}
printf("---\n");
iter++;
} while (iter < CANT_ITER);
vision_terminate();
fprintf(fileOut,"THE END!\n");
fclose (fileOut);
printf("THE END!\n");
return 0;
}
//
// // open file to save info
// textfile << "blobs_" << std::setw(5) << std::setfill('0') << frameNumber;
// myfile.open (textfile.str().c_str(),std::ios_base::app); // concatena cada linea al final del archivo
//
......@@ -11,7 +11,7 @@
#include <stdio.h>
#include <stdlib.h>
int BLOB_LENGTH = 0x10; //se leen 16 bytes
//int BLOB_LENGTH = 0x10; //se leen 16 bytes
/**
* Retorna la comparacion de los arrays de blobs b1 y b2
......
......@@ -36,7 +36,7 @@ IplImage *img;
CvSize imgSize;
IplImage *frame;
int frameNumber;
int num = 0;
int num = -1;
/* BALL - FIELD - MY GOAL - OPP GOAL - ROBOT BODY - CYAN - MAGENTA */
cv::Scalar *calibsMIN;
......@@ -171,7 +171,7 @@ int utilBlobs_getFrame(){
/* img = cvLoadImage(imagen,1);*/
cvConvertScale(img, frame, 1, 0);
std::stringstream filename;
filename << "IMG" << std::setw(5) << std::setfill('0') << num++ << ".png";
filename << "ORIGINAL_IMG_" << std::setw(5) << std::setfill('0') << ++num << ".png";
cvSaveImage(filename.str().c_str(),frame);
return 1;
}
......@@ -296,23 +296,23 @@ void utilBlobs_getBlobs(struct blob* result){
int indice=0;
CvBlobs blobsitos;
for (int i=0; i < CANT_CALIBRACIONES && indice < CANT_REGIONS; i++){
IplImage *labelImg = cvCreateImage(cvGetSize(frame), IPL_DEPTH_LABEL, 1);
getOneColorBlobs(hsv, labelImg, blobsitos, imgSize, calibsMIN[i], calibsMAX[i]);
cvRenderBlobs(labelImg, blobsitos, frame, frame, CV_BLOB_RENDER_BOUNDING_BOX);
std::stringstream filename;
filename << "debugBLOB_" << std::setw(5) << std::setfill('0') << indice << ".png";
cvSaveImage(filename.str().c_str(),frame);
CvBlobs::const_iterator it = blobsitos.begin();
CvBlob* bloby;
while (it!=blobsitos.end() && indice < CANT_REGIONS){
bloby = (*it).second;
result [indice++] = infoToBlob(*bloby, indice+1, i+1);
it++;
}
IplImage *labelImg = cvCreateImage(cvGetSize(frame), IPL_DEPTH_LABEL, 1);
getOneColorBlobs(hsv, labelImg, blobsitos, imgSize, calibsMIN[i], calibsMAX[i]);
cvRenderBlobs(labelImg, blobsitos, frame, frame, CV_BLOB_RENDER_BOUNDING_BOX);
std::stringstream filename;
filename << "debugBLOB_" << std::setw(5) << std::setfill('0') << num << std::setw(5) << std::setfill('0') << indice << ".png";
cvSaveImage(filename.str().c_str(),frame);
CvBlobs::const_iterator it = blobsitos.begin();
CvBlob* bloby;
while (it!=blobsitos.end() && indice < CANT_REGIONS){
bloby = (*it).second;
result [indice++] = infoToBlob(*bloby, indice+1, i+1);
it++;
}
cvReleaseImage(&labelImg);
cvReleaseBlobs(blobsitos);
cvReleaseImage(&labelImg);
cvReleaseBlobs(blobsitos);
}
cvReleaseImage(&hsv);
while(indice < CANT_REGIONS) result [indice++] = fillZeros();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment