Ask Your Question

Revision history [back]

I think it should be pretty easy to define a draw_crosshairs(Mat, Point(center_x,center_y))() function yourself. Steps that you should follow is:

  • Take the Mat element and locate the middle point.
  • Based on the middle coordinates draw 4 small lines of 3-4 pixels in the correct direction.
  • Then return the Mat element with the drawing on it.

There is no such functionality in OpenCV provided, because GUI interfacing is not the core buisness of OpenCV. The used visualisation is mainly for data validation, and openCV provides mostly functionality that runs in your processing layer under your GUI interface.

I think it should be pretty easy to define a draw_crosshairs(Mat, Point(center_x,center_y))() function yourself. Steps that you should follow is:

  • Take the Mat element and locate the middle point.
  • Based on the middle coordinates draw 4 small lines of 3-4 pixels in the correct direction.
  • Then return the Mat element with the drawing on it.

There is no such functionality in OpenCV provided, because GUI interfacing is not the core buisness of OpenCV. The used visualisation is mainly for data validation, and openCV provides mostly functionality that runs in your processing layer under your GUI interface.

EDIT: The following command draws a crosshair in the middle of your screen. Reform this snippet for your purpose!

line((screenWidth/2)-20, screenHeight/2, (screenWidth/2)+20, screenHeight/2);  //crosshair horizontal
line(screenWidth/2, (screenHeight/2)-20, screenWidth/2, (screenHeight/2)+20);  //crosshair vertical