Commit Graph

33336 Commits

Author SHA1 Message Date
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
Alexander Smorkalov
cca4ee2e46 Revert PR 24186 as it force skip tests. 2023-09-05 14:35:37 +03:00
Alexander Smorkalov
21fb10c6a3
Merge pull request #24209 from alexlyulkov:al/fixed-mjpeg
Fixed bug with the last 4 bytes in MJPEG encoder
2023-09-05 13:45:26 +03:00
Björn Böken
639836ebf0 Added CMake configuration OPENCV_DNN_BACKEND_DEFAULT 2023-09-05 10:05:12 +02:00
Dmitry Kurtaev
6ae7caaa01
Merge pull request #24216 from dkurt:inter_lines_less_compute
Minor optimization of two lines intersection #24216

### Pull Request Readiness Checklist

Not significant, but we can reduce number of multiplications while compute two lines intersection. Both methods are used heavily in their modules.

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
- [ ] 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 10:44:56 +03:00
Alexander Lyulkov
f280e3cbd9 Fixed bug with the last 4 bytes in MJPEG encoder. 2023-09-05 10:38:19 +03:00
Alexander Smorkalov
9eba360eab
Merge pull request #24221 from WanliZhong:issue_24016
Increase the test threshold of FastRCNN_vgg166 and FastRCNN_zf when FAST_MATH enable
2023-09-05 10:20:43 +03:00
Wanli
84f32bbb24 increase Fast Math threshold 2023-09-05 14:03:54 +08:00
Philipp Schrader
c91c631ae2 Fix "use after free" issue in essential_solver.cpp
The address sanitizer highlighted this issue in our code base. It
looks like the code is currently grabbing a pointer to a temporary
object and then performing operations on it.

I printed some information right before the asan crash:

    eigensolver address: 0x7f0ad95032f0
    eigensolver size: 4528
    eig_vecs_ ptr: 0x7f0ad95045e0
    eig_vecs_ offset: 4848

This shows that `eig_vecs_` points past the end of `eigensolver`. In
other words, it points at the temporary object created by the
`eigensolver.eigenvectors()` call.

Compare the docs for `.eigenvalues()`:
https://eigen.tuxfamily.org/dox/classEigen_1_1EigenSolver.html#a0f507ad7ab14797882f474ca8f2773e7
to the docs for `.eigenvectors()`:
https://eigen.tuxfamily.org/dox/classEigen_1_1EigenSolver.html#a66288022802172e3ee059283b26201d7

The difference in return types is interesting. `.eigenvalues()`
returns a reference. But `.eigenvectors()` returns a matrix.

This patch here fixes the problem by saving the temporary object and
then grabbing a pointer into it.

This is a curated snippet of the original asan failure:

    ==12==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7fc633704640 at pc 0x7fc64f7f1593 bp 0x7ffe8875fc90 sp 0x7ffe8875fc88
    READ of size 8 at 0x7fc633704640 thread T0
        #0 0x7fc64f7f1592 in cv::usac::EssentialMinimalSolverStewenius5ptsImpl::estimate(std::__1::vector<int, std::__1::allocator<int> > const&, std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >&) const /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/usac/essential_solver.cpp:181:48
        #1 0x7fc64f915d92 in cv::usac::EssentialEstimatorImpl::estimateModels(std::__1::vector<int, std::__1::allocator<int> > const&, std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >&) const /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/usac/estimator.cpp:110:46
        #2 0x7fc64fa74fb0 in cv::usac::Ransac::run(cv::Ptr<cv::usac::RansacOutput>&) /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/usac/ransac_solvers.cpp:152:58
        #3 0x7fc64fa6cd8e in cv::usac::run(cv::Ptr<cv::usac::Model const> const&, cv::_InputArray const&, cv::_InputArray const&, int, cv::Ptr<cv::usac::RansacOutput>&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&) /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/usac/ransac_solvers.cpp:1010:16
        #4 0x7fc64fa6fb46 in cv::usac::findEssentialMat(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, int, double, double, cv::_OutputArray const&) /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/usac/ransac_solvers.cpp:527:9
        #5 0x7fc64f3b5522 in cv::findEssentialMat(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, int, double, double, int, cv::_OutputArray const&) /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/five-point.cpp:437:16
        #6 0x7fc64f3b7e00 in cv::findEssentialMat(cv::_InputArray const&, cv::_InputArray const&, cv::_InputArray const&, int, double, double, cv::_OutputArray const&) /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/five-point.cpp:486:12
        ...

    Address 0x7fc633704640 is located in stack of thread T0 at offset 17984 in frame
        #0 0x7fc64f7ed4ff in cv::usac::EssentialMinimalSolverStewenius5ptsImpl::estimate(std::__1::vector<int, std::__1::allocator<int> > const&, std::__1::vector<cv::Mat, std::__1::allocator<cv::Mat> >&) const /proc/self/cwd/external/com_github_opencv_opencv/modules/calib3d/src/usac/essential_solver.cpp:36

      This frame has 63 object(s):
        [32, 56) 'coefficients' (line 38)
        [96, 384) 'ee' (line 55)
        ...
        [13040, 17568) 'eigensolver' (line 142)
        [17824, 17840) 'ref.tmp518' (line 143)
        [17856, 17872) 'ref.tmp523' (line 144)
        [17888, 19488) 'ref.tmp524' (line 144) <== Memory access at offset 17984 is inside this variable
        [19616, 19640) 'ref.tmp532' (line 169)
        ...

