2017-02-04 5 views
0

Diese Arbeit ist auf dem MPEG-Codec, der eine YUV-Datei als rohe Video-Inout nehmen soll. Im Anschluss ist der Code, den ich die YUV-Datei konvertieren bin mit RGBFehler in clipvalue() in Matlab

fileName = 'bus.y4m'; 
width = 250; 
height = 250; 
nrFrame = 10; 

fileId = fopen(fileName, 'r'); 
subSampleMat = [1, 1; 1, 1]; 
dummy = fgetl(fileId); % Skip file header 

%progressbar 
for f = 1:nrFrame 
    %f 

    % Skip frame header 
    dummy = fgetl(fileId); 
    fprintf('fileID = %i',fileId); 
    % read Y component 
    buf = fread(fileId, width * height, 'uchar'); 
    imgYuv(:, :, 1) = reshape(buf, width, height).'; % reshape 

    % read U component 
    buf = fread(fileId, width/2 * height/2, 'uchar'); 
    buf = reshape(buf, width/2, height/2).'; 
    imgYuv(:, :, 2) = kron(buf, subSampleMat); % reshape and upsample 

    % read V component 
    buf = fread(fileId, width/2 * height/2, 'uchar'); 
    buf = reshape(buf, width/2, height/2).'; 
    imgYuv(:, :, 3) = kron(buf, subSampleMat); % reshape and upsample 

    % convert YUV to RGB 
    imgRgb = reshape(convertYuvToRgb(reshape(imgYuv, height * width, 3)), height, width, 3); 
    mov(f) = im2frame(imgRgb); 

    progressbar(f/nrFrame) 
end 
fclose(fileId); 

Ich erhalte die folgende Fehler

Undefinierte Funktion ‚clipValue‘ für Eingabeargumente vom Typ ‚double‘.

Fehler in convertYuvToRgb (Zeile 11)

rgb = uint8 (clipValue (rgb, 0, 255));

Fehler in conv (Zeile 32) imgRgb = Umformen (convertYuvToRgb (Umformen (ImgYuv, Höhe * Breite, 3)), Höhe, Breite, 3);

Fehler in Lauf (Linie 64)

evalin ('Anrufer', [script ';']);

Was könnte falsch gelaufen sein ??

Antwort

1

Das Problem ist: convertYuvToRgb.m ist abhängig von clipValue.m.

Ich glaube, Sie haben einige Dateien fehlen ...

  1. Zum https://www.mathworks.com/matlabcentral/fileexchange/6318-convert-yuv-cif-4-2-0-video-file-to-image-files/content/YUV2Image/convertYuvToRgb.m
  2. Herunterladen YUV2Image.zip.
  3. Extrahieren YUV2Image.zip. Stellen Sie sicher, dass Sie alle extrahierten Dateien in demselben Ordner haben.
  4. Downloaden und extrahieren Sie progressbar.zip von https://www.mathworks.com/matlabcentral/fileexchange/6922-progressbar (kopieren Sie progressbar.m in den gleichen Ordner wie YUV2Image).
  5. Zeigen Sie Quelldatei im Ordner ...

ich nicht bus.y4m finden konnte, so dass ich es getestet mit bus_cif.y4m.

enter image description here