Repository navigation
Making JavaCamera2View be consistent with JavaCameraView - #13840
Conversation
There values are OpenCV-specific (not mapped into any Android values). How many cameras are available? (check this via debugger breakpoint) |
|
Hi! There were two cameras on testing phones. One on the front and the other on the back. I also confirmed that the two cameras are recognized correctly by using the debugger. The permission was also correctly granted. If I change JavaCamera2View to JavaCameraView, other things kept exactly same, then everything works correctly. But if I change to JavaCamera2View then the error occurs. |
|
What value of "mCameraIndex" is showed by debugger? |
|
|
|
I think I found the cause of the problem.
private CameraBridgeViewBase mOpenCvCameraView;
mOpenCvCameraView.setCameraIndex(0);If I use On the other hand, if I use So it seems the difference between |
There are special OpenCV-specific values for this parameter: Looks like, current implementation of JavaCamera2View supports these values only, without supporting of zero-based device-specific indexes. |
Yes. |
|
I made a new commit. Compared to the previous commit, this new commit makes logic of There are three important final variables:
The logic of
On contrary, the logic of
So in this new commit I added a new step to else { // this corresponds to the last step of JavaCameraView's logic
Log.i(LOGTAG, "Trying to open camera with new open(" + mCameraIndex + ")");
mCameraID = Integer.toString(mCameraIndex);
manager.openCamera(mCameraID, mStateCallback, mBackgroundHandler);
}This new commit makes the logic of |
alalek
left a comment
There was a problem hiding this comment.
Change makes sense.
Please squash commits into one (for example, git rebase -i HEAD~3)
(git history with changes is not needed)
37579ff to
b1d45dd
Compare
|
Added an error-checking block and squashed the commits into one! |
b1d45dd to
6b1185f
Compare
|
The new code (which corresponds to the resolved conversation) is committed and all previous commits are squashed into one. Thanks for the hard work of OpenCV maintainers! |
|
Thank you! This patch should go into 3.4 branch first. We will merge changes from 3.4 into master regularly (weekly/bi-weekly). So, please:
Note: no needs to re-open PR, apply changes "inplace". |
6b1185f to
225bdc2
Compare
|
Hi! I rebased the commit according to your explanation. |
resolves #11325
Bug fix of
Interrupted while setCameraPreviewSizeandwidth and height must be > 0which is related toJavaCamera2ViewThis pullrequest changes
org.opencv.android.JavaCamera2Viewcrashes on certain phones such as Samsung Galaxy S7 and Alcatel A5A. (On contrary,JavaCameraViewworks fine.) It is becauseCameraBridgeViewBase.CAMERA_ID_BACKandCameraBridgeViewBase.CAMERA_ID_FRONTdo not match correct values. This patch introduces two newfinal intvariables to correctly detect cameras.Bug which happens with old code