Search This Blog

Wednesday, 29 May 2013

Android and OpenCV

How to render text in Android with OpenCV:
 Scalar c = new Scalar(255, 0, 0, 255);   
 Core.putText(inputFrame, "1.234m", new Point(100,100), 3, 1, c, 2);  

Draw a cross on the screen:
 void drawCross(Mat inputFrame, Point center, int width)  
 {  
   Scalar crossColor = new Scalar(0, 255, 0, 255);  
   Point point1x = new Point(center.x + width/2, center.y);  
   Point point2x = new Point(center.x - width/2, center.y);  
   Core.line(inputFrame, point1x, point2x, crossColor, 3);  
   Point point1y = new Point(center.x, center.y + width/2);  
   Point point2y = new Point(center.x, center.y - width/2);  
   Core.line(inputFrame, point1y, point2y, crossColor, 3);  
 }