hybridgroup / gocv

Go package for computer vision using OpenCV 4 and beyond. Includes support for DNN, CUDA, OpenCV Contrib, and OpenVINO.
https://gocv.io
Other
6.73k stars 868 forks source link

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

Closed tnolle closed 3 days ago

tnolle commented 2 weeks ago

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.

deadprogram commented 1 week ago

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 commented 1 week ago

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