2017-02-04 49 views
0

這項工作是在MPEG編解碼器上,它應該將YUV文件作爲原始視頻輸入。以下是我使用的YUV文件轉換代碼爲RGBmatlab中clipvalue()的錯誤

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); 

我收到以下錯誤類型的輸入參數「雙重」

未定義功能「clipValue」。

錯誤convertYuvToRgb(第11行)

RGB = UINT8(clipValue(RGB,0,255)); (重新塑形(imgYuv,height * width,3)),高度,寬度,3);重新塑形(轉換)。

錯誤運行(線64)

evalin( '呼叫者',[腳本 ';']);

什麼可能出錯?

回答

1

問題是:convertYuvToRgb.m取決於clipValue.m

我覺得你有一些文件丟失......

  1. 轉到https://www.mathworks.com/matlabcentral/fileexchange/6318-convert-yuv-cif-4-2-0-video-file-to-image-files/content/YUV2Image/convertYuvToRgb.m
  2. 下載YUV2Image.zip。
  3. 提取YUV2Image.zip。確保將所有提取的文件放在同一個文件夾中。
  4. https://www.mathworks.com/matlabcentral/fileexchange/6922-progressbar(將progressbar.m複製到與YUV2Image相同的文件夾)下載並提取progressbar.zip。
  5. 將您的源文件中的文件夾...

我找不到bus.y4m,所以我bus_cif.y4m進行了測試。

enter image description here