Commit Graph

33354 Commits

Author SHA1 Message Date
Kuan-Wei Chiu
e16ca08b33 Fix memory leak and handle realloc failure
In the previous code, there was a memory leak issue where the
previously allocated memory was not freed upon a failed realloc
operation. This commit addresses the problem by releasing the old
memory before setting the pointer to NULL in case of a realloc failure.
This ensures that memory is properly managed and avoids potential
memory leaks.
2023-09-18 22:43:44 +08:00
Alexander Smorkalov
157b0e7760
Merge pull request #24275 from alexlyulkov:al/fix-tf-graph-simplifier
Fixed removePhaseSwitches in tf_graph_simplifier
2023-09-18 11:02:44 +03:00
Alexander Smorkalov
0a53afe8ba
Merge pull request #24278 from georgthegreat:compat-fixes
More fixes for iterators-are-pointers case
2023-09-18 10:47:53 +03:00
Dmitry Kurtaev
6bc369fc56
Merge pull request #24250 from dkurt:ts_fixture_constructor_skip_2
Skip test on SkipTestException at fixture's constructor (version 2) #24250

### Pull Request Readiness Checklist

Another version of https://github.com/opencv/opencv/pull/24186 (reverted by https://github.com/opencv/opencv/pull/24223). Current implementation cannot handle skip exception at `static void SetUpTestCase` but works on `virtual void SetUp`.

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
2023-09-18 10:23:24 +03:00
Vincent Rabaud
687fc11626
Merge pull request #24274 from vrabaud:webp_1.3.2
Merge pull request #24274 from vrabaud:webp_1.3.2
 
Bump libwebp to 1.3.2 #24274

This is version [c1ffd9a](c1ffd9ac75)
It is 1.3.2 with a few patches that were made right after to help compilation.
No need for patches on the OpenCV side!

### 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
2023-09-15 14:25:49 +03:00
Yuriy Chernyshov
638c575c73 More fixes for iterators-are-pointers case 2023-09-15 12:37:43 +03:00
Alexander Lyulkov
d4cb564ce2 Fixed removePhaseSwitches in tf_graph_simplifier 2023-09-15 14:22:21 +07:00
HAN Liutong
5e9191558d
Merge pull request #24058 from hanliutong:rewrite-imgporc
Rewrite Universal Intrinsic code by using new API: ImgProc module. #24058

The goal of this series of PRs is to modify the SIMD code blocks guarded by CV_SIMD macro in the `opencv/modules/imgproc` folder: rewrite them by using the new Universal Intrinsic API. 

For easier review, this PR includes a part of the rewritten code, and another part will be brought in the next PR (coming soon). I tested this patch on RVV (QEMU) and AVX devices, `opencv_test_imgproc` is passed.

