Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. Please help my Matlab code work

Please help my Matlab code work

Scheduled Pinned Locked Moved IT & Infrastructure
help
5 Posts 2 Posters 21 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    Opul3nce
    wrote on last edited by
    #1

    Hi everyone I've got this project on MATLAB where i'm trying to read in a YUV file. Below are the m files within my work directory <pre lang="matlab">function [width,height,fps,startpos,NumberFrames]=readheader(fid) %******************************************************** % This function will read the header of a bath yuv file % % This file is used by readyseq and should not be used on its own. % % N.Young % 5 June 2001 %******************************************************** FileFormat = []; %The first line will contain one of the following %1. YUV 4:2:0 %2. RVS RAW YUV 4:2:0 %read the format descriptor for i=1:17 FileFormat = [FileFormat fscanf(fid,'%c',1)]; %Check to see if it is yuv 420 (i.e. number 1 above) if i==9 if FileFormat == 'YUV 4:2:0' disp('File format is : YUV 4:2:0'); FileFormat=0; break; end end %Check to see if it is rvs raw yuv 420 (i.e. number 2 above) if i==17 if FileFormat == 'RVS RAW YUV 4:2:0' disp('File format is : RVS RAW YUV 4:2:0'); FileFormat=1; break; end end %if we get here and i is 17, we have an unsupported FileFormat if i==17 disp('Unknown file format') FileFormat = 2; end end if FileFormat==0 [width,height,fps,startpos,NumberFrames] = readyuvheader(fid); end</pre> <pre lang="matlab">function [width,height,y]=readyseq(filename,start,stop) %******************************************************** % Function to load a bath yuv file % % Syntax : [width,height,ysequence] = readyseq(filename,start frame,end frame) % % NOTE: the frames are numbered from 0. % % A.N.Evans & N.Young % 5 June 2001 %******************************************************** %Note that I have to use some C functions here. I know some people dont like %mixing matlab with c, I'm affraid its un avoidable. %First we need to open the file [fid,msg] = fopen(filename,'r'); %if msg is longer than 0, i.e. it has something in it, we have an error if length(msg) > 0 disp('Error opening the file.'); else %read the header info [width,height,fps,startpos,NumberFrames] = readheader(fid); if start < NumberFrames & stop < NumberFrames %Now we can read the given frames. i=1; for frame = start:stop %now read the required frame y(i,:,:)=readyframe(fid,width,height,startpos,frame); i=i+1; end end end fclose(fid);</pre

    L 1 Reply Last reply
    0
    • O Opul3nce

      Hi everyone I've got this project on MATLAB where i'm trying to read in a YUV file. Below are the m files within my work directory <pre lang="matlab">function [width,height,fps,startpos,NumberFrames]=readheader(fid) %******************************************************** % This function will read the header of a bath yuv file % % This file is used by readyseq and should not be used on its own. % % N.Young % 5 June 2001 %******************************************************** FileFormat = []; %The first line will contain one of the following %1. YUV 4:2:0 %2. RVS RAW YUV 4:2:0 %read the format descriptor for i=1:17 FileFormat = [FileFormat fscanf(fid,'%c',1)]; %Check to see if it is yuv 420 (i.e. number 1 above) if i==9 if FileFormat == 'YUV 4:2:0' disp('File format is : YUV 4:2:0'); FileFormat=0; break; end end %Check to see if it is rvs raw yuv 420 (i.e. number 2 above) if i==17 if FileFormat == 'RVS RAW YUV 4:2:0' disp('File format is : RVS RAW YUV 4:2:0'); FileFormat=1; break; end end %if we get here and i is 17, we have an unsupported FileFormat if i==17 disp('Unknown file format') FileFormat = 2; end end if FileFormat==0 [width,height,fps,startpos,NumberFrames] = readyuvheader(fid); end</pre> <pre lang="matlab">function [width,height,y]=readyseq(filename,start,stop) %******************************************************** % Function to load a bath yuv file % % Syntax : [width,height,ysequence] = readyseq(filename,start frame,end frame) % % NOTE: the frames are numbered from 0. % % A.N.Evans & N.Young % 5 June 2001 %******************************************************** %Note that I have to use some C functions here. I know some people dont like %mixing matlab with c, I'm affraid its un avoidable. %First we need to open the file [fid,msg] = fopen(filename,'r'); %if msg is longer than 0, i.e. it has something in it, we have an error if length(msg) > 0 disp('Error opening the file.'); else %read the header info [width,height,fps,startpos,NumberFrames] = readheader(fid); if start < NumberFrames & stop < NumberFrames %Now we can read the given frames. i=1; for frame = start:stop %now read the required frame y(i,:,:)=readyframe(fid,width,height,startpos,frame); i=i+1; end end end fclose(fid);</pre

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Please do not post in more than one forum; I already responded to this here[^].

      txtspeak is the realm of 9 year old children, not developers. Christian Graus

      O 1 Reply Last reply
      0
      • L Lost User

        Please do not post in more than one forum; I already responded to this here[^].

        txtspeak is the realm of 9 year old children, not developers. Christian Graus

        O Offline
        O Offline
        Opul3nce
        wrote on last edited by
        #3

        Hi Sorry Someone(you) told me i was in the wrong forum Opul3nce

        L 1 Reply Last reply
        0
        • O Opul3nce

          Hi Sorry Someone(you) told me i was in the wrong forum Opul3nce

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Yes, I suggested you try the MATLAB forums, meaning on this site[^].

          txtspeak is the realm of 9 year old children, not developers. Christian Graus

          O 1 Reply Last reply
          0
          • L Lost User

            Yes, I suggested you try the MATLAB forums, meaning on this site[^].

            txtspeak is the realm of 9 year old children, not developers. Christian Graus

            O Offline
            O Offline
            Opul3nce
            wrote on last edited by
            #5

            Thanks for your advice. I've solved my problem.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups