[Robotvision-commit] SF.net SVN: robotvision:[24] vision
Brought to you by:
phildavidson
From: <luc...@us...> - 2010-06-03 04:17:24
|
Revision: 24 http://robotvision.svn.sourceforge.net/robotvision/?rev=24&view=rev Author: lucyyuan Date: 2010-06-03 04:17:18 +0000 (Thu, 03 Jun 2010) Log Message: ----------- Slider autosaves config values on exit. Modified Paths: -------------- vision/.cproject vision/src/main.cpp Modified: vision/.cproject =================================================================== --- vision/.cproject 2010-06-03 03:56:47 UTC (rev 23) +++ vision/.cproject 2010-06-03 04:17:18 UTC (rev 24) @@ -60,7 +60,7 @@ </folderInfo> <sourceEntries> <entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/> -<entry excluding="ellipse.cpp|findBuoy.c|pipe.cpp|squares.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/> +<entry excluding="test2.cpp|ellipse.cpp|findBuoy.c|pipe.cpp|squares.c" flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src"/> </sourceEntries> </configuration> </storageModule> Modified: vision/src/main.cpp =================================================================== --- vision/src/main.cpp 2010-06-03 03:56:47 UTC (rev 23) +++ vision/src/main.cpp 2010-06-03 04:17:18 UTC (rev 24) @@ -35,12 +35,13 @@ int sthresholdbuoy=0, hupperbuoy=0, hlowerbuoy=0, erodebuoy=0, dilatebuoy=0; int sthresholdpipe=0, hupperpipe=0, hlowerpipe=0, erodepipe=0, dilatepipe=0; int sthresholdhedge=0, hupperhedge=0, hlowerhedge=0, erodehedge=0, dilatehedge=0; +int sthreshold=0, hupper=0, hlower=0, erode=0, dilate=0; // for slider //the following function is used by all of the find functions //in order to set their threshold values on the fly //using a config file -//type 1 is the buoy, type 2 is the pipe, type 3 is the hedge +//type 1 is the buoy, type 2 is the pipe, type 3 is the hedge, type 4 is slider void readFile(char* filename, int type){ FILE* filereader; @@ -69,6 +70,7 @@ case(1):sthresholdbuoy=atoi(value);break; case(2):sthresholdpipe=atoi(value);break; case(3):sthresholdhedge=atoi(value);break; + case(4):sthreshold=atoi(value);break; } @@ -82,6 +84,7 @@ case(1):hupperbuoy=atoi(value);break; case(2):hupperpipe=atoi(value);break; case(3):hupperhedge=atoi(value);break; + case(4):hupper=atoi(value);break; } @@ -94,6 +97,7 @@ case(1):hlowerbuoy=atoi(value);break; case(2):hlowerpipe=atoi(value);break; case(3):hlowerhedge=atoi(value);break; + case(4):hlower=atoi(value);break; } @@ -105,6 +109,7 @@ case(1):erodebuoy=atoi(value);break; case(2):erodepipe=atoi(value);break; case(3):erodehedge=atoi(value);break; + case(4):erode=atoi(value);break; } @@ -116,6 +121,7 @@ case(1):dilatebuoy=atoi(value);break; case(2):dilatepipe=atoi(value);break; case(3):dilatehedge=atoi(value);break; + case(4):dilate=atoi(value);break; } @@ -131,6 +137,22 @@ } } + +void saveFile(char* filename) { + FILE* filewriter; + + filewriter = fopen(filename, "w"); + + if(filewriter!=NULL){ + fprintf(filewriter, "sthreshold %d\n", sthreshold); + fprintf(filewriter, "hlower %d\n", hlower); + fprintf(filewriter, "hupper %d\n", hupper); + fprintf(filewriter, "erode %d\n", erode); + fprintf(filewriter, "dilate %d\n", dilate); + } +} + + //need to show the method headers /*point findBuoy(IplImage* img); point findPipe(IplImage* img); @@ -667,13 +689,18 @@ return retElipse; } -int slider(char* imageFile) { +int slider(char* functionName, char* imageFile) { - int sthreshold = 68, erode = 4, dialate = 8; + if(strcmp(functionName, "findBuoy") == 0) { + readFile("config/buoy.txt", 4); + } + else if(strcmp(functionName, "finalFindPipe") == 0) { + readFile("config/pipe.txt", 4); + } + else{ + readFile("config/hedge.txt", 4); + } - int hlower = 127, hupper = 25;/* - here hlower is the lower cut off and the hupper is the upper cut off for hue values of red.*/ - cvNamedWindow("original", CV_WINDOW_AUTOSIZE); cvNamedWindow("Monochrome Of red Blob", CV_WINDOW_AUTOSIZE); @@ -683,7 +710,7 @@ cvCreateTrackbar("hlower", "Monochrome Of red Blob", &hlower, 255, 0); cvCreateTrackbar("hupper", "Monochrome Of red Blob", &hupper, 255, 0); cvCreateTrackbar("erode", "Monochrome Of red Blob", &erode, 20, 0); - cvCreateTrackbar("dialate", "Monochrome Of red Blob", &dialate, 20, 0); + cvCreateTrackbar("dilate", "Monochrome Of red Blob", &dilate, 20, 0); int i, j, k;//for iterations int temp = 0;//if we use a temporary var @@ -770,7 +797,7 @@ or erosion*/ cvErode(monoimgbot, monoimgbot, 0, erode); - cvDilate(monoimgbot, monoimgbot, 0, dialate); + cvDilate(monoimgbot, monoimgbot, 0, dilate); /*here i have experimented with the values by changing them\x85and i have found that i come to a good result by applying erosion 6 times and dilation 15 times you can comment/uncomment play with the values and see what is going on @@ -791,6 +818,17 @@ } cvDestroyWindow("Monochrome Of red Blob"); cvDestroyWindow("original"); + + if(strcmp(functionName, "findBuoy") == 0) { + saveFile("config/buoy.txt"); + } + else if(strcmp(functionName, "finalFindPipe") == 0) { + saveFile("config/pipe.txt"); + } + else{ + saveFile("config/hedge.txt"); + } + return 0; } @@ -1026,8 +1064,28 @@ printf("Image file? Remember: images/...\n"); printf("%**>"); gets(fileName); - slider(fileName); + printf("Type 1 for findBuoy, 2 for findPipe, 3 for findHedge\n"); + printf("%**>"); + gets(functionName); + + type = atoi(functionName); + + if(type==1){ + + slider("findBuoy", fileName); + + } + else if(type==2){ + + slider("finalFindPipe", fileName); + } + else{ + + slider("findHedge", fileName); + + } + } else{ @@ -1082,20 +1140,21 @@ //make sure that the person puts the name of the method //as well as the name of the video - if(argc<3){ + if(argc<4){ printf("Insufficient number of arguments.\n"); } else{ - slider(argv[2]); + slider(argv[2], argv[3]); } } else{ printf("To view a video type vision.exe -v functionName video\n " - "To view an image type vision.exe -i functionName image"); + "To view an image type vision.exe -i functionName image\n" + "To view the slider utility type vision.exe -s functionName image\n"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |