// Return the bounding boxes of columns at the given y-range
void ColPartitionSet::GetColumnBoxes(int y_bottom, int y_top,
                                     ColSegment_LIST *segments) {
  ColPartition_IT it(&parts_);
  ColSegment_IT col_it(segments);
  col_it.move_to_last();
  for (it.mark_cycle_pt(); !it.cycled_list(); it.forward()) {
    ColPartition* part = it.data();
    ICOORD bot_left(part->LeftAtY(y_top), y_bottom);
    ICOORD top_right(part->RightAtY(y_bottom), y_top);
    ColSegment *col_seg = new ColSegment();
    col_seg->InsertBox(TBOX(bot_left, top_right));
    col_it.add_after_then_move(col_seg);
  }
}
Beispiel #2
0
// Returns a bounding box of the outline contained within the
// given horizontal range.
TBOX BLOBNBOX::BoundsWithinLimits(int left, int right) {
  FCOORD no_rotation(1.0f, 0.0f);
  float top = box.top();
  float bottom = box.bottom();
  if (cblob_ptr != NULL) {
    find_cblob_limits(cblob_ptr, static_cast<float>(left),
                      static_cast<float>(right), no_rotation,
                      bottom, top);
  }

  if (top < bottom) {
    top = box.top();
    bottom = box.bottom();
  }
  FCOORD bot_left(left, bottom);
  FCOORD top_right(right, top);
  TBOX shrunken_box(bot_left);
  TBOX shrunken_box2(top_right);
  shrunken_box += shrunken_box2;
  return shrunken_box;
}
Beispiel #3
0
void eye_control(){
    while(1){
		 if(buttonsPressed & BUTTON_S2){   //D3 to disable eye control
			 bot_stop();
			 buttonsPressed=0;
			 lcd_clear();
			 print_string(40,30,"Disabled!!");
			 _delay_ms(3000);
			 lcd_clear();
			 break;
		 }

        small_blink=0,big_blink=0,ON=0,menu_counter=0;
		 short toggle=1;
		 input = adc_read();

         highlight_and_print_string(0,8,"1.Waiting...");
         _delay_ms(100);
		 // lcd_clear();

		 if(input > AdcThreshold || input==AdcThreshold){
		        check_blink();
		 }

		 if(big_blink){
		     _delay_ms(1000);
			 while(1){
				 if(buttonsPressed & BUTTON_S2){   //D3 to disable eye control
					 bot_stop();
					 /*lcd_clear();
					 print_string(24,30,"Disabled!!");
					 _delay_ms(1000);
					 lcd_clear();*/
					 break;
				 }
				 small_blink=0,big_blink=0;
				 input = adc_read();
				 if(input > AdcThreshold){
					 check_blink();
				 }
				 if(small_blink && !ON){
					 menu_counter++;
					 toggle=1;
					 if(menu_counter==5) menu_counter=0;

				 }


				else if(big_blink){
						//lcd_clear();
						if(ON){
							   ON=0;
							   bot_stop();
							   _delay_ms(1000);
							   toggle=1;
						}
						else if(menu_counter==0){
						       _delay_ms(1000);
							   break;
						}
						else if(menu_counter==1){
							   highlight_and_print_string(0,16,"2.Left...");
							   _delay_ms(1000);
							   bot_left();
							   ON=1;
						}
						else if(menu_counter==2){
							   highlight_and_print_string(0,24,"3.Right...");
							   _delay_ms(1000);
							   bot_right();
							   ON=1;
						}
						else if(menu_counter==3){
						    	highlight_and_print_string(0,32,"4.Forward...");
							   _delay_ms(1000);
							   bot_forward();
							   ON=1;
						}
						else if(menu_counter==4){
						    	highlight_and_print_string(0,40,"5.Backward...");
							   _delay_ms(1000);
							   bot_backward();
							   ON=1;
						}


				}


				if(!ON && toggle){
					 toggle=0;
					 //lcd_clear();
		             print_string(0,0,"===Eye Control===");
		             print_string(0,8,"1.Wait      ");
		        	 print_string(0,16,"2.Left   ");
		        	 print_string(0,24,"3.Right   ");
		             print_string(0,32,"4.Forward   ");
		        	 print_string(0,40,"5.Backward   ");
		        	 print_string(0,56,"*S2=ESC*");

					 switch(menu_counter){
					 case 0:
			              highlight_and_print_string(0,8,"1.Wait      ");
						 _delay_ms(100);
						 break;
					 case 1:
						  highlight_and_print_string(0,16,"2.Left   ");
						 _delay_ms(100);
						 break;
					 case 2:
						 highlight_and_print_string(0,24,"3.Right   ");
						 _delay_ms(100);
						 break;
					 case 3:
						 highlight_and_print_string(0,32,"4.Forward   ");
						 _delay_ms(100);
						 break;
					 case 4:
						 highlight_and_print_string(0,40,"5.Backward   ");
						 _delay_ms(100);
						 break;
				   default:
						 break;
				  }
				}
			}
		}


	 }
}