Die Kamera kann nicht öffnen, während eine Flask -App von Docker läuftPython

Python-Programme
Anonymous
 Die Kamera kann nicht öffnen, während eine Flask -App von Docker läuft

Post by Anonymous »

Ich erhalte diesen Fehler, wenn ich versuche, eine Kamera aus einer Flask -App zu öffnen, die in Docker ausgeführt wird: < /p>

Code: Select all

172.17.0.1 - - [17/Mar/2025 11:24:10] "GET / HTTP/1.1" 200 -
[2025-03-17 11:24:19,498] ERROR in app: Exception on /detect_faces [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1511, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 919, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
File "/face_app/face_recognition_.py", line 114, in detect_faces_api
result = detect_faces(image_path, video_capture)
File "/face_app/face_recognition_.py", line 48, in detect_faces
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
cv2.error: OpenCV(4.11.0) /io/opencv/modules/imgproc/src/resize.cpp:4208: error: (-215:Assertion failed) !ssize.empty()
< /code>
Mein Code: < /p>
def detect_faces_api():

timestamp = int(time.time())
video_capture = cv2.VideoCapture(0,cv2.CAP_DSHOW)

image = request.files['image']
image_path = '/face_app/'+str(timestamp)+ '.jpg'
image.save(image_path)

result = detect_faces(image_path, video_capture)

video_capture.release()
cv2.destroyAllWindows()
< /code>
Ich muss diese App in einem Linux -Server ausführen, sobald sie fertig ist.72.17.0.1 - - [14/Mar/2025 15:45:53] "GET / HTTP/1.1" 200 -
[ WARN:0@13.565] global cap_v4l.cpp:913 open VIDEOIO(V4L2:/dev/video0): can''t open camera by index
[ERROR:0@13.566] global obsensor_uvc_stream_channel.cpp:158 getStreamChannelGroup Camera index out of range
[2025-03-14 15:46:02,507] ERROR in app: Exception on /detect_faces [POST]
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 1511, in wsgi_app
response = self.full_dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 919, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 917, in full_dispatch_request
rv = self.dispatch_request()
File "/usr/local/lib/python3.9/site-packages/flask/app.py", line 902, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)  # type: ignore[no-any-return]
File "/face_app/face_recognition_.py", line 113, in detect_faces_api
result = detect_faces(image_path, video_capture)
File "/face_app/face_recognition_.py", line 48, in detect_faces
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
cv2.error: OpenCV(4.11.0) /io/opencv/modules/imgproc/src/resize.cpp:4208: error: (-215:Assertion failed) !ssize.empty() in function 'resize'
< /code>
Ich habe auch cv2.videocapture (1), cv2.videocapture (2), cv2.videocapture (-1), cv2.videocapture (1, cv2.cap_v4l2) und alles < /p>
< /P> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> < /p> ) ausprobiert.FROM python:3.9-slim

RUN apt-get update && apt-get install -y \
build-essential \
cmake \
gfortran \
wget \
libboost-all-dev \
libatlas-base-dev \
libopenblas-dev \
liblapack-dev \
libx11-dev \
tesseract-ocr \
libgl1-mesa-glx \
libglib2.0-0 \
libsm6 \
libxrender1 \
libxext6 \
&& rm -rf /var/lib/apt/lists/*

COPY requirements.txt /face_app/
RUN pip install --no-cache-dir -r /face_app/requirements.txt

WORKDIR /face_app

COPY . /face_app

EXPOSE 5000

ENV NAME=World

CMD ["python", "face_recognition_.py"]
Docker Build -t-Docker-Face-App.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post