# Deciding megapixels and sensorsize needed...?

One of my project contains 6mm defect size.How i will decide that certain megapixel of camera will be able to detect it.

Prashant007
2018-06-02 10:02:11 UTC
report abuse

One of my project contains 6mm defect size.How i will decide that certain megapixel of camera will be able to detect it.

Hi,

you should start with a simple formula:

`Resolution = (Object Size) / (Size of the detail to be inspected)`

Size of the detail to be inspected is 6mm in your case. Object size is the FOV (Field of view), that is the size of the whole area, your camera is looking at. Let's say, you want to detect a 6mm defect within an area of 600mm x 600mm:

Resolution = 600mm / 6mm = 100pixels

This is the minimum resolution needed (in **both directions**). Since sensors normally are rectangular, rather than quadratic, the 100 pixels are the needed **minimum sensor height**.

**BUT, this is only half of the truth.** According to the **Nyquist-Shannon sampling theorem**, at least twice the frequency is required.

In our case twice the frequency means twice the number of pixels, so our formula becomes:

`Resolution = (Object Size) / (Size of the detail to be inspected) * (Nyquist Factor)`

The Nyquist Factor normally is 2 (according to the sampling theorem).

This is true for monochrome sensors! If you use a color sensor with bayer pattern, you'll need to de-bayer (interpolate) the raw image in order to get a full RGB image. This interpolation reduces your optical resolution. So for bayer sensors, you need to further increase the Nyquist Factor. Typical values are 3 or even 4.

Next you can use the Basler Lens Selector in order to find a suitable lens:

https://www.baslerweb.com/en/products/tools/lens-selector/

Select a camera that matches your resolution in pixels, enter width or height of your FOV, enter the distance between camera and object, click into the focal length field and you will get a focal length value.

Comments

Thankyou,

Can you elaborate it with an example like..

If in our case FOV>60 degree

working distance : 30 cm

frame rate 15 fps or greater

and defect size=6mm

Then how i could select the camera...?

You have mixed up Field of View with Angle of View (sometimes called Angular Field Of View). In order to calculate the needed resolution, we need the FOV (at least width OR height). But we can approximate:

`Horizontal FOV [mm] = 2 x Working Distance [mm] x tan(Angle of View [°] / 2)`

In your case HFOV = 2 x 300 mm x tan (60° / 2) = 346 mm (HFOV = Horizontal Field of View (Object Width)).

Resolution = 346 mm / 6 mm * 2 (Nyquist) = 116 pixels.

So, you can use any sensor, that has at least a sensor height of 116 pixels.

Let's say, the lowest resolution we can get a camera for is a VGA sensor (640 x 480).

Next, we decide which interface we want to use...let's say USB 3.0.

Using the Basler Area Scan Camera Selector, setting the filter to:

Resolution: VGA, Interface: USB 3.0, Mono/Color: Mono

That gives us 4 results, so let's choose the acA640-750um.

Back in the Lens Selector, we select the acA640-750um and we enter the distance (300mm) and the horizontal angle (60°).

Result: Focal Length = 2.66 mm, Object Width = 343 mm

Now, we click "Show matching lenses" and we get 1/3", 1/2.5" and 2/3" lenses listed.

Our camera sensor is 1/4" so our lens must be >= 1/4" in order to avoid vignetting.

1/3" is perfect. However, there are only s-mount lenses listed for 1/3" but we need c-mount for the ace and furthermore, we won't find a c-mount lens with Focal Length < f4mm... bad choice!

The acA640-90um was listed as well and it has a bigger sensor, so we will hopefully end up with a higher Focal Length.

In the lens selector, we select the acA640-90um, we enter a Focal Length of 4mm (since this is the lowest we get for c-mount) and we enter the distance of 300mm. This results in a AFOV of 62.8° and a FOV width of 361 mm. "Show matching lenses" gives us a Basler Lens C125-0418-5M F1.8 f4mm (1/2.5" which is bigger than 1/3" sensor size, so it will fit without vignetting).

Let's calculate backwards:

```
Width needed [pix] = (Object Width [mm] / Defect Width [mm]) * Nyquist Factor
Defect Width [mm] = (Nyquist Factor / Sensor Width [pix]) * Object Width [mm]
```

The acA640-90um has a sensor width of 659 pix.

**Defect Width = (2 / 659 pix) * 361 mm = 1.1 mm**

So, with this setup you will be able to detect defects >= 1.1 mm...

Comments

Thankyou bro

Just drop us an email to ... Show more