Problem Capturing V...
 
Notifications
Clear all

Problem Capturing Video on Docker Container with input.visual Node

5 Posts
2 Users
0 Likes
43 Views
SageofAge
Posts: 5
Member
Topic starter
(@sageofage)
Active Member
Joined: 3 weeks ago

Hi all,

I am running the PeekingDuck pipeline from my Python Flask Application, and when I run it locally with source=0 for the input.visual node, it is able to capture video data as the backend is running on my computer, and it can access my computer's webcam.

 

However, when I deploy the application onto a Docker Container so that I will be able to deploy it to the cloud for the final working product in the future, an error occurs as PeekingDuck, or rather OpenCV is unable to recognise that there are any cameras on my container.

This is the error I am getting:

[ WARN:1@155.258] global cap_v4l.cpp:982 open VIDEOIO(V4L2:/dev/video0): can't open camera by index
[ERROR:1@155.259] global obsensor_uvc_stream_channel.cpp:156 getStreamChannelGroup Camera index out of range
2023-01-18 15:15:41 werkzeug INFO: 172.17.0.1 - - [18/Jan/2023 15:15:41] "GET /start HTTP/1.1" 500 -
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2091, in _call_
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.9/site-packages/flask_socketio/_init.py", line 43, in __call_
return super(SocketIOMiddleware, self).call_(environ,
File "/usr/local/lib/python3.9/site-packages/engineio/middleware.py", line 74, in _call_
return self.wsgi_app(environ, start_response)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2076, in wsgi_app
response = self.handle_exception(e)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 2073, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1518, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1516, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1502, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
File "/aichallenge/app.py", line 35, in start
main()
File "/aichallenge/main.py", line 24, in main
visual_node = visual.Node(source=0)
File "/usr/local/lib/python3.9/site-packages/peekingduck/pipeline/nodes/input/visual.py", line 173, in _init_
self._open_next_input()
File "/usr/local/lib/python3.9/site-packages/peekingduck/pipeline/nodes/input/visual.py", line 335, in _open_next_input
self._open_input(self.source)
File "/usr/local/lib/python3.9/site-packages/peekingduck/pipeline/nodes/input/visual.py", line 302, in _open_input
self.videocap = VideoNoThread(input_source, self.mirror_image)
File "/usr/local/lib/python3.9/site-packages/peekingduck/pipeline/nodes/input/utils/read.py", line 191, in _init_
raise ValueError(f"Video or image path incorrect: {input_source}")
ValueError: Video or image path incorrect: 0

If anyone is able to give advice on how I can prevent this issue, I would greatly appreciate it.

My goal is to access the user's camera when users connect to my website, and send the image data to PeekingDuck. Does anyone know whether this can be done by modifying some arguments to the input.visual node, or even making a custom visual node using OpenCV? I have spent quite some time researching the available options, and hope is bleak so far.

Otherwise, I will have to get the camera data from the front end, which presents another issue as the JavaScript API required for this only works on HTTPS for security reasons, and Docker does not work when the SSL Certifcate is self-signed, and I do not have a running website to get a proper SSL Certificate for Docker to run.

As such, I am stuck and unable to deploy the app to Docker and potentially a website, unless I purchase a domain and set up a shell website to get a proper SSL Certificate.

This may be besides the topic, but if getting image data from the end user using PeekingDuck/OpenCV is unfeasible, I would appreciate if anyone could advise me on how I can get flask to work with HTTPS on a Docker Container.

Thanks, and have a nice day!

4 Replies
Gao Hongnan
Posts: 19
Moderator
(@gao-hongnan)
Eminent Member
Joined: 4 months ago

Hi, apologies for the late reply, and thanks for the question, we will look into it and reply back.

Reply
Gao Hongnan
Posts: 19
Moderator
(@gao-hongnan)
Eminent Member
Joined: 4 months ago

Hi, the question asked here seems to be similar to your problem, have you give it a try and see if it resolves the issue? Do let us know!

If it doesn't, then you may also look into domains such as letsencrypt that offers free and open certificate.

Reply
2 Replies
SageofAge
Member
(@sageofage)
Joined: 3 weeks ago

Active Member
Posts: 5

@gao-hongnan Hi, thanks! I have got it deployed as a web app on the cloud and used let's encrypt as recommended. Also I have made a custom node to read the video data from the client and solved the issue.

Reply
Gao Hongnan
Moderator
(@gao-hongnan)
Joined: 4 months ago

Eminent Member
Posts: 19

@sageofage Great to hear! All the best!

Reply
Share: