예제 #1
0
// Converts the Boxa array to a list of C_BLOB, getting rid of severely
// overlapping outlines and those that are children of a bigger one.
// The output is a list of C_BLOBs that are owned by the list.
// The C_OUTLINEs in the C_BLOBs contain no outline data - just empty
// bounding boxes. The Boxa is consumed and destroyed.
void LineFinder::ConvertBoxaToBlobs(int image_width, int image_height,
                                    Boxa** boxes, C_BLOB_LIST* blobs) {
#ifdef HAVE_LIBLEPT
  C_OUTLINE_LIST outlines;
  C_OUTLINE_IT ol_it = &outlines;
  // Iterate the boxes to convert to outlines.
  int nboxes = boxaGetCount(*boxes);
  for (int i = 0; i < nboxes; ++i) {
    l_int32 x, y, width, height;
    boxaGetBoxGeometry(*boxes, i, &x, &y, &width, &height);
    // Make a C_OUTLINE from the leptonica box. This is a bit of a hack,
    // as there is no outline, just a bounding box, but with some very
    // small changes to coutln.cpp, it works nicely.
    ICOORD top_left(x, image_height - y);
    ICOORD bot_right(x + width, image_height - (y + height));
    CRACKEDGE startpt;
    startpt.pos = top_left;
    C_OUTLINE* outline = new C_OUTLINE(&startpt, top_left, bot_right, 0);
    ol_it.add_after_then_move(outline);
  }
  // Use outlines_to_blobs to convert the outlines to blobs and find
  // overlapping and contained objects. The output list of blobs in the block
  // has all the bad ones filtered out and deleted.
  BLOCK block;
  ICOORD page_tl(0, 0);
  ICOORD page_br(image_width, image_height);
  outlines_to_blobs(&block, page_tl, page_br, &outlines);
  // Transfer the created blobs to the output list.
  C_BLOB_IT blob_it(blobs);
  blob_it.add_list_after(block.blob_list());
  // The boxes aren't needed any more.
  boxaDestroy(boxes);
#endif
}
예제 #2
0
		void GLOffscreenTarget::updateImageTile(Size x_lower, Size y_lower, Size x_upper, Size y_upper)
		{
			QImage current_screen;

			if (use_pixel_buffer_ && pixel_buffer_)
				current_screen = pixel_buffer_->toImage();
			else if (share_from_)
				current_screen = share_from_->grabFrameBuffer();

			if (!current_screen.isNull())
			{
				// compute the coordinates of the rectangle in the final image (remembering
				// that Qt sets y to 0 on the *upper* boundary of the image!)
				QPoint  top_left(x_lower, current_image_.height() - (y_upper+1));
				QPoint bot_right(x_upper, current_image_.height() - (y_lower+1));

				QPainter p(&current_image_);
				p.drawImage(QRect(top_left, bot_right), current_screen, current_screen.rect());
				p.end();
			}
		}
예제 #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;
				  }
				}
			}
		}


	 }
}