Commit Graph

1138 Commits

Author SHA1 Message Date
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
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
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
Alexander Lyulkov
f280e3cbd9 Fixed bug with the last 4 bytes in MJPEG encoder. 2023-09-05 10:38:19 +03:00
Alexander Alekhin
abda763073 Merge pull request #24150 from DeePingXian:4.x 2023-08-16 22:25:11 +00:00
Alexander Alekhin
27d718b223 Merge pull request #24138 from mshabunin:fix-gst-plugin-camera 2023-08-13 19:47:21 +00:00
DeePingXian
a300e7e945 Adding support for Streamlabs Desktop Virtual Webcam
Streamlabs Desktop has the same issue in https://github.com/opencv/opencv/issues/19746.
This fixes it using https://github.com/opencv/opencv/pull/23460 method.
2023-08-13 16:40:38 +08:00
Alexander Smorkalov
5b41134ee7
Merge pull request #24012 from cudawarpedЖvideocapture_raw_read
`VideoCapture`: remove decoder initialization when demuxing
2023-08-11 11:28:57 +03:00
Alexander Smorkalov
3421b950ce
Merge pull request #24133 from alexlyulkov:al/fixed-msmf-webcam
Fixed bug when MSMF webcamera doesn't start when build with VIDEOIO_PLUGIN_ALL
2023-08-10 11:48:38 +03:00
Maksim Shabunin
53dfd9536a videoio: fix camera opening with GStreamer plugin 2023-08-10 11:39:29 +03:00
Alexander Lyulkov
4a12707103 Fixed bug when MSMF webcamera doesn't start when build with VIDEOIO_PLUGIN_ALL 2023-08-09 18:43:49 +08:00
Alexander Smorkalov
9b5b2540a4
Merge pull request #24086 from Kumataro:fix24081
videoio: doc: add odd width or height limitation for FFMPEG
2023-08-09 09:31:47 +03:00
cudawarped
e4ad7e3778 VideoCapture: remove decoder initialization when CAP_PROP_FORMAT== -1 (rawMode == true) 2023-08-02 16:34:22 +03:00
Maksim Shabunin
9fc83ac544 videoio: fix V4L compilation for older kernels 2023-08-01 14:11:14 +03:00
Maksim Shabunin
e0e537d94e videoio: fixed MSVC warning in test 2023-08-01 14:09:22 +03:00
Kumataro
68968eda8d videoio: doc: add odd width or height limitation for FFMPEG 2023-08-01 18:56:20 +09:00
Alexander Smorkalov
b22c2505a8 Disable warning C5054 in VS 2022 C++20 2023-07-26 09:23:32 +03:00
firebladed
7819ec784b
Merge pull request #18498 from firebladed:patch-1
Add V4L2_PIX_FMT_Y16_BE pixel format #18498

Address #18495
relates to #23944

### 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 other license that is incompatible with OpenCV
- [ ] The PR is proposed to proper branch
- [x] There is reference to 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
- [ ] Test using Melexis MLX90640
2023-07-14 11:31:55 +03:00
Maksim Shabunin
e3c1405254 videoio: fix v4l2 test on older platforms (centos) 2023-07-11 17:05:32 +03:00
Maksim Shabunin
e43bc88fc3 videoio: test for V4L using virtual device 2023-07-07 17:33:33 +03:00
Maksim Shabunin
8931f08362 videoio: fix CAP_IMAGES with non-numbered file 2023-07-06 22:26:53 +03:00
Alexander Smorkalov
8839bd572e
Merge pull request #23815 from LaurentBerger:CAP_IMAGES
Add single image support to VideoCapture
2023-07-04 16:31:29 +03:00
Alexander Smorkalov
c9d8b541fc
Merge pull request #23896 from mshabunin:test-cap-images
videoio: tests for CAP_IMAGES
2023-07-04 16:30:53 +03:00
Maksim Shabunin
1d9c0d3e12 videoio: tests for CAP_IMAGES 2023-07-03 10:33:16 +03:00
Alexander Smorkalov
426b088754 FFmpeg/4.x: update FFmpeg wrapper 2023.6 2023-06-22 13:58:58 +03:00
Alexander Smorkalov
61d48dd0f8
Merge pull request #23540 from cudawarped:add_CAP_PROP_CODEC_FOURCC
`VideoCapture`: change `CAP_PROP_FOURCC` to fix #22876
2023-06-22 12:21:59 +03:00
Alexander Smorkalov
004801f1c5 Merge remote-tracking branch 'origin/3.4' into merge-3.4 2023-06-20 09:56:57 +03:00
unknown
1eaa074a49 remove line 2023-06-16 11:28:11 +02:00
cudawarped
024c836462 cv::VideoCapture: change CAP_PROP_FOURCC to prefer codec_id over codec_tag 2023-06-16 11:56:44 +03:00
unknown
8762c37c22 solve issue 23808 2023-06-15 21:29:18 +02:00
Alexander Smorkalov
cbda161c39 Fixed FPS computation on some videos for FFmpeg backend. 2023-05-26 14:36:13 +03:00
Alexander Smorkalov
c946285a07
Merge pull request #23601 from cudawarped:videocapture_threading
Videoio: FFMpeg remove locks from `VideoCapure/VideoWriter::open()` to fix 20114
2023-05-19 20:33:25 +03:00
cudawarped
99ef35a353 Videoio: FFMpeg remove locks if OPENCV_FFMPEG_IS_THREAD_SAFE==true 2023-05-17 08:20:46 +03:00
Maksim Shabunin
001a2c5195
Merge pull request #23606 from mshabunin:fix-ffmpeg-packet-limit
videoio/FFmpeg: increased packet read attempt limit, allow configuring it

resolves #9455
related #3225

* Use different counters for wrong packets recieved by demuxer and errors from decoder
* Allow modifying these counters via environment variables `OPENCV_FFMPEG_READ_ATTEMPTS`/`OPENCV_FFMPEG_DECODE_ATTEMPTS`
* Added logging when reading breaks at one of error limits

Notes:
* I've been able to reproduce original issue with a video file with 14 total streams (video + audio + subtitles), at some point in the video only packets from the last stream are being sent by the demuxer, thus exceeding our limit. For my specific video total number of packets from wrong stream was about 2700. I've chosen 4096 as default value.
* Default limit of decoding attempts is quite low, because I'm not sure in which cases it can be exceeded (network stream?). I tried to read 8k video from the disk, but it did not cause break at decode point.
2023-05-16 14:31:04 +03:00
vovka643
d6dc91b4d4 Added depricated_backends list. Added new information masseges. It needs to inform user, when he tries to use depricated or not uses backend 2023-05-05 14:22:18 +03:00
kallaballa
a2be9e9fc1 Log a debug message if a capture backend is generally available but isn't capabable of a capture mode. 2023-05-04 19:18:58 +03:00
cudawarped
871f931e95 VideoCapture: apply bitstream filter to all h264/5 raw streams 2023-04-25 13:52:28 +03:00
Alexander Smorkalov
b68aa12572
Merge pull request #23375 from mshabunin:fix-v4l-verify
cmake: fix V4L config verification conflict with OBSENSOR
2023-04-18 13:05:04 +03:00
gottagofaster236
d30830d0a6 Use NV12 instead of YUY2 for OBS Virtual Camera. 2023-04-09 01:56:03 +02:00
gottagofaster236
b4e3359448 Fix OBS Virtual Camera capture. 2023-04-05 08:04:35 +02:00
Alexander Smorkalov
f5fd3e7d65
Merge pull request #23367 from LaurentBerger:msmf_doc
Note for MSMF in doc
2023-03-24 17:16:52 +03:00
Alexander Smorkalov
d3cc507380 Added reference to Media Foundation. 2023-03-23 16:58:22 +03:00
ippei.i
a60408cda5
Merge pull request #23300 from ippei-i:CAP_PROP_AUTO_WB-and-CAP_PROP_WHITE_BALANCE_BLUE_U_support_in_CAP_DSHOW
Support VideoCapture CAP_PROP_AUTO_WB and CV_CAP_PROP_WHITE_BALANCE_BLUE_U for DShow

### Pull Request Readiness Checklist

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

- [OK] I agree to contribute to the project under Apache 2 License.
- [OK] 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
- [OK] The PR is proposed to the proper branch
- [OK] There is a reference to the original bug report and related work
https://github.com/opencv/opencv/issues/19621
https://github.com/opencv/opencv/issues/21408

### Before apply this pull request console output.

before AWB setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 2000
CAP_PROP_AUTO_WB: -1

after AWB disable setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 2000
CAP_PROP_AUTO_WB: -1

after AWB enable setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 2000
CAP_PROP_AUTO_WB: -1

after Manual WB(and Disable AWB) setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 2000
CAP_PROP_AUTO_WB: -1

### After apply this pull request console output.

before AWB setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 2000
CAP_PROP_AUTO_WB: 0

after AWB disable setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 4000
CAP_PROP_AUTO_WB: 0

after AWB enable setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 4000
CAP_PROP_AUTO_WB: 1

after Manual WB(and Disable AWB) setting
CAP_PROP_WHITE_BALANCE_BLUE_U: 2000
CAP_PROP_AUTO_WB: 0

### Test Code
[OpenCvVideoCapTest.zip](https://github.com/opencv/opencv/files/10825399/OpenCvVideoCapTest.zip)
2023-03-21 14:29:24 +03:00
Maksim Shabunin
aef1fc087d cmake: fix V4L config verification conflict with OBSENSOR 2023-03-19 10:58:47 +03:00
unknown
a2e04718ec te for MSMF in doc 2023-03-17 13:36:47 +01:00
Alexander Alekhin
0052d46b8e Merge pull request #23237 from hzcyf:feature/orbbec_femto_mega_support 2023-03-01 07:13:22 +00:00
Alexander Alekhin
bdff0949bb dnn(tflite): add 3rdparty flatbuffers with pre-generated schema 2023-02-21 16:06:19 +00:00
hzcyf
325fe7e663 add support for Orbbec Femto Mega RGB-D camera 2023-02-11 16:22:35 +08:00