Sunday, January 29, 2017

CCTV BASICS: How Far Can We See with Given Lens

Why you need good quality lens.

Lens. Essential part of every camera. You can buy expensive 12 MPx camera, and mess everything up with poorly chosen lens. It's just like finding right glasses for a human eyes.
If you choose poor quality lens, with not precisely "cut" high quality glass - you will lose important details, and details is the most important thing in surveillance.

Currently more and more people use bullet and dome cameras - with build in lens. But from time to time you will get this picky customer with some special project, so you have to install classic box camera with proper lens. Or choose cheaper camera with specific lenses that can do the job.

Resolution of lens

Not only cameras have resolution. You have to also check resolution of your lens.Why? It's all about sensor and pixel size.

When light hits an object it bounces from it, passes the lens and hits a sensor.

Principle of a pinhole camera. Light rays from an object pass through a small hole to form an image. [1]


 Image sensor looks like "plate with cavities". 
Camera sensor with "pits" where "the light falls in.[2]
Photons (of different color/wave length) fall to those cavities in a sensor, and this how it draws a "pixel" (kind of)/;

Camera cavities. This will produce greyscale image. This is how it looks like when IR CUT filter is off [2]

Cavities with specific color filters. Those are passing only specific wave length/color. [2]

Not so long time we were forced to use analog cameras with OUTSTANDING resolution of 0.35MPx. Just wow. And then problem with lens quality was not so visible. Why? Because those sensor cavities (or holes) where big enough.

A light ray will refract as it enters and leaves glass (lens) so when manufacturer makes lens, he need to make sure, that the light ray from specific point on object will hit specific cavity on a sensor.

If the cavity is big enough, lens quality doesn't matter that much (it still matters, just a lil' bit).

Shitty lens and shitty sensor. Light still falls on huge pixel. 


But if you put low quality lens, on big high resolution sensor, with small pixel size - then you have a problem with details and focus of the image.

Shitty lens on high resolution sensor.

How it looks like in real life? Here is sample image.
First one  - No-name lens, not rated for megapixel cameras.
Second one - Tamron 10-360mm F/1.6 Aspherical Mega Pixel Zoom LENS
Both on DAHUA Starlight camera.
This is what happens when you are trying to save money buy using cheap stuff.

So now you know. Use proper lens for megapixel camera. Even when you are buying bullet camera or dome camera, ask your provider - what kind of lenses they use? If they have nothing to hide, they will provide you this information.

Zoom in or not to zoom in. 

Ok, now you know how to get details. But HOW to choose proper lens for given scene? 
Can I use any megapixel lens on my 4K camera to cover whole yard? 
Not so fast.

You need to know that there are 2 types of lenses - varifocal and fixed. 
Varifocal allows you to "zoom in or out", optically.
Fixed are... well fixed, you can't change angle - zoom level. 

So varifocal are better, right? Well not exactly, let's say you have to install dome camera above entrance to a shop. You want to see everyone that is entering, so you want something like, lets say, 90° angle. You wont change this angle for whole time of using a camera. So why pay extra for lenses that will allow you to change angle from 90° to 10°? Because varifocal lenses are more expensive.

"Zooming factor" is called focal length, and it's measured in mm (millimeter).

Example of a fixed CCTV lenses. 

Example of a varifocal CCTV lenses.

Smaller focal length = wider angle, higher focal length = narrower angle (bigger zoom).

28mm lens [1]

70mm lens [1]



So if you need to monitor something from greater distance, you should choose CCTV lenses with high numbers.
Here is example of a FullHD camera with ultra zoom lens - from 8mm to 250mm. 






You can clearly see the difference of 8mm and 250mm lens angle or zoom ratio.

I want to see EVERYTHING

So how can you calculate what focal length you need? 
For example you need to read licence plates. Gate is 25 meters away.
It's simple math rly. You can use formulas to calculate needed focal length or how far you can see with given lens.

Lets say you want to use some 2.0MPx camera for licence plate recognition. Distance to gate is ~25m (lets call this distance [D]).
Licence plates are something like 0.55m wide [W] and they need to be ~150 pixels [Q] for good recognition picture.

First of all we will calculate width of scene that can be seen by camera [H] with this quality level [Q].

H = horizontal resolution of camera * W/Q

2.0MPx = 1920x1080

H = (1920 * 0.55)/150 = 7.04 m

So 2.0 MPx  camera will provide you about 7 meter wide scene with (minimal) quality allowing plate recognition.

Now check what is image sensor size of your camera.
Let's take for example Dahua HFW5231 bullet camera, 2.0MPx with Sony STARVIS 1/2.8" Sensor.
Sensor model is IMX291 (you should ask your camera provider if you don't know exact model)
According to Sony datasheet of this sensor, it has 1945 x 1097 efective pixels with 2.9 µm pixel size.

IMX291 spec


To calculate sensor size you just have to change pixel size to mm:
2.9um = 0.0029mm 

And than multiply it by effective pixel size.
So width of sensor is 0.0029mm*1945 = ~5.64mm [w]
Height of sensor is 0.0029mm*1097 = ~3.18mm [h]


Now we can calculate focal length:

f = D * w / H 
f = (25m * 5.64mm) / 7.04m = ~20mm 

So you need lens with f>20 mm focal length. So standard bullet with 2.7~12mm lens will be not enough.

INSANE

But, yeah, only insane would calculate everything like this. That's why I prepared this crafty LENS CALCULATOR:

And here is download link: CLICK.

Thanks and have fun! Hope you like this article. Like, share and visit my facebook page. 
www.facebook.com/CCTVnerd

And wait for another episode of CCTV BASICS. Next stop - Aperture of lens. 








[1] https://en.wikipedia.org/wiki/Camera_lens
[2] http://www.cambridgeincolour.com/tutorials/camera-sensors.htm





No comments:

Post a Comment