4

following up on my other question, do you guys know a good example in OpenCV, with a simple Black/White-Calibration Picture and appropriate detection-algorithms?

I just want to show some B&W-image on a screen, take a picture of that image from afar and calculate the size of the shown image, to calculate the distance to said screen.

Before I invent the wheel again, I recon this is so easy that it could be achieved through many different ways in OpenCV, yet I thought I'd ask if there's a preferred way around, possibly with some sample code.

(I got some face-detection code running using haarcascade-xml files already)

PS: I already have the resolution/dpi-part of my screen covered, so I know how big a picture would be in cm on my screen.

EDIT:

I'll make it real simple, I need:

  1. A pattern, that is easily recognizable in an Image. Right now I'm experimenting with a checkerboard. The people who made ARDefender used this.
  2. An appropriate algorithm to tell me the exact pixel coordinates of pattern 1) in a picture using OpenCV.
Community
  • 1
  • 1
Bersaelor
  • 2,517
  • 34
  • 58
  • Sorry, but I don't get your question - you want to calculate distance to another phone, and this (another) phone has black and white image on it? – ArtemStorozhuk Jun 27 '12 at 17:56
  • I want to show an Image (whether on a phone or screen is not important) that is easily recognizable in OpenCV. So I can calculate the images size in pixels in a picture. (Once I know how big the test-pattern is exactly I can easily calculate it's distance because I know it's actual size in cm) – Bersaelor Jun 27 '12 at 17:58
  • 1
    Do you want to recognize this image in defferent illumination? – ArtemStorozhuk Jun 27 '12 at 18:02
  • It should be easily recognizable in different angles/illuminations. That's why I supposed B&W might be appropriate, because I'd have the highest contrast then. – Bersaelor Jun 27 '12 at 18:18

2 Answers2

1

Well, it's hard to say which image is the best for recognition - in different illumination any color could be interpret as another color. Simple example:

sample example

As you can see both traffic signs have red color border but even on one image upper sign border is obviously not red.

So in my opinion you should use image with many different colors (like a rainbow). And also you said that it should be easy recognizable in different angles. That's why circle shape is the best for it.

That's why your image should look like this:

example

So idea of detection such object is the following:

  1. Make different color segmentation (blue, red, green etc). For this use HSV color space.
  2. Detect circles of specific color on image.
  3. That area which has the biggest count of circles seems to be your object.
ArtemStorozhuk
  • 8,715
  • 4
  • 35
  • 53
  • I was not thinking about color so much.. more about the pattern being unique and with high contrasts so it's size/borders is/are easily measurable.. but the idea with circles is a good one, I'll look into that and respond again, once I get something working :) – Bersaelor Jun 27 '12 at 18:47
  • @Bersaelor it seems that pattern will fail at different angle. – ArtemStorozhuk Jun 27 '12 at 19:02
0

you just have to take pictures of your B&W object from several known distances (1m, 2m, 3m, ...) and then for each distance check the size of your object in the corresponding image. From those datas, you will be able to create a linear function giving you the distance from the size in pixels (y = ax + b should do ;) ), translate it into your code and you're done. Cheers

CTZStef
  • 1,675
  • 2
  • 18
  • 47
  • the problem seems to be not in that. – ArtemStorozhuk Jun 27 '12 at 18:03
  • Agree with Astor, because what you wrote is what I know already and not my question. – Bersaelor Jun 27 '12 at 18:08
  • -1 for that is kind of harsh. I don't care for the 50 points bounty btw. Just wanted to help. Learn to express yourself in a better way then, and write your problem so taht everyone can understand it dude. – CTZStef Jun 27 '12 at 18:08
  • "Voting down, also known as "casting downvotes", is how the community indicates which questions and answers are least useful.". You answered a different question, read it before you answer. – Bersaelor Jun 27 '12 at 18:14
  • Very well Bersaelor, very well. I answered to "measure Size of Object on a screen". – CTZStef Jun 27 '12 at 18:16