opencv/modules/python/src2
Yuantao Feng 5510718381
Merge pull request #25810 from fengyuentau:python/fix_parsing_3d_mat_in_dnn
python: attempts to fix 3d mat parsing problem for dnn #25810

Fixes https://github.com/opencv/opencv/issues/25762 https://github.com/opencv/opencv/issues/23242
Relates https://github.com/opencv/opencv/issues/25763 https://github.com/opencv/opencv/issues/19091

Although `cv.Mat` has already been introduced to workaround this problem, people do not know it and it kind of leads to confusion with `numpy.array`. This patch adds a "switch" to turn off the auto multichannel feature when the API is from cv::dnn::Net (more specifically, `setInput`) and the parameter is of type `Mat`. This patch only leads to changes of three places in `pyopencv_generated_types_content.h`:

```.diff
static PyObject* pyopencv_cv_dnn_dnn_Net_setInput(PyObject* self, PyObject* py_args, PyObject* kw)
{
...
- pyopencv_to_safe(pyobj_blob, blob, ArgInfo("blob", 0)) &&
+ pyopencv_to_safe(pyobj_blob, blob, ArgInfo("blob", 8)) &&
...
}

// I guess we also need to change this as one-channel blob is expected for param
static PyObject* pyopencv_cv_dnn_dnn_Net_setParam(PyObject* self, PyObject* py_args, PyObject* kw)
{
...
- pyopencv_to_safe(pyobj_blob, blob, ArgInfo("blob", 0)) )
+ pyopencv_to_safe(pyobj_blob, blob, ArgInfo("blob", 8)) )
...
- pyopencv_to_safe(pyobj_blob, blob, ArgInfo("blob", 0)) )
+ pyopencv_to_safe(pyobj_blob, blob, ArgInfo("blob", 8)) )
...
}
```

Others are unchanged, e.g. `dnn_SegmentationModel` and stuff like that.

### 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
2024-07-04 08:33:20 +03:00
..
typing_stubs_generation Merge pull request #25709 from dkurt:wrap_addLayer 2024-06-07 20:39:44 +03:00
copy_typings_stubs_on_success.py Merge pull request #20370 from ddacw:stub-gen-next 2023-05-26 18:25:46 +03:00
cv2_convert.cpp Merge pull request #25810 from fengyuentau:python/fix_parsing_3d_mat_in_dnn 2024-07-04 08:33:20 +03:00
cv2_convert.hpp Merge pull request #25810 from fengyuentau:python/fix_parsing_3d_mat_in_dnn 2024-07-04 08:33:20 +03:00
cv2_highgui.cpp Merge pull request #21182 from mshabunin:split-cv2cpp 2021-12-05 12:49:36 +00:00
cv2_highgui.hpp Merge pull request #21182 from mshabunin:split-cv2cpp 2021-12-05 12:49:36 +00:00
cv2_numpy.cpp Replace static numpy allocator by function containing static. 2024-04-26 14:38:18 +02:00
cv2_numpy.hpp Replace static numpy allocator by function containing static. 2024-04-26 14:38:18 +02:00
cv2_util.cpp Merge pull request #23736 from seanm:c++11-simplifications 2024-01-19 16:53:08 +03:00
cv2_util.hpp Fixed tests execution with Python 2.7 2023-07-11 18:24:08 +03:00
cv2.cpp Merge pull request #23679 from dkurt:py_cv_type_macro 2023-05-25 15:54:41 +03:00
cv2.hpp Merge pull request #25810 from fengyuentau:python/fix_parsing_3d_mat_in_dnn 2024-07-04 08:33:20 +03:00
gen2.py Merge pull request #25810 from fengyuentau:python/fix_parsing_3d_mat_in_dnn 2024-07-04 08:33:20 +03:00
hdr_parser.py Merge pull request #25810 from fengyuentau:python/fix_parsing_3d_mat_in_dnn 2024-07-04 08:33:20 +03:00
pycompat.hpp Enabled VAS OT in G-API Python interface 2023-12-19 17:51:59 +00:00
typing_stubs_generator.py Merge pull request #23801 from VadimLevin:dev/vlevin/python-stubs-api-refinement 2023-06-21 10:44:36 +03:00