The crash report says that we're accessing a temporary object from
line 144 when we shouldn't be. Line 144 looks like this:
https://github.com/opencv/opencv/blob/4.6.0/modules/calib3d/src/usac/essential_solver.cpp#L144

    const auto * const eig_vecs_ = (double *) eigensolver.eigenvectors().real().data();

We are using version 4.6.0 for this, but the problem is present on the
4.x branch.

Note that I am dropping the .real() call here. I think that is safe because
of the code further down (line 277 in the most recent version):

    const int eig_i = 20 * i + 12; // eigen stores imaginary values too

The code appears to expect to have to skip doubles for the imaginary parts
of the complex numbers.

Admittedly, I couldn't find a test case that exercised this code path to
validate correctness.
2023-09-04 11:10:05 -07:00
Alex
ca527040e2 fix refineDetectedMarkers, add test 2023-09-04 18:28:28 +03:00
alexander-varjo
114c23e411
Merge pull request #23607 from alexander-varjo:alexander-varjo-patch-1
Fix crash in ap3p #23607

### 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
- [x] The PR is proposed to the proper branch
- [ ] 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-04 17:49:45 +03:00
Alexander Smorkalov
748279d5f1
Merge pull request #23904 from kai-waang:removing-unreachable
removing unreachable codes in `gbackend`
2023-09-04 17:06:45 +03:00
Alexander Smorkalov
e274e72869
Merge pull request #24098 from 0xMihir:4.x
Fix fullscreen behavior for macOS
2023-09-04 16:48:04 +03:00
Alexander Smorkalov
4dd755443a
Merge pull request #24215 from Kumataro:fix24213
core: arm64: v_round() works with round to nearest, ties to even.
2023-09-04 12:51:02 +03:00
Dmitry Matveev
d19fc1264b
Merge pull request #24178 from dmatveev:dm/streaming_queue
G-API: Introduce a Queue Source #24178

- Added a new IStreamSource class: in fact, a wrapper over a concurrent queue;
- Added minimal example on how it can be used;
- Extended IStreamSource with optional "halt" interface to break the blocking calls in the emitter threads when required to stop.
- Introduced a QueueInput class which allows to pass the whole graph's input vector at once. In fact it is a thin wrapper atop of individual Queue Sources.

There is a hidden trap found with our type system as described in https://github.com/orgs/g-api-org/discussions/2

While it works even in this form, it should be addressed somewhere in the 5.0 timeframe.

### 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
- [ ] 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-04 12:48:53 +03:00
Alexander Smorkalov
d3bccd7b23
Merge pull request #24199 from Kumataro:fixlibTiffSite
imgcodecs: fix libtiff URL in opencv source code
2023-09-04 10:54:43 +03:00
Kumataro
72bb8bb73c core: arm64: v_round() works with round to nearest, ties to even. 2023-09-04 10:27:55 +03:00
Alexander Smorkalov
c53b3c5f84
Merge pull request #24203 from thesamesam:arm64-fp16
Fix compilation on arm64 with FP16 when disabled
2023-09-04 09:32:46 +03:00