I am trying to place an image over a webcam feed in camera.py and send to main.py; output displayed in a flask generated local server . But I encountered the following error
libv4l2: error setting pixformat: Device or resource busy HIGHGUI ERROR: libv4l unable to ioctl S_FMT libv4l2: error setting pixformat: Device or resource busy libv4l1: error setting pixformat: Device or resource busy HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT
main.py
from flask
import Flask, render_template, Response
from camera
import VideoCamera
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
def gen(camera):
while True:
frame = camera.get_frame()
yield(b '--frame\r\n'
b 'Content-Type: image/jpeg\r\n\r\n' + frame + b '\r\n\r\n')
@app.route('/video_feed')
def video_feed():
return Response(gen(VideoCamera()),
mimetype = 'multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host = '0.0.0.0', debug = True)
index.html
<html>
<head>
<title>Video Streaming Demonstration</title>
<link type="text/css" rel="stylesheet"
href="{{ url_for('static',
filename='styles.css')}}" />
<style>
body {
background-image: url(http://cdn.wall88.com/51b487f75df1050061.jpg);
background-repeat: no-repeat;
}
</style>
</style>
</head>
<body>
<h1>Video Streaming Demonstration</h1>
<img id="bg" align="middle" src="{{ url_for('video_feed') }}">
</body>
</html>
使用python和flask的Opencv:HIGHGUI錯誤:libv4l無法ioctl S_FMT ,程式人生 > python > 使用python和flask的Opencv:HIGHGUI錯誤:libv4l無法ioctl S_FMT
我試圖將影象放置在camera.py的網路攝像頭提要上併發送到main.py;輸出顯示在flask生成的本地伺服器中。但是我遇到了以下錯誤
libv4l2: error setting pixformat: Device or resource busy HIGHGUI ERROR: libv4l unable to ioctl S_FMT libv4l2: error setting pixformat: Device or resource busy libv4l1: error setting pixformat: Device or resource busy HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT
from flask
import Flask, render_template, Response
from camera
import VideoCamera
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
def gen(camera):
while True:
frame = camera.get_frame()
yield(b '--frame\r\n'
b 'Content-Type: image/jpeg\r\n\r\n' + frame + b '\r\n\r\n')
@app.route('/video_feed')
def video_feed():
return Response(gen(VideoCamera()),
mimetype = 'multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host = '0.0.0.0', debug = True)
Which are the correct OpenCV libraries I should link with the target SNPE executable on the RB5 and where can I find these libraries? (I have downloaded the OpenCV source code but can't see any aarch64_linux libraries to link to),(DEBUG) try_init_v4l2 VIDIOC_QUERYCAP "/dev/video0": Inappropriate ioctl for deviceUnable to stop the stream: Inappropriate ioctl for device,Failed to query video capabilities: Inappropriate ioctl for devicelibv4l2: error getting capabilities: Inappropriate ioctl for deviceVIDEOIO ERROR: V4L: device /dev/video0: Unable to query number of channels,Hello, I had come across the GStreamer applications, but I would like to know if it is the only option to work with the onboard MIPI cameras, meaning V4L2 would not be an option.
gst-launch-1.0 -e qtiqmmfsrc name=qmmf ! video/x-h264,format=NV12, width=1280, height=720,framerate=30/1 ! h264parse config-interval=1 ! mpegtsmux name=muxer ! queue ! tcpserversink port=8900 host=<RB5_IP_ADDRESS>
gst-launch-1.0 -e qtiqmmfsrc name=qmmf ! video/x-h264,format=NV12, width=1280, height=720,framerate=30/1 ! h264parse config-interval=1 ! mpegtsmux name=muxer ! queue ! tcpserversink port=8900 host=<RB5_IP_ADDRESS>
NOTE: Please keep running the above pipeline in seperate terminal.
Now, you can use VideoCapture, and pass streaming URL to get the frames using OpenCV, Please refer below Example,
import cv2
cap = cv2.VideoCapture("tcp://<RB5_IP_ADDRESS>:8900") #rb5 ip & port (same from command)
while(cap.isOpened()):
ret, frame = cap.read()
#
# Write your code here
#
break
cap.release()