Пример #1
0
int arrow_detection::segmentation(Mat binary_image,vector<Rect> &blobs_roi, vector <vector<Point2i>> &blobs){
    int image_area = (float(3500)/float(1080*760)) * binary_image.total();
    // DEBUG_LOG("Minimum blob area: %d\n",image_area);
	findBlobs(binary_image, blobs,image_area);
	blobs_roi.clear();
	for(size_t i=0; i < blobs.size(); i++) {
		int min_x,min_y,max_x,max_y;
		max_x = max_y = 0;
		min_x = binary_image.cols;
		min_y = binary_image.rows;
        for(size_t j=0; j < blobs[i].size(); j++) {
            int x = blobs[i][j].x;
            int y = blobs[i][j].y;
            if(x < min_x){
            	min_x = x;
            }
            if (x > max_x){
            	max_x = x;
            }
            if(y < min_y){
            	min_y = y;
            }
            if(y > max_y){
            	max_y = y;
            }
        }
        blobs_roi.push_back(Rect(min_x,min_y,abs(min_x-max_x),abs(min_y - max_y)));
    }
    return 0;
}
Пример #2
0
/**
* Runs an iteration of the Pipeline and updates outputs.
*
* Sources need to be set before calling this method. 
*
*/
void GripPipeline::process(cv::Mat source0){
	//Step CV_resize0:
	//input
	cv::Mat cvResizeSrc = source0;
	cv::Size cvResizeDsize(0, 0);
	double cvResizeFx = 0.25;  // default Double
	double cvResizeFy = 0.25;  // default Double
    int cvResizeInterpolation = cv::INTER_LINEAR;
	cvResize(cvResizeSrc, cvResizeDsize, cvResizeFx, cvResizeFy, cvResizeInterpolation, this->cvResizeOutput);
	//Step HSV_Threshold0:
	//input
	cv::Mat hsvThresholdInput = cvResizeOutput;
	double hsvThresholdHue[] = {42.086330935251794, 86.7911714770798};
	double hsvThresholdSaturation[] = {32.10431654676259, 207.37691001697794};
	double hsvThresholdValue[] = {91.72661870503596, 255.0};
	hsvThreshold(hsvThresholdInput, hsvThresholdHue, hsvThresholdSaturation, hsvThresholdValue, this->hsvThresholdOutput);
	//Step CV_erode0:
	//input
	cv::Mat cvErodeSrc = hsvThresholdOutput;
	cv::Mat cvErodeKernel;
	cv::Point cvErodeAnchor(-1, -1);
	double cvErodeIterations = 1;  // default Double
    int cvErodeBordertype = cv::BORDER_CONSTANT;
	cv::Scalar cvErodeBordervalue(-1);
	cvErode(cvErodeSrc, cvErodeKernel, cvErodeAnchor, cvErodeIterations, cvErodeBordertype, cvErodeBordervalue, this->cvErodeOutput);
	//Step Mask0:
	//input
	cv::Mat maskInput = cvResizeOutput;
	cv::Mat maskMask = cvErodeOutput;
	mask(maskInput, maskMask, this->maskOutput);
	//Step Find_Blobs0:
	//input
	cv::Mat findBlobsInput = maskOutput;
	double findBlobsMinArea = 0.0;  // default Double
	double findBlobsCircularity[] = {0.0, 1.0};
	bool findBlobsDarkBlobs = true;  // default Boolean
	findBlobs(findBlobsInput, findBlobsMinArea, findBlobsCircularity, findBlobsDarkBlobs, this->findBlobsOutput);
}