How to make blob search and detection faster - Raspberry Pi Forums
hello,
making robot has play game. should detect , grab balls , cylinders of color in ground (small play area table made of wood of maximum area of 4*4 meters). has move in play area, find balls , cylinders of specific color , grab them, find next object of same color , on..
using camera robot see , find objects of interest.
1) problem when objects far away robot (and camera), there color intensities changes along size becomes difficult robot move in direction not identifies them. fix problem changing image binary applying proper color thresholds, since background(playing area) , objects of contrasting colors.is right way go or there better ways? avoided going hsv color space save processing time.
2) robot able blob detection slow in searching objects of interest. camera basic logic link camera max. resolution of 640*480. (link given below). how can make search faster? decreasing resolution or increasing it? how increase or decrease?
http://logilink.com/showproduct/ua0072. ... anguage=en
3) can over-clock raspberry pi , in case?
4) can use sensors can detect objects of color distance? 15 -20 inches?
posting part of code simple blob detection below unable attach file. working in c++ language.
regards
saher maqsood
making robot has play game. should detect , grab balls , cylinders of color in ground (small play area table made of wood of maximum area of 4*4 meters). has move in play area, find balls , cylinders of specific color , grab them, find next object of same color , on..
using camera robot see , find objects of interest.
1) problem when objects far away robot (and camera), there color intensities changes along size becomes difficult robot move in direction not identifies them. fix problem changing image binary applying proper color thresholds, since background(playing area) , objects of contrasting colors.is right way go or there better ways? avoided going hsv color space save processing time.
2) robot able blob detection slow in searching objects of interest. camera basic logic link camera max. resolution of 640*480. (link given below). how can make search faster? decreasing resolution or increasing it? how increase or decrease?
http://logilink.com/showproduct/ua0072. ... anguage=en
3) can over-clock raspberry pi , in case?
4) can use sensors can detect objects of color distance? 15 -20 inches?
posting part of code simple blob detection below unable attach file. working in c++ language.
regards
saher maqsood
code: select all
videocapture cap(1); if(!cap.isopened()) { cout<<"not getting camera capture"<<endl; terminatewhile = 0; } while(terminatewhile) { /// read image 5 times avoid getting broken frames, issue had for( i=0 ; i<5 ; i++ ) { cap.read(img); } if(img.empty()) { cout<<"not getting frames"<<endl; terminatewhile = 0; } else if(!img.empty()) { cout<<"getting continuous frames"<<endl; cvtcolor(img, gray, cv_bgr2gray); ///convert grayscale image binary detect color object threshold( gray, binary, 180, 255, thresh_binary); imwrite("imagebinary.jpg",binary); /// calling blob detection function. (the variables blobcounter , lastfounddirection sent blobdetectionwithimage function not used blob detection such used in other functions in case blob detected/not detected) blobdetectionarray = blobdetectionwithimage (binary, blobcounter, lastfounddirection); } } std::vector<int> blobdetectionwithimage (mat thresholdimage, int findblobcounter, int lastfounddirection) { int blobsize; int arr[] = {-1,-1,-1,-1,0}; std::vector<int> blobdetectarray(arr, arr+5); blobdetectarray[3] = findblobcounter; blobdetectarray[4] = lastfounddirection; ///declaring blob detector params , setting parameters simpleblobdetector::params params; ///vector store points of blobs vector<keypoint> keypoints; params.minarea = 500.0f; params.maxarea = 900000.0f; params.filterbyarea = true; params.filterbycircularity = false; params.filterbyconvexity = false; params.filterbyinertia = false; params.filterbycolor = true; params.blobcolor = 255; ///making object of simpleblobdetector simpleblobdetector myblob(params); myblob.create("simpleblob"); ///calling function detect blobs myblob.detect(thresholdimage, keypoints); ///if blob detected if(keypoints.size() > 0) { if(keypoints.size() > 1) { sort(keypoints.begin(),keypoints.end(), waytosort); } ///displaying area, x-coordinate , y-coordinate of each blob for(int i=0; i< keypoints.size(); i++) { cout<<"blob " <<i; blobsize = keypoints[i].size; cout << " x=" << (int)keypoints[i].pt.x << endl; cout << " y=" << (int)keypoints[i].pt.y << endl; cout<<" size=" << blobsize << endl; } blobdetectarray[0] = 1; blobdetectarray[1] = (int)keypoints[0].pt.x; blobdetectarray[2] = (int)keypoints[0].pt.y; drawkeypoints( thresholdimage, keypoints, thresholdimage); imshow( "image keypoints drawn", thresholdimage); } /// if no blob detected else if (keypoints.size() == 0) { cout <<" no blob found !!"<<endl; findblobcounter = findblob(findblobcounter,lastfounddirection); blobdetectarray[3] = findblobcounter; blobdetectarray[4] = lastfounddirection; } return blobdetectarray; }
raspberrypi
Comments
Post a Comment