-2

I am new to using azure and django. During my project I'm having issues with the camera on my laptop. When running the code on my local system, it works completely fine (the camera opens, detects everything and does what it needs to). So after that I uploaded my code on azure using a virtual machine to get it up and running. The code is uploaded fine and everything works fine but the camera doesn't switch on (a broken image box appears) when I go to the page where the camera is supposed to run. What can I do to fix this?

I uploaded the code using azure web app to look at the error logs, errors like this appear too-

  1. [ERROR] import gi [ERROR] ModuleNotFoundError: No module named 'gi'

  2. [ERROR] [ WARN:0] global /tmp/pip-req-build-khv2fx3p/opencv/modules/videoio/src/cap_v4l.cpp (890) open VIDEOIO(V4L2:/dev/video0): can't open camera by index [ERROR] INFO: Created TensorFlow Lite XNNPACK delegate for CPU.

  3. [ERROR] cv2.error: OpenCV(4.5.4) /tmp/pip-req-build-khv2fx3p/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor' (I do not get these errors on my local system, only when I upload it)

(Also the audio clip that is supposed to play doesn't work either, does that have something to do with server configuration?)

I also found a suggestion that says I got to open the camera from client side and not the server side. I did not understand what that meant. Any clarification on that would be helpful.

I have looked around and haven't found anything definitive that works to help me fix these errors.

Zoron
  • 1
  • 2
    these questions show up regularly. OpenCV doesn't know it's supposed to be a web app. it accesses the *local camera*. the server has no camera. -- you are responsible for writing the code that asks the user for permission to use their webcam through the browser, and then to move those images from the browser to the server, **if** the server actually needs the data. – Christoph Rackwitz Nov 27 '21 at 18:27
  • we do this using django code right? does deployment method have any changes? – Zoron Jan 31 '22 at 11:08

1 Answers1

1

Thank you Christoph Rackwitz. Posting your suggestion as an answer to help other community members.

OpenCV doesn't know it's supposed to be a web app. it accesses the local camera. the server has no camera. -- you are responsible for writing the code that asks the user for permission to use their webcam through the browser, and then to move those images from the browser to the server, if the server actually needs the data.

You can refer to How to access webcam in OpenCV on PythonAnywhere through Javascript?, How do i access my webcam with python (Django) from the browser with the help of HTML and Javascript? and Using OpenCV with Django

Ecstasy
  • 1,866
  • 1
  • 9
  • 17