How to get camera preview sizes natively for Android & desktop
I would like to know how to get the supported camera preview sizes on Android and desktop, possibly uniformly. I'm on a completely native framework (Qt) and would like to do this fully natively if possible. Currently, I'm using VideoCapture to get image data on both platforms but the size is basically guessed.
Does this look like what you're are looking for? QCameraImageCapture::supportedResolutions
Also, two things. Firstly, strictly speaking this question is a question about Qt, and only marginally related to OpenCV - or not at all. Therefore it is somewhat out-of-topic here. Secondly, please do not downvote an answer just because it did not solve your problem. This is especially important if the answer does not contain any bad-will, as it sends an unfriendly message to users of OpenCV forum. If it did not solve your problem, you can simply leave it unvoted and explain your reason, so that it will remain at zero vote. A negative vote should only be used when the answer is unfriendly, or contain misleading or clearly wrong information. In itay's case, it is what I would have suggested as well - to obtain the parameters on the Java side, during application startup.
First, this question is perfectly related to OpenCV: In order to even be able to get the live camera image in a hardware independent manner, you first need the supported preview sizes. As OpenCV provides the mechanism to access the camera (
VideoCapture
), it should provide the mechanism to access the supported preview sizes as well. I shouldn't need Qt or any other platform to obtain this information. See my answer below.Second, I don't believe that downvotes are reserved for "bad behavior" or "clearly wrong information", it also applies to where an answer is obviously found from the first page on Google search results. Honestly, try searching for "android get camera preview sizes"; no one should ask some question here whose answer can be found easily on Google (or whose answer is RTFM). Moreover in this case, the code desired in the question has a nativity priority. The given answer "You can try using android.hardware.Camera parameters like this:" obviously indicates that the answerer did not even properly read the question, let alone considering giving an answer in the case that he/she is not familiar with the meaning of "native".
I think these kinds of answers just clutter the Q&A space and give the impression that this is not a competent community, hence the downvote.
Also, there is a "flag offensive" button in the answers for "unfriendly" behavior.