Exemple #1
0
void opp_bot::update(){
   
    Mat roi_image = image(location);
    
    GaussianBlur( roi_image, roi_image, Size( 3, 3 ), 0, 0 );
    
    cvtColor(roi_image, roi_image, CV_BGR2HSV);

    mask[0] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);
    
    pick_color( roi_image, mask[0], color );
    imshow("opp bot mask", mask[0]);
    FindCenter();
    
    cvtColor(roi_image, roi_image, CV_HSV2BGR);

    if( center.x != 0 ){
        center = Point( center.x + location.x, center.y + location.y );
        update_location( location, center );
    }
    else{
        expand_location( location );
    }

    limit_location_within_arena( location );

}
	void clusterfnc::Merge(clusterdat* c1, clusterdat* c2){ //c2 and c1 are going to be in c3 from now on.
		int index = 0;
		for (index=0;index<640*480;index++) {
			if (!(c2->points[index]==0)) {
				c1->points[index] = c2->points[index];
			}
		}
		c1->pntfnc.Center(&c1->center,&c2->center,&c1->center);
		CalculateVolume(c1);
		FindCenter(c1);
	}
	void clusterfnc::Flatten(clusterdat* c1, int maxDepth){
		float maxZValue = c1->vol.location.z + maxDepth;
		if (c1->vol.depth > maxDepth) {
			int index = 0;
			for (index=0;index<640*480;index++) {
				if (!(c1->points[index]==0)) {
					if (c1->points[index]->z > maxDepth) {
						c1->points[index]->z = maxDepth; //ALTERED
					}
				}
			}
			FindCenter(c1);
			CalculateVolume(c1);
		}
	}
Exemple #4
0
void our_bot::update(){

    Mat roi_image;
    roi_image = image(location);

    GaussianBlur( roi_image, roi_image, Size( 3, 3 ), 0, 0 );
    
    cvtColor(roi_image, roi_image, CV_BGR2HSV);
    
    mask[0] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);
    mask[1] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);
    mask[2] = Mat::zeros(roi_image.rows,roi_image.cols,CV_8UC1);

    pick_color( roi_image,mask[0], basecolor );
    pick_color( roi_image,mask[1], lcolor );
    pick_color( roi_image,mask[2], rcolor );
   
	imshow("base",mask[0]);
	imshow("left",mask[1]);
	imshow("right",mask[2]);
    
    FindCenter();
    
   cvtColor(roi_image, roi_image, CV_HSV2BGR);

    if( front_center.x != 0 && back_center.x != 0 ){
        //Taking care for the relative position changes due to ROI.
        front_center = Point( front_center.x + location.x, front_center.y + location.y );
        back_center = Point( back_center.x + location.x, back_center.y + location.y );
        bot_center = Point( ( front_center.x + back_center.x ) / 2, ( front_center.y + back_center.y ) / 2 );
        update_location( location, bot_center );
        //        cout<<"bot found!!"<<endl;
    }
    else{
        expand_location( location );
    }

    limit_location_within_arena( location );

    //    cout<<"location = "<<location.x<<' '<<location.y
    //        <<' '<<location.width<<' '<<location.height<<endl;
    pos();
    orientation();
}
void CScanImage::OnButton1() 
{
	// TODO: Add your control notification handler code here
	okCaptureTo(hBoard,BUFFER,0,CROSS_CAPTURE_NUM);//采集一幅图像
	okGetCaptureStatus(hBoard,1);//等待采集完毕
	long lBitNumber=CAMERA_WIDTH*CAMERA_HEIGHT;//单幅图像数据所需空间大小
	cData=new unsigned char[lBitNumber]; //开辟自用图像数据区
	memcpy(cData, lpLinear, lBitNumber); //将BUFFER中数据拷贝到开辟的自由图像数据区
	int nCenterX,nCenterY;
	int nWidth=CAMERA_WIDTH;
	int nHeight=CAMERA_HEIGHT;
	
	FindCenter(cData,nCenterX,nCenterY,nWidth,nHeight);//在当前的图像数据中,寻找亮度极大值点(作为十字叉中心)
	delete cData;

	m_nXPos=nCenterX;
	m_nYPos=nCenterY;
	
	Invalidate();
}
void Cluster::Flatten(int maxDepth){    
	float maxZValue = vol.location->z + maxDepth;
	std::vector<Point*> newlist;
	std::vector<Point*>::iterator iter;
	Point *p;
	if (vol.depth > maxDepth)
	{
		for (iter=points.begin();iter<points.end();iter++) {
			//go through list, make new list, apply to old list
			p = (Point*)*iter;
			if (p->z<maxZValue) {
				newlist.push_back(new Point(p));
			}
		}
		

		points = newlist;
		FindCenter();
		CalculateVolume();
	}
}