JimHokanson / SegwormMatlabClasses

Segworm code rewritten to use Matlab classes and packages
3 stars 0 forks source link

can't get video_testing to run on my mac system #4

Closed aaronlange closed 10 years ago

aaronlange commented 10 years ago

On my first attempt, using the example worm video: mec-4 (u253) off food x_2010_04_2117_19_201.avi, I got the following:

>> video_testing(true)
Cannot find an exact (case-sensitive) match for 'videoReader'

The closest match is: VideoReader
in /Applications/MATLAB_R2012b.app/toolbox/matlab/audiovideo/@VideoReader/VideoReader.m

Error in seg_worm.segWormFrames (line 82)
vr = videoReader(video_file_path,true);

Error in video_testing (line 45)
[worms, fixed_images, orig_images] = seg_worm.segWormFrames(video_file_path,FRAMES_PARSE,true);

So first off, I think "videoReader" in seg_worm.segWormFrames needs to change to "VideoReader" (I am using Matlab 2012b and I think function name case-sensitivity is enforced in this version of Matlab)

I made this change in my copy of the repo and tried again:

>> video_testing(true)
Error using VideoReader/init (line 429)
Failed to initialize internal resources.

Error in VideoReader (line 132)
            obj.init(fileName);

Error in seg_worm.segWormFrames (line 82)
vr = VideoReader(video_file_path);

Error in video_testing (line 54)
[worms, fixed_images, orig_images] = seg_worm.segWormFrames(video_file_path,FRAMES_PARSE,true);

Looking into this, it seemed the issue was related to the video being in .avi format rather than a format supported by QuickTime on my mac such as .mov

So I converted the video to .mov and ran it again:

>> video_testing(true)
Error using VideoReader/set
Invalid input argument type to 'set'.  Type 'help set' for options.

Error in VideoReader (line 136)
                set(obj, varargin{:});

Error in seg_worm.segWormFrames (line 82)
vr = VideoReader(video_file_path,true);

Error in video_testing (line 45)
[worms, fixed_images, orig_images] = seg_worm.segWormFrames(video_file_path,FRAMES_PARSE,true);

I had a look at VideoReader.m and saw that the varargin argument to the 'set' function call on line 136 consisted of the second argument to the 'VideoReader' function call on line 82 in seg_worm.segWormFrames. I.e. in this case varargin consisted of only a boolean with value 'true'. I typed "help set" into matlab and noticed that having a boolean as the second of two arguments to the 'set' function didn't seem to fit the correct usage of the function. So, not seeing any apparent purpose for the boolean argument, I changed

vr = VideoReader(video_file_path,true);

to

vr = VideoReader(video_file)

in seg_worm.segWormFrames and tried again:

>> video_testing(true)
Error using reshape
To RESHAPE the number of elements must not change.

Error in seg_worm.vignette (line 65)
            obj.mask_data = reshape(temp,width,height)';

Error in seg_worm.vignette.create (line 38)
               obj_or_empty = seg_worm.vignette(v_file_path,video_reader);

Error in seg_worm.segWormFrames (line 98)
vignette     = seg_worm.vignette.create(file_manager,vr);

Error in video_testing (line 45)
[worms, fixed_images, orig_images] = seg_worm.segWormFrames(video_file_path,FRAMES_PARSE,true);

I checked the details of each argument of 'reshape' and found the following:

size(temp) = [1 8542041]
width = 640
height = 480

which explains why matlab was complaining about how 'reshape' was being used.

I recalled that when I converted the .avi to a .mov, I allowed the program that did the conversion to set the dimensions of the output video to 640x480, which explained why width=640 and height=480 (given that width=video_reader.width etc). However, I did not know why the size 'temp' should equal width*height, given that 'temp' seemed to consist of the entire video file (line 61 of vignette.m), rather than just one frame.

I thought maybe the issue had something to do me using the .mov format, but a quick search for answers didn't yield anything straightforward. I started to look at the .mov format specification, but then thought I must be getting off-track. I also couldn't work out why this code would have worked for Jim when using a .avi file. This is as far as I got.

I hope that's clear enough. Any ideas on why this repo might not be working for me or where I've gone wrong? :)

JimHokanson commented 10 years ago

@aaronlange

My apologies!

A few things:

1) The video reading code was me hacking around and testing things out here and there. I never really cleaned it up to the point that it was meant to run and have everything work. I instead shifted my focus to the feature processing since we absolutely need that for the simulations. All of this was meant to be very temporary code as we transitioned over to Python.

2) Some of the code is still a hold over from the MRC code, beware! These files may or may not actually be used in processing.

3) I found videoReader everywhere in the old code. Rather than rewrite everything I created a 'videoReader' function that had the same interface as the old code but that called my code.

4) Their videoReader was an old toolbox that had a lot of compiling steps to it that seemed way too complicated: http://sourceforge.net/p/videoio/code/HEAD/tree/trunk/ Instead I wrote an AVI parser and linked that in with a JPEG decoder. The AVI parser isn't great but it works for that particular file.

5) Any time you see "sl" in the code that's a reference to: https://github.com/JimHokanson/matlab_standard_library

The repo isn't very stable yet. If you have any problems with it please let me know.

6) All of the original code, minus some toolboxes (apparently) can be found at: https://github.com/openworm/SegWorm

7) Finally, I started throwing everything in a package towards the end of this whole endeavor, rather than at the beginning of working on the video parsing. At one point I had a @videoReader class in the path. This was moved to seg_worm.videoReader.

I don't have time tonight but I'll try and get my mac out soon and make sure I can run through most of the code (up to the point that I completed).

Jim

JimHokanson commented 10 years ago

@aaronlange

I updated the code with a function: seg_worm.parseWormFromVideo

I remember now that I had stopped in the middle of getting orientation handling to work.

I haven't tested it yet with my mac but let me know if you have any troubles.

Jim

P.S. Looking over the code I was still in the process of translating the code and I never got around to refactoring. In other words, the overall layout isn't great, although I think it is better than the original ...

aaronlange commented 10 years ago

@JimHokanson

Thanks for the update! I gave it a test run and on first appearances it seemed to process the video successfully this time. Haven't got around to looking at the output in detail yet though