简体   繁体   English

vb.net 从视频中检测字符并提取到图像

[英]vb.net character detection from video and extract to image

example:例子:

file name: test.mp4文件名:test.mp4
file duration: 46min文件时长:46分钟

program will start scan at 0 min to 46 min (frame by frame)程序将在 0 分钟到 46 分钟开始扫描(逐帧)
if there is a subtitle or text on video, capture that frame and extract to image如果视频上有字幕或文本,则捕获该帧并提取到图像

NOT OCR, JUST CAPTURE AND EXTRACT IMAGE不是 OCR,只是捕获和提取图像

someone told me i can do it by opencv or emgucv有人告诉我我可以通过 opencv 或 emgucv
but i dont know how to do it.. so, can you guys give me tutorial?但是我不知道该怎么做..那么,你们能给我教程吗?

original image原始图像在此处输入图像描述

image after extract提取后的图像
在此处输入图像描述

You can just use a video stream in Emgucv, and capture a frame that you want.您可以在 Emgucv 中使用视频 stream 并捕获您想要的帧。

private List<Image<Bgr, Byte>> GetVideoFrames(String Filename)
{
        List<Image<Bgr, Byte>> image_array = new List<Image<Bgr, Byte>>();
        Capture _capture = new Capture(Filename);
        double totalFrames = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_COUNT);
        double fps = _capture.GetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FPS);
        double frameNumber = 0.0;

        bool Reading = true;

        while (Reading)
        {
            _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES, frameNumber);
            Image<Bgr, Byte> frame = _capture.QueryFrame();
            if (frame != null)
            {
                //image_array.Add(frame.Copy());

                //frame.Save(OutFileLocation + "\\" + Guid.NewGuid() + ".jpg");

                frame.Save(OutFileLocation + "\\" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".jpg");
            }
            else
            {
                Reading = false;
            }

            frameNumber += (fps * TimeDiff);
        }

        return image_array;
}

If you want to crop the image to only include the captions, then you could just use an roi.如果您想裁剪图像以仅包含标题,那么您可以只使用 roi。

Rectangle rect = new Rectangle(0, 0, frame.Width, frame.Height / 4);
frame.ROI = rect;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM