Files
opencv-MIRROR/modules/python/test
Prasad Ayush Kumar e62a7038d5 Merge pull request #29767 from Prasadayus:fix/int32_output
python: fix int32 output arrays on Windows by mapping 32-bit NPY_LONG - #29767

On Windows numpy spells `int32` as C `long`, so such arrays arrive as `NPY_LONG` (typenum 7) instead of `NPY_INT` (5). `numpyTypeToCvDepth()` has no case for it, so `pyopencv_to()` takes the cast-and-copy path — which is rejected for **output** arguments, even though the data is already bit-identical to `CV_32S`:

```python
cv.watershed(img, np.int32(markers))
```

```
cv2.error: (-5:Bad argument) in function 'watershed'
> Overload resolution failed:
>  - Layout of the output array markers is incompatible with cv::Mat
```

Three tests fail on Windows for this reason, all on an int32 output argument (`markers`, `detectedIds`):

- `test_watershed`
- `test_aruco_detector_refine`
- `test_charuco_refine`

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [x] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-09-01 11:32:39 +03:00
..
2019-05-18 19:32:23 +00:00
2026-02-14 15:37:33 +03:00
2026-02-20 22:05:35 +03:00
2025-03-05 10:28:32 +03:00