有没有把视频捕获(0)(从python文件)放在C#用户界面中

我正在做关于人脸识别的项目。我正在研究如何在 Visual Studio 2019 中使用 C# 创建用户界面


我想知道如何将实时视频输出放到C#用户界面videoCapture.py


这是videoCapture.py


import numpy as np

import cv2


cap = cv2.VideoCapture(0)


while(True):

    # Capture frame-by-frame

    ret, frame = cap.read()


    # Our operations on the frame come here

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)


    # Display the resulting frame

    cv2.imshow('frame',gray)

    if cv2.waitKey(1) & 0xFF == ord('q'):

        break


# When everything done, release the capture

cap.release()

cv2.destroyAllWindows()

下面是 UI 的命名空间代码


namespace DropDownMenu

{

    /// <summary>

    /// Interaction logic for MainWindow.xaml

    /// </summary>

    public partial class MainWindow : Window

    {

        public MainWindow()

        {

            InitializeComponent();


            var menuReceptionist = new List<SubItem>();

            menuReceptionist.Add(new SubItem("Profiles", new UserControlAdd()));

            var item0 = new ItemMenu("Receptionist", menuReceptionist, PackIconKind.ViewDashboard);


            var menuAdmin = new List<SubItem>();

            menuAdmin.Add(new SubItem("Admins Profile", new UserControlAdmins()));

            menuAdmin.Add(new SubItem("Add Admin", new UserControlAdd()));

            var item1 = new ItemMenu("Administrations", menuAdmin, PackIconKind.FaceProfile);


            var menuPreprocess = new List<SubItem>();

            menuPreprocess.Add(new SubItem("New Data", new UserControlAdmins()));

            var item2 = new ItemMenu("Data PreProcessing", menuPreprocess, PackIconKind.Schedule);


            Menu.Children.Add(new UserControlMenuItem(item0, this));

            Menu.Children.Add(new UserControlMenuItem(item1, this));

            Menu.Children.Add(new UserControlMenuItem(item2, this));

        }



如果我做错了什么,我提前很抱歉。这是我第一次在堆栈溢出中发帖


杨魅力
浏览 101回答 2
2回答

哔哔one

您需要从 c# 运行 python 脚本,这可以通过几个方法完成。这是一篇解释该过程的文章:从 C# 运行 Python 脚本并使用结果

湖上湖

只是//add library&nbsp;using Emgu.CV;// in your code&nbsp;VideoCapture _videoCapture = new VideoCapture ();// to process framesApplication.Idle += ProcessFrame ; // you should create this function就是这样,我制作了一个视频,用简单的代码解释如何检测和识别人脸您可以查看此视频 https://www.youtube.com/watch?v=KEpSdKoyhs0
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python