Ask Your Question
1

OpenCV Image DPI [closed]

asked 2016-01-27 04:22:35 -0600

junmilreyso gravatar image

updated 2016-01-27 20:01:31 -0600

Hello,

I have small openCV python code that covers a rectangle in an image with a solid color, basically covering it up. (Trying to censor out an image and some personal details from an ID to be specific) using coordinates from another OCR engine.

The problem is when I use the coordinates from the other OCR engine's recognition, the white boxes (solid color to cover up the image) arent in the correct places.

All I know is that the coordinates from the other OCR engine were from a 300dpi image, but I dont know what dpi openCV works with its images when dealing with coordinates.

Any help?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by junmilreyso
close date 2016-01-28 01:14:39.205193

1 answer

Sort by ยป oldest newest most voted
4

answered 2016-01-27 05:53:22 -0600

pklab gravatar image

DPI are used to print, scan or display ... from/to real world. DPI is a scale factor to convert inches coordinates into pixel coordinates and back.

OpenCV doesn't know about DPI it just uses matrix cols and rows as pixel coordinates x,y. If you have coordinates in inches and you know source DPI you can convert them in rows and cols:

x_px = x_inch * DPI
y_px = y_inch * DPI

Remember that in OpenCV

  • 0,0 is top left
  • X are columns and increases on the right
  • Y are rows and increases on the bottom
edit flag offensive delete link more

Comments

I see, so how come when I use the coordinates (in pixels, judging from their values - 3digit values) from the other OCR engine that the regions of colored boxes are way off from the intended areas if I am using the coordinate values as-is?

junmilreyso gravatar imagejunmilreyso ( 2016-01-27 19:10:34 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-01-27 04:22:35 -0600

Seen: 14,124 times

Last updated: Jan 27 '16