Okay guys, I opened this topic here, because I couldn't find any better place to do it. Hope it's not a problem.
The general situation:
Say you have a camera at 320x240. This gives a 4:3 aspect ratio image, ZM works beautifully, image can be seen, it's according to the reality, nothing is distorted.
Now you have another camera, grabbing at 352x288. This is not 4:3 aspect ratio, although it should be. ZM works beautifully, image can be seen, but it's not according to the reality: the picture is narrower than the reality, it looks squished.
The reason:
while at 320x240 the pixels are SQUARE, at 352x288 they are NOT. Actually 320x240 is 1/4 of 640×480, which is the "True" computer square-pixel format (1/1). 352x288 is the format for VCD, DVD, H.261 + H.263 (CIF), having a pixel aspect ratio of 128/117!!
In other words:
320x240 captured images show well, because pixels are square. 352x288 captured images show narrower, because pixels are not square, but wrongly displayed as square in Firefox, on the computer display.
The easiest way to fix this is actually to stretch the images in the viewer (the default case: Firefox), according to the correct aspect ratio of the pixels in that image.
This means:
ZM should know all the supported resolutions of the capturing devices (there aren't many, as the video resolutions are all standardized, and all devices, like capture cards, webcams or network cams conform to these, see below), and when displaying images with the resolutions selected, they must be re-scaled according to their correct pixel aspect ratio. It wouldn't add extra load on the ZM server itself, because everything would work in behind just like now, the viewer application, like the browser, must actually do the stretching of the image, and that can be intelligently achieved from php code. In reality, there's not much work to do: instead of the fields where now one can fill the desired resolution, there should be a drop-down list with the available standard resolutions, and from the resoultion selected, the php code knows how to display the image. No need to use the brand new 'Keep Aspect Ratio' option either, as it is used totally wrong in respect to the standards.
Here is a great documentation on this, that would help in understanding the issue:
A Quick Guide to Digital Video Resolution and Aspect Ratio Conversions
There are listed all the standard resolutions for PAL (named '625-line systems with a 50 Hz field rate') and NTSC (named '525-line systems with a 59.94¹ Hz field rate'). See the table in the document. The column 'pixel aspect ratio (x/y)' has the correction factor that needs to be applied when displaying the images.
Really easy to achieve. Any chances to implement? It would make ZM an application working according to the industry standards.
Square and nonsquare pixels:
A. Square pixels and 4:3 frame aspect ratio
B. Nonsquare pixels and 4:3 frame aspect ratio
C. Nonsquare pixels displayed on a square-pixel monitor
This example illustrates nonsquare pixels form an image with a 4:3 aspect ratio.
An image created with nonsquare pixels is distorted when displayed with square pixels.
Images above show pretty much what happens in ZM, and that is not quite correct.
Try to experiment and see this for yourself:
- place 2 cameras in the same location
- set one to 320x240
- set the other to 352x288 (make sure they don't share the same bt chip, otherwise you won't be able to)
- view them in the montage view, in the browser and see the difference: the second cam's picture is not cropped, but squished.
Other good links on this topic:
http://lurkertech.com/lg/pixelaspect/
http://livedocs.adobe.com/en_US/AfterEf ... -7f3a.html
http://www.microsoft.com/windows/window ... rames.aspx
Video standards, Pixel Aspect Radio in ZM
Video standards, Pixel Aspect Radio in ZM
Last edited by robi on Fri Mar 07, 2008 8:52 am, edited 1 time in total.
v1.25.0 + Ubuntu Linux 12.04 Server
LOL:
Computer Industry Mass Confusion on Pixel Aspect Ratio
We should really take care not to fall into this again
Computer Industry Mass Confusion on Pixel Aspect Ratio
We should really take care not to fall into this again
v1.25.0 + Ubuntu Linux 12.04 Server
- zoneminder
- Site Admin
- Posts: 5215
- Joined: Wed Jul 09, 2003 2:07 pm
- Location: Bristol, UK
- Contact:
I think this issue only really makes any difference when displaying the images. However even if you specify the image size, or resize, to correct for any distortions all that is going to happen is that certain pixels columns are dropped as browsers wouldn't interpolate.
Doing interpolation on capture is just losing information so I don't see the point in that. I have a bunch of 352x288 cameras and I don't notice any distortion so I don't think it's a major issue unless you are going to do any calibration from video images.
Doing interpolation on capture is just losing information so I don't see the point in that. I have a bunch of 352x288 cameras and I don't notice any distortion so I don't think it's a major issue unless you are going to do any calibration from video images.
Phil
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
I have to agree
While it would be ideal to have this i think its well down the todo list.
If you require that id advise developing a viewing app (i could make zm4ms do this i suppose) but dont see the need to be in the main app. Or adjust your card to 320 x 240
While it would be ideal to have this i think its well down the todo list.
If you require that id advise developing a viewing app (i could make zm4ms do this i suppose) but dont see the need to be in the main app. Or adjust your card to 320 x 240
James Wilson
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk