用C#来实现,脸部处理的功能

最近根据开源的项目,进行优化,实现,脸部处理的效果,开发环境:vs2022 + openCVsharp4.8 +Microsoft.ML.OnnxRuntime.GPU 1.18版本

在源代码的基础上进行了优化,增加了音频处理,gpu的优化功能有

public partial class VideoGpu : Form
{

    private VideoAudioProcessor _videoAudioProcessor;

    private readonly string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;

    private VideoAudioProcessor processor = new VideoAudioProcessor();
    private CancellationTokenSource cts;
    public VideoGpu()
    {
        InitializeComponent();
        this.Load += new EventHandler(Form1_Load);
        _videoAudioProcessor = new VideoAudioProcessor();
    }

    string fileFilter = "图片|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";

    string startupPath = string.Empty;

    string source_path = string.Empty;

    string newVideoPath = string.Empty;

    string finalOutputPath = string.Empty;

    Yolov8Face detect_face;
    Face68Landmarks detect_68landmarks;
    FaceEmbdding face_embedding;
    SwapFace swap_face;
    FaceEnhance enhance_face;


    private void button2_Click(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();
        ofd.Filter = fileFilter;
        if (ofd.ShowDialog() != DialogResult.OK) return;

        pictureBox1.Image = null;

        source_path = ofd.FileName;
        pictureBox1.Image = new Bitmap(source_path);
    }

    string video_path = "";
    string videoFilter = "视频|*.mp4;*.avi;";

    private void button3_Click(object sender, EventArgs e)
    {
        OpenFileDialog ofd = new OpenFileDialog();
        ofd.Filter = videoFilter;
        ofd.InitialDirectory = Application.StartupPath + "\\test";
        if (ofd.ShowDialog() != DialogResult.OK) return;

        video_path = ofd.FileName;
        label2.Text = video_path;

        //读取第一帧显示
        VideoCapture vcapture = new VideoCapture(video_path);
        if (!vcapture.IsOpened(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值