English 中文(简体)
我如何改变使用弗拉茨克语播音的网上广告?
原标题:How do I change the webcam of a python file by using Flask?

我正致力于一个面对面的承认项目,该项目将基因(镜子)发送到录像中。 然而,我找不到把当地储存送到弗拉斯克的正确途径。 没有人会提出一些建议,说明我如何用地方储存来改变网络运动?

The python visit_taker.py which contained the gen_frame methods:

`def gen_frame(): cap = cv2.VideoCapture(0) # This is what I want to change using localstorage face_recognizer = Face_Recognizer()

while True:
    success, frame = cap.read()
    if not success:
        break

    face_recognizer.process(frame)

    ret, buffer = cv2.imencode( .jpg , frame)
    frame = buffer.tobytes()
    yield (b --frame
 
           b Content-Type: image/jpeg

  + frame + b 
 )`

这里是《 j法》:

`window.addEventListener("DOMContentLoaded", function () { var webcamSelect = document.getElementById("webcamSelect");

webcamSelect.addEventListener("change", function () {
    var selectedWebcamIndex = webcamSelect.selectedIndex;
    localStorage.setItem("selectedWebcamIndex", selectedWebcamIndex);
});

navigator.mediaDevices
    .enumerateDevices()
    .then((devices) => {
        var videoDevices = devices.filter(
            (device) => device.kind === "videoinput",
        );
        videoDevices.forEach((device, index) => {
            var option = document.createElement("option");
            option.value = index;
            option.text = device.label || `Webcam ${index + 1}`;
            webcamSelect.appendChild(option);
        });

        var selectedWebcamIndex = localStorage.getItem(
            "selectedWebcamIndex",
        );
        if (selectedWebcamIndex) {
            webcamSelect.selectedIndex = selectedWebcamIndex;
        }
    })
    .catch((error) => {
        console.error("Error enumerating devices:", error);
    });

}); ` app.py:

@app.route(/video_feed ) def视频_feed():回报反应(gen_frame()、米梅类=多部分/x-ixed-replace;边界=frame

我利用 j子进行审判,但没有工作。

问题回答

我很想把这个问题混为一谈,但这里是:

根据我的理解,你重新寻求把产出作为档案服务器的一方加以节省,然而,你无需通过您的头版javascript这样做。

# pip install opencv-python

import cv2

# basic opencv2 things here feel free to ignore

cv2.startWindowThread()
cap = cv2.VideoCapture(0) # specify camera

out = cv2.VideoWriter( output.avi , cv2.VideoWriter_fourcc(* MJPG ), 15., (640, 480)) 
#  output.avi : outputted file,  MJPG : motion jpeg,  (640, 480) : output width and height, adjust to needs

while True:
    success, frame = cap.read()
    # ...
    
    out.write(frame.astype( uint8 )) # write the output video


# run this afterwards to save the video
out.release() # release video output

在试图将你的密码锁定在标记中时,比你更多的微薄服务器会走很长的路,会非常谨慎。

  • triple backticks opening and closing for multiline code blocks
  • single backticks opening and closing for single line code blocks

link • 与全基例的链接,以便与普思松开放。

I notice the title says how do I change the webcam of a python file using flask, if that s the question itself, you can use the:

<代码>cap = cv2.VideoCapture(0),以具体说明照相机。 该数字显示有一台单独的照相机。 (e:1,可在0上安装一个照相机。 可以是嵌入式的,等等

Let me know if I completely missed the mark here or if you have anymore questions!





相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签