matlab - How to use reshape on a 4D matrix after using fread on a RGB RAW file? -
the following code correctly loads mp4 file , stores in 3d matrix.
r = 1; filename = testdummymp4; readerobj = videoreader(filename, 'tag', 'myreader1'); f = get(readerobj, 'numberofframes'); tampon = single(read(readerobj,1)); tampon = imresize(tampon(:,:,1),r); = zeros(size(tampon,1),size(tampon,2),f,'uint8'); k = 1:f disp(['open: ' num2str(round(100*k/f)) '%']) vidframes = single(read(readerobj,k)); i(:,:,k) = imresize(vidframes(:,:,2),r); end; imagesc((i(:,:,1)));
this output
i'm trying reverse engineer code produces same sort of result .raw 8bit rbg file. following answers this question tried following:
you can download 'm1302000245_1436389857.982603.raw'
rbg file here or google drive version here
ix = 256; iy = 256; sf = 30; % sample frequency recordingtime = 30; iz = sf*recordingtime testdummy = 'm1302000245_1436389857.982603.raw' fin = fopen(testdummy, 'r'); = fread(fin, ix*iy*3*iz, 'uint8'); fclose(fin); = reshape(i, [ix iy 3 iz]); % rbg should 256x256x3x900 % i've tried each of following manipulations before calling imagesc no avail % = flipdim(imrotate(i, -90),2); % i=impixel(i) % i=i' imagesc((i(:,:,1))); % view first slice
this gives:
what doing wrong?
additional info: recordings taken using raspberry pi cameras following python code
class braincamera: def __init__(self): self.video_format = "rgb" #self.video_quality = 5 # set settings of camera # exposure , gains constant. self.camera = picamera.picamera() self.camera.resolution = (256,256) self.camera.framerate = 30 sleep(2.0) self.camera.shutter_speed = self.camera.exposure_speed self.camera.exposure_mode = 'off' g = self.camera.awb_gains self.camera.awb_mode = 'off' self.camera.awb_gains = g self.camera.shutter_speed = 30000 self.camera.awb_gains = (1,1) def start_recording(self, video_name_path): self.camera.start_recording(video_name_path, format=self.video_format) self.camera.start_preview() def stop_recording(self): self.camera.stop_recording() self.camera.stop_preview() # destructor def __del__(self): print ("closed camera") self.camera.close()
i don't output have, reasonable image:
%your vode above, ending i=fread(...) i=uint8(i) i2=reshape(i, 3, ix ,iy, []); i2=permute(i2,[3,2,1,4]); imagesc(i2(:,:,:,1)); implay(i2);
Comments
Post a Comment