The patch is partially auto-generated by using the [rewriter](https://github.com/hanliutong/rewriter), related PR https://github.com/opencv/opencv/pull/23885 and https://github.com/opencv/opencv/pull/23980.



### Pull Request Readiness Checklist

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

- [ ] I agree to contribute to the project under Apache 2 License.
- [ ] 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
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [ ] The feature is well documented and sample code can be built with the project CMake
2023-09-14 20:37:46 +03:00
Alexander Smorkalov
515f119a59
Merge pull request #24270 from dkurt:fix_24256
Higher threshold for FasterRCNN_vgg16
2023-09-14 15:58:23 +03:00
Vincent Rabaud
3880d059b3
Merge pull request #24260 from vrabaud:ubsan
Fix undefined behavior arithmetic in copyMakeBorder and adjustROI. #24260

This is due to the undefined: negative int multiplied by size_t pointer increment.

To test, compile with:
```
mkdir build
cd build
cmake ../ -DCMAKE_C_FLAGS_INIT="-fsanitize=undefined" -DCMAKE_CXX_FLAGS_INIT="-fsanitize=undefined" -DCMAKE_C_COMPILER="/usr/bin/clang" -DCMAKE_CXX_COMPILER="/usr/bin/clang++" -DCMAKE_SHARED_LINKER_FLAGS="-fsanitize=undefined -lubsan"
```
And run:
```
make -j opencv_test_core && ./bin/opencv_test_core --gtest_filter=*UndefinedBehavior*
```

### 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
2023-09-14 15:16:28 +03:00
Alexander Smorkalov
ec1c0608bc
Merge pull request #24131 from cudawarped:cuda_add_default_ptx
`cuda`: update default PTX behaviour when `CUDA_ARCH_BIN` is unset
2023-09-14 15:00:34 +03:00
Alexander Smorkalov
fa81936a5b
Merge pull request #24269 from FlyinTeller:patch-1
Update OpenCVFindOpenBLAS.cmake to accomodate alternative lib name
2023-09-14 14:17:22 +03:00
Dmitry Kurtaev
c5edd20354 Higher threshold for FasterRCNN_vgg16 2023-09-14 13:11:53 +03:00
alexlyulkov
1e54e56579
Merge pull request #24266 from alexlyulkov:al/tf-argmax-default-dim
Added default dimension value to tensorflow ArgMax and ArgMin layers #24266

Added default dimension value to tensorflow ArgMax and ArgMin layers.
Added exception when accessing layer's input with out of range index.
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48452
2023-09-14 10:25:24 +03:00
FlyinTeller
347a1e2913
Update OpenCVFindOpenBLAS.cmake to accomodate alternative lib name
openBLAS windows release calls their library libopenblas which was not recognized before. see #24268
2023-09-14 09:04:41 +02:00
Alexander Smorkalov
4790a3732e
Merge pull request #24263 from georgthegreat:msan-include
Add missing sanitizer interface include
2023-09-13 14:50:59 +03:00
Yuriy Chernyshov
eb20bb3b23 Add missing sanitizer interface include 2023-09-13 12:15:34 +03:00
Alexander Smorkalov
97614920ef
Merge pull request #24247 from AleksandrPanov:fix_drawDetectedCornersCharuco_type_error
fix type cast in drawDetectedMarkers, drawDetectedCornersCharuco, drawDetectedDiamonds
2023-09-12 17:38:44 +03:00
Alex
ae1d1b6d55 fix drawDetectedCornersCharuco, drawDetectedMarkers, drawDetectedDiamonds added tests 2023-09-12 12:17:57 +03:00
Alexander Smorkalov
6694d87a23
Merge pull request #24239 from asmorkalov:as/msmf_returned_fourcc
More strict test for MSMF FOURCC (camera)
2023-09-11 11:00:54 +03:00
Alexander Smorkalov
ee867ead1d
Merge pull request #24248 from opencv-pushbot:gitee/alalek/issue_22751
JavaScript: include LUT support
2023-09-11 08:59:02 +03:00
Alexander Smorkalov
62c0556c58
Merge pull request #24252 from opencv-pushbot:gitee/alalek/refactor_24218
cmake: revise OPENCV_DNN_BACKEND_DEFAULT integration
2023-09-11 08:55:19 +03:00
Alexander Alekhin
02525abd9f cmake: revise OPENCV_DNN_BACKEND_DEFAULT integration
- disable message on default value
2023-09-10 13:11:36 +00:00
Alexander Alekhin
c552e9eede Merge pull request #24251 from dkurt:ov_build_debug 2023-09-10 12:58:31 +00:00
Dmitry Kurtaev
5dc5b27858 Enable build with OpenVINO in Debug 2023-09-09 20:38:59 +03:00
Alexander Alekhin
c319735d9b js: include LUT support 2023-09-09 03:31:39 +00:00
Alexander Smorkalov
1a8d37d19e
Merge pull request #24245 from alexlyulkov/al/update-fast-neural-style-dnn-sample
Replaced torch7 model by ONNX model in fast-neural-style dnn sample
2023-09-08 16:33:18 +03:00
alexlyulkov
91cf0d1843
Merge pull request #24244 from alexlyulkov:al/update-dnn-js-face-recognition-sample
Replaced torch7 by onnx model in js_face_recognition dnn sample #24244

Changed face recognition model in js_face_recognition dnn sample: replaced torch7 model from https://github.com/pyannote/pyannote-data by ONNX model from https://github.com/opencv/opencv_zoo/tree/main/models/face_recognition_sface
2023-09-08 15:36:01 +03:00
Alexander Lyulkov
910db5c9b7 changed readNetFromONNX to readNet 2023-09-08 18:36:13 +07:00
Alexander Smorkalov
e60825e75b
Merge pull request #24218 from CSBVision:patch-5
Added CMake configuration OPENCV_DNN_BACKEND_DEFAULT
2023-09-08 14:21:39 +03:00
Alexander Smorkalov
5a042af7e3
Merge pull request #24246 from asmorkalov:as/merge_input_check2
Check that cv::merge input matrices are not empty
2023-09-08 13:41:43 +03:00
Alexander Smorkalov
0367a12b92 Check that cv::merge input matrices are not empty. 2023-09-08 12:36:46 +03:00
Alexander Smorkalov
757d296382
Merge pull request #24228 from AleksandrPanov:fix_extendDictionary
fix extendDictionary
2023-09-08 11:01:43 +03:00
Alexander Lyulkov
ceeb01dce5 Replaced torch7 by onnx model in fast-neural-style dnn sample 2023-09-08 12:44:22 +07:00
Alex
e5ff41ec9b fixes extendDictionary, add test 2023-09-07 16:01:51 +03:00
jason_w
e8f94182f5
Merge pull request #24180 from MambaWong:4.x
Fixed the channels when capturing yuv422 with v4l2 backend #24180

example to reproduce the problem
```cpp
#include <iostream>

#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>

using namespace cv;
using namespace std;

void help_func(VideoCapture& cap) {
  int height      = cap.get(cv::CAP_PROP_FRAME_HEIGHT);
  int width       = cap.get(cv::CAP_PROP_FRAME_WIDTH);
  int pixel_type  = cap.get(cv::CAP_PROP_FORMAT);
  int channels    = CV_MAT_CN(pixel_type);
  int pixel_bytes = CV_ELEM_SIZE(pixel_type);
  bool to_bgr     = static_cast<bool>(cap.get(cv::CAP_PROP_CONVERT_RGB));

  std::cout << "backend: " << cap.getBackendName() << std::endl;
  std::cout << std::hex << "fourcc: " << static_cast<int>(cap.get(cv::CAP_PROP_FOURCC)) << std::endl;
  std::cout << std::boolalpha << "to_bgr: " << to_bgr << std::endl;
  std::cout << std::dec << "height: " << height << " width: " << width << " channels: " << channels
            << " pixel_bytes: " << pixel_bytes << std::endl;

  std::cout << "-----------------------------------------" << std::endl;
}

int main(int, char**) {

  VideoCapture cap;
  cap.open("/dev/video0");
  if (!cap.isOpened()) {
    cerr << "ERROR! Unable to open camera\n";
    return -1;
  }

  {
    help_func(cap);
  }

  {
    cap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
    cap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
    cap.set(cv::CAP_PROP_CONVERT_RGB, 0);
    help_func(cap);
  }

  // {
  //   cap.set(cv::CAP_PROP_CONVERT_RGB, 0);
  //   cap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);
  //   cap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);
  //   help_func(cap);
  // }

  Mat frame;
  int frame_idx = 0;
  while (cap.read(frame)) {
    std::cout << "frame index: " << frame_idx++ << std::endl;
    help_func(cap);
    if (frame.empty()) {
      cerr << "ERROR! blank frame grabbed\n";
      break;
    }
    Mat bgr;
    if (cap.get(cv::CAP_PROP_CONVERT_RGB)) {
      bgr = frame;
    } else {
      cv::cvtColor(frame, bgr, cv::COLOR_YUV2BGR_YUYV);
    }

    imshow("frame", bgr);
    if (waitKey(5) >= 0) {
      break;
    }
  }

  return 0;
}
```
The above code will get the wrong channels. By changing lines 41-45 like below, can get the correct channels.
<img width="747" alt="code" src="https://github.com/opencv/opencv/assets/16932438/55f44463-8465-4dba-a979-e71a50d58008">
This is because `cap.set(cv::CAP_PROP_FRAME_HEIGHT, 1080);` and `cap.set(cv::CAP_PROP_FRAME_WIDTH, 1920);` reinitialize the `frame`, but `cap.set(cv::CAP_PROP_CONVERT_RGB, 0);` not.
Log info.
<img width="691" alt="log" src="https://github.com/opencv/opencv/assets/16932438/236e3b26-f5b2-447a-b202-bcd607c71af6">
We can also observe that we get the correct channels in the while loop. This is because:
ca0bd70cde/modules/videoio/src/cap_v4l.cpp (L2309-L2310)
reinitialize the `frame`.
2023-09-07 15:47:00 +03:00
Alexander Smorkalov
5c9f58e124 More strict test for MSMF FOURCC (camera). 2023-09-07 13:16:20 +03:00
beanjoy
d0de575aef
Merge pull request #24142 from beanjoy:4.x
Modify the outputVideoFormat after changing the output format in MSMF backend #24142

After changing the output format, need to modify the outputVideoFormat, otherwise the outputVideoFormat is always CV_CAP_MODE_BGR, and an error will occur when converting the format in retrieveVideoFrame(), and will always enter "case CV_CAP_MODE_BGR:" process.

### Pull Request Readiness Checklist

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

- [ ] I agree to contribute to the project under Apache 2 License.
- [ ] 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
- [ ] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [ ] 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

Co-authored-by: 李龙 <lilong@sobey.com>
2023-09-07 13:06:39 +03:00
Alexander Smorkalov
1ebea1e0f0
Merge pull request #24232 from georgthegreat:missing-qualifiers
Add missing std namespace qualifiers
2023-09-06 17:50:51 +03:00
Alexander Smorkalov
5350fba319
Merge pull request #24128 from CSBVision:CSBVision-patch-1
Fix bug at blobFromImagesWithParams
2023-09-06 16:20:37 +03:00
Yuriy Chernyshov
8a415c881a Add missing std namespace qualifiers 2023-09-06 13:46:39 +03:00
CSBVision
674c618471 Update dnn_utils.cpp 2023-09-06 10:01:07 +03:00
Alexander Smorkalov
f64738218a
Merge pull request #24227 from georgthegreat:missing-includes
Add missing <sstream> includes
2023-09-06 09:16:57 +03:00
Yuriy Chernyshov
494d201fda Add missing <sstream> includes 2023-09-05 22:04:26 +03:00
Alexander Smorkalov
91808e64a1
Merge pull request #24211 from philsc:fix-asan-crash
Fix "use after free" issue in `essential_solver.cpp`
2023-09-05 18:42:58 +03:00
Dmitry Kurtaev
178fdbbda8
Merge pull request #24196 from dkurt:ov_backend_cleanups
Use ngraph::Output in OpenVINO backend wrapper #24196

### Pull Request Readiness Checklist

resolves https://github.com/opencv/opencv/issues/24102

* Use `ngraph::Output<ngraph::Node>>` insead of `std::shared_ptr<ngraph::Node>` as a backend wrapper. It lets access to multi-output nodes: 588ddf1b18/modules/dnn/src/net_openvino.cpp (L501-L504)
* All layers can be customizable with OpenVINO >= 2022.1. nGraph reference code used for default layer implementation does not required CPU plugin also (might be tested by commenting CPU plugin at `/opt/intel/openvino/runtime/lib/intel64/plugins.xml`).
* Correct inference if only intermediate blobs requested.


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
2023-09-05 18:08:28 +03:00
Yuriy Chernyshov
2c53e3f53d
Merge pull request #24204 from georgthegreat:mser-license
Properly preserve chi_table license as mandated by BSD-3-Clause #24204

Amend reference to online hosted file with the full license quotation as mandated by the original license.
2023-09-05 17:05:47 +03:00
Alexander Smorkalov
af9be78ead
Merge pull request #24223 from asmorkalov:as/24186_revert
Revert PR 24186 as it forces skipping tests
2023-09-05 16:35:46 +03:00
Alexander Smorkalov
c9d70d46b1
Merge pull request #24139 from AleksandrPanov:fix_refineDetectedMarkers
fix refineDetectedMarkers
2023-09-05 15:24:57 +03:00
Dmitry Kurtaev
c4c2e2e796
Merge pull request #24214 from dkurt:distanceTransform_big_step
Fix distanceTransform for inputs with large step and height #24214

### Pull Request Readiness Checklist

resolves https://github.com/opencv/opencv/issues/23895

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
2023-09-05 15:21:10 +03:00