www.gusucode.com > Deep Learning for Defect Detection on Raspberry Pi 源码程序matlab > Deep Learning for Defect Detection on Raspberry Pi/RaspPi/mat2ocv.m
function out = mat2ocv(img) % Convert image data format to OpenCV compatible format % Copyright 2018 The MathWorks, Inc. sz = size(img); Iocv = zeros([prod(sz), 1], 'uint8'); % Reshape input data Ir = permute(img, [2 1 3]); % RRR...GGG...(MATLAB) format to BGRBGR...(openCV) format Iocv(1:3:end) = Ir(:,:,3); Iocv(2:3:end) = Ir(:,:,2); Iocv(3:3:end) = Ir(:,:,1); out = reshape(Iocv, sz); end