Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RTSPCameraAgent: connection robustness #816

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

davidvng
Copy link
Contributor

Description

  • Move connection to camera stream to its own function
  • Continue loop instead of stopping acq process when snapshot fails
  • Add connected to session.data and OCS feed

Motivation and Context

Resolves #809

How Has This Been Tested?

Tested on daq-dev

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Copy link
Member

@BrianJKoopman BrianJKoopman left a comment

Choose a reason for hiding this comment

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

Thanks for this! There's one bug with the connected status, but otherwise looks good.

cap = cv2.VideoCapture(self.connection)
if not cap.isOpened():
self.log.error(f"Cannot open RTSP stream at {self.connection}")
return False, "Could not open RTSP stream"
Copy link
Member

Choose a reason for hiding this comment

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

This is returning a tuple if cap doesn't open, which results in not cap: evaluating to False down on line 226, so this will always result in connected = True. It made sense to return this tuple within the process, since that's what ocs needs, but now that it's moved best to just return None, that will evaluate the connected check correctly.

>>> cap = False, "Could not open RTSP stream"
>>> connected = True
>>> if not cap:
...     connected = False
...
>>> print(connected)
True

return False, "Cannot connect to camera"
cap = self._init_stream()
if not cap:
return False
Copy link
Member

Choose a reason for hiding this comment

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

return False -> return False, "Cannot connect to camera"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RTSP Agent: Error while decoding stream
2 participants