Skip to content

Timeouts support for GStreamer backend#22919

Merged
asmorkalov merged 3 commits intoopencv:4.xfrom
asmorkalov:as/gstreamer_read_timeout
Dec 15, 2022
Merged

Timeouts support for GStreamer backend#22919
asmorkalov merged 3 commits intoopencv:4.xfrom
asmorkalov:as/gstreamer_read_timeout

Conversation

@asmorkalov
Copy link
Copy Markdown
Contributor

@asmorkalov asmorkalov commented Dec 5, 2022

Address #22868
Used the same defaults as it's done for FFmpeg

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
force_builders=Custom
build_image:Custom=gstreamer:16.04
buildworker:Custom=linux-1

@asmorkalov
Copy link
Copy Markdown
Contributor Author

@alalek Could you take a look?

@mshabunin
Copy link
Copy Markdown
Contributor

@asmorkalov , I've added the test to your PR. Also made some cosmetic changes to reduce number of constant being used. And added timeout to the startPipeline method, but I'm not sure about this. Please take a look.

@asmorkalov
Copy link
Copy Markdown
Contributor Author

@mshabunin Thanks a lot for the fix!

return false;

sample.attach(gst_app_sink_pull_sample(GST_APP_SINK(sink.get())));
sample.attach(gst_app_sink_try_pull_sample(GST_APP_SINK(sink.get()), readTimeout));
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a GStreamer version check here.

/build/precommit_custom_linux/4.x/opencv/modules/videoio/src/cap_gstreamer.cpp: In member function 'virtual bool cv::GStreamerCapture::grabFrame()':
/build/precommit_custom_linux/4.x/opencv/modules/videoio/src/cap_gstreamer.cpp:513:85: error: 'gst_app_sink_try_pull_sample' was not declared in this scope
     sample.attach(gst_app_sink_try_pull_sample(GST_APP_SINK(sink.get()), readTimeout));
                                                                                     ^

with probably CV_LOG_ONCE_INFO() message for old versions.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have device with old GSteamer. Will check today and update.

@asmorkalov asmorkalov force-pushed the as/gstreamer_read_timeout branch from 0ac5fc3 to 95ec8c3 Compare December 14, 2022 19:34
@asmorkalov asmorkalov force-pushed the as/gstreamer_read_timeout branch from 95ec8c3 to 6e4c04b Compare December 15, 2022 06:47
@canberkgurel
Copy link
Copy Markdown

@asmorkalov when a read timeout occurs, how can I detect a timeout and handle it gracefully?

Also, what's the expected behavior of cap.read(img);? I ran a test and I can confirm that cap.read didn't return false when I killed the Gstreamer transmitter.

a-sajjad72 pushed a commit to a-sajjad72/opencv that referenced this pull request Mar 30, 2023
…eout

Address opencv#22868
Used the same defaults as it's done for FFmpeg

### 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
- [ ] 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


```
force_builders=Custom
build_image:Custom=gstreamer:16.04
buildworker:Custom=linux-1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants