Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bugfix] VideoCaptureProperties being an int64 does not correctly unpack the parameters for OpenCV VideoCapture.open #1250

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

tnolle
Copy link

@tnolle tnolle commented Nov 6, 2024

This patch changes the type of VideoCaptureProperties to int32. It is currently set to int. This breaks VideoCapture_OpenDeviceWithAPIParams because it doesn't correclty unpack the slice into the std::vector<int> here:

bool VideoCapture_OpenDeviceWithAPIParams(VideoCapture v, int device, int apiPreference, int *paramsv, int paramsc) {
    std::vector< int > params;

    for( int i = 0; i< paramsc; i++) {
        params.push_back(paramsv[i]);
    }

    return v->open(device, apiPreference, params);
}

With int64 this for loop will create only zeros in the value parts of the array that OpenCV expects ([p1, v1, ..., pn, vn]).

Changing it to int32 unpacks the slice correctly and OpenCV will pass the parameters correctly to the respective VideoCapture backends.

This patch changes the type of `VideoCaptureProperties` to `int32`. It is currently set to `int`. This breaks `VideoCapture_OpenDeviceWithAPIParams` because it doesn't correclty unroll the slice into the `std::vector<int>` here:

```c++
bool VideoCapture_OpenDeviceWithAPIParams(VideoCapture v, int device, int apiPreference, int *paramsv, int paramsc) {
    std::vector< int > params;

    for( int i = 0; i< paramsc; i++) {
        params.push_back(paramsv[i]);
    }

    return v->open(device, apiPreference, params);
}
```

With `int64` this for loop will create only zeros in the value parts of the array that OpenCV expects (`[p1, v1, ..., pn, vn]`).

Changing it to `int32` unpacks the slice correctly and OpenCV will pass the parameters correctly to the respective VideoCapture backends.
@tnolle tnolle changed the title Change type of VideoCaptureProperties to int32 [Bugfix] VideoCaptureProperties being an int64 does not correctly unpack the parameters for OpenCV VideoCapture.open Nov 6, 2024
@deadprogram deadprogram changed the base branch from release to dev November 11, 2024 09:45
@deadprogram
Copy link
Member

Hello @tnolle thank you for the pull request. I changed the branch to dev as mentioned here: https://github.com/hybridgroup/gocv/blob/release/CONTRIBUTING.md#how-to-use-our-github-repository

@diegohce can you take a peek at this please?

@tnolle
Copy link
Author

tnolle commented Nov 11, 2024

@deadprogram, oops, you're right. Sorry about that and thanks for changing it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants