Skip to content

C++ cv::VideoCapture.open(0) always return false on Android #11952

@omatrot

Description

@omatrot
System information (version)
  • OpenCV => 3.4.1
  • Operating System macOS High Sierra 10.13.6 / Platform => Android 7.1.1 API 25
  • Compiler => Android NDK
Detailed description
Context

I'm writing a cross platform OpenCV based C++ library. The consuming code is a React Native Application through a react native native module.

To be perfectly clear, there is no access from Java Code to C++ OpenCV on Android. There are events with the result of the OpenCV C++ code sent to Javascript through the react native bridge.

My native library is compiled on Android as a SHARED library. It is dynamically linked to the libopencv_world.so that is produced by the compilation of OpenCV C++ for Android.

What it does

Basically, it opens the device's default camera and take snapshots.

The outcome

This code is then ran on iOS and Android.

This is working perfectly well on iOS.
It fails on Android.

Here is the failing part of C++ code on Adndroid:

Steps to reproduce
// cap is a cv::VideoCapture object    
if (cap.open(0))
        {
            cap.set(cv::CAP_PROP_FRAME_WIDTH, CAM_WIDTH);
            cap.set(cv::CAP_PROP_FRAME_HEIGHT, CAM_HEIGHT);
        }
        else
        {
            reject("false", "cap.open(0) returned false");
        }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions