Giter VIP home page Giter VIP logo

g-toolbox's Introduction

g-toolbox's People

Contributors

baidut avatar

Stargazers

Min Dai avatar

Watchers

James Cloos avatar  avatar

g-toolbox's Issues

video2yuv

Author: @baidut
Brief: convert video file to .yuv

  1. 将摄像头采集到的数据存成YUV文件
    • 帧率:15fps
    • 尺寸:320x240
    • 色度格式:4:2:0
  2. 用yuvviewer观察正确性
inFile = 'test.mp4';
outFile = 'output.yuv';
vidObj = VideoReader(inFile);
fid = fopen(outFile,'wb');
hold on;
while hasFrame(vidObj)
    vidFrame = readFrame(vidObj);

  R = double(vidFrame(:,:,1));
    G = double(vidFrame(:,:,2));
    B = double(vidFrame(:,:,3));

  D = [.299  .587  .144;
    -.147 -.289  .436;
     .615 -.515 -.1];
  C = [0; 128; 128];

    Y = D(1,1) * R + D(1,2) * G + D(1,3) * B + C(1);
    U = D(2,1) * R + D(2,2) * G + D(2,3) * B + C(2);
    V = D(3,1) * R + D(3,2) * G + D(3,3) * B + C(3);

    Y4 = uint8(round(Y));
    U4 = uint8(round(U));
    V4 = uint8(round(V));

    U1 = U4(1:2:end,1:2:end);
    V1 = V4(1:2:end,1:2:end);

    fwrite(fid,Y4','uint8');
    fwrite(fid,U1','uint8');
    fwrite(fid,V1','uint8');
end
fclose(fid);

参考资料

  1. MathWorks-Image Format Conversion: RGB to YUV
  2. 用Matlab读写YUV文件(备忘)
  3. ilovematlab-求教Matlab图像RGB转YUV

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.