Eduard Mráz
Eduard Mráz

Reputation: 21

Django web displaying stream from webcam using jetson tx2 as a server

I am writing web app, where I would like to:

  1. Display LOCAL stream from webcam - it means, that I want to stream video from server (I do not want to open webcam of client)
  2. Read QR Codes and list them in text box

These two were already achieved but! I came across some unexpected behaviour. Functionality that I have described is working perfectly, but only on localhost. I want to deploy it, so it could be accessible via different computer (it is meant to be used on a robot).

So to describe my architecture: I am using Jetson TX2 as a server (webcam is connected here). I am using Django web framework, django-channels, daphne as a web server and ngingx as a proxy. I am running daphne and background process in supervisor.

I am using worker (background process) to capture frames from webcam and send it via redis to the web backend.

So when I run it on localhost everything work as expected. When I set Debug to FALSE and I add Jetson's IP to ALLOWED_HOSTS and try to access the web from different computer this happens: I can see, that webcam is accessed because the webcam light turns on. I put some QR code in front of the webcam and the code appears in the textbox on web! BUT the video is not there (when ALLOWED_HOSTS contains localhost video IS there). Output of background process which collects the camera frames gives following error:

libv4l2: error setting pixformat: Device or resource busy
OpenCV Error: Unspecified error (GStreamer: unable to start pipeline)
in cvCaptureFromCAM_GStreamer, file /home/nvidia/prototype/opencv/opencv-3.4.0/modules/videoio/$
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)):raised OpenCV exception:
/home/nvidia/toyota_prototype/opencv/opencv-3.4.0/modules/videoio  /src/cap_gstreamer.cpp:890: error: (-2)$
in function cvCaptureFromCAM_GStreamer

I will not post whole code here, since I do not know where exactly is the problem. Does anyone have an idea where the problem could be?

Thank you for your help!

Upvotes: 1

Views: 832

Answers (1)

Eduard Mráz
Eduard Mráz

Reputation: 21

So, I figured it out. In my html template I had one line, where I was linking to the stream address:

 <img src="http://127.0.0.1:8000/webcam-stream">

I think, now you all know, where the problem was. I needed to change the IP to HOST address.

Upvotes: 1

Related Questions