mercredi 4 mars 2015

Correct way to determine the size of the camera's preview that maintains aspect ratio


I have noticed that the majority of algorithms out there will query getSupportedPreviewSizes() from the camera parameters object, calculate the sizes ratio (w/h) and determine the difference of that ratio and the ratio of the screen's resolution and return the value size that has the lowest difference.


This approach does not return the best option - it just returns the option that is not the worst option which is obviously not ideal. I have an entire StackOverflow question with more details of what I am trying to achieve.


http://ift.tt/17R0Y9V


Any help in understanding how to achieve this without using the "close enough" approach would be great.


Specifically I am looking for a way to programmtically determine why the options that are the best are actually the best.



720.0/1184.0 = 0.6081081081081081

Res Ratio Delta in ratios Result
----------------------------------------------------
176/144 = 1.22222222222 (0.614114114114) (vertically stretched)
352/288 = 1.22222222222 (0.614114114114) (vertically stretched)
320/240 = 1.33333333333 (0.725225225225) (vertically stretched)
640/480 = 1.33333333333 (0.725225225225) (vertically stretched)
720/480 = 1.5 (0.891891891892) (vertically stretched)
800/480 = 1.66666666667 (1.05855855856) (looks good)
640/360 = 1.77777777778 (1.16966966967) (horizontally squashed)
1280/720 = 1.77777777778 (1.16966966967) (slight horizontal squash)
1920/1080 = 1.77777777778 (1.16966966967) (slight horizontal squash)


For example - in the above results the "close enough" wouldn't return the values that look the best - I'm looking for an understanding in why the 800x400 resolution is the option that looks the best when displayed in a view that is 720x1184.





Aucun commentaire:

Enregistrer un commentaire