Info

Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.

convert this code to efficient way.

2 Ansichten (letzte 30 Tage)
Tal Regev
Tal Regev am 29 Aug. 2015
Geschlossen: MATLAB Answer Bot am 20 Aug. 2021
I have code that convert from org.bytedeco.javacv.Frame to matlab image.
In inefficient way. Can you help me convert it to efficient way?
javaaddpath('javacv.jar')
import org.bytedeco.javacv.*;
import org.bytedeco.javacpp.*;
grabber = FrameGrabber.createDefault(0)
grabber.start()
img = grabber.grab()
buff = img.image(1);
% //from here is inefficient code
charBuff = buff.asCharBuffer;
n = charBuff.length;
data = repmat(uint16(0),n,1);
for i=0:n-1
data(i+1) = charBuff.get(i);
end
I = typecast(data, 'uint8');
I = cat(3, ...
reshape(I(3:3:end),[w h])', ...
reshape(I(2:3:end),[w h])', ...
reshape(I(1:3:end),[w h])' ...
);
imshow(I);
  1 Kommentar
dpb
dpb am 29 Aug. 2015
Don't know what the form of buff is but why wouldn't
I=typecast(buff.asCharBuffer,'uint8');
be the same as what your end result is? Although I'd think there's likely a direct transformation if one knew the input format and what one's trying to get to in description rather than code...but I'm not an image processing guy at all, either, so what do I know??? :)

Antworten (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by