Skip to content

Camera id problem with multi camera system ( MacOS ) #22901

@calism2

Description

@calism2

System Information

OpenCV version: 4.6.0
Operating System / Platform: MacOS Ventura 13.0.1
Apple clang version 14.0.0 (clang-1400.0.29.202)
Target: arm64-apple-darwin22.1.0

Detailed description

If you try to create two cv::VideoCapture instance, camera indexes swap every run.

Steps to reproduce

Test Code

    cv::VideoCapture cap(0);
    cv::VideoCapture capSecond(1);
    
    if(!cap.isOpened() || !capSecond.isOpened()){ return -1; }
    
   

    cv::Mat frame, frameSecond;
    while( true ){
        cap.read(frame);
        capSecond.read(frameSecond);
        cv::resize(frame, frame, cv::Size(256,256), 0, 0, cv::INTER_LINEAR );
        cv::resize(frameSecond, frameSecond, cv::Size(256,256), 0, 0, cv::INTER_LINEAR );
        cv::imshow(std::string{"Cap 1"}, frame);
        cv::imshow(std::string{"Cap 2"}, frameSecond);
        cv::waitKey(100);
     }

First Run (for every number of odd try )

firstRun1

firstRun

Second Run (for every number of even try )

secondRunCap2

secondRun2

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions