File Exchange

image thumbnail

Foreground segmentation

version 1.0 (639 KB) by

Uses graph cuts to segment foreground objects from a static background in video.

45 Downloads

Updated

View License

This package contains m-files for the segmentation of a moving foreground from video with a static background, using graph cuts to achieve a clean result.

For more details and an accompanying paper please see http://cs.smith.edu/~nhowe/research/code/

Comments and Ratings (17)

Any alternatives to Indeo5 ? since it's not supported in windows 7 64 bits.

Adnan

Adnan (view profile)

Not working.. error in opening SampleVideo.avi. I tried (.avi) video from own dataset and got error
Undefined function 'gcut' for input arguments of type 'double'.

Error in graphLabel (line 16)
cut = gcut([zeros(2),C;C',P],[1 2]);

Hello Dears,
when I executed this script in Maltab I received this error,
Undefined function 'gcut' for input arguments
of type 'double'.
Error in graphLabel (line 16)
cut = gcut([zeros(2),C;C',P],[1 2]);
Error in extractForeground (line 113)
        label =
        reshape(graphLabel(alpha*[max(2*significanceThreshold-deviation(:)',0);deviation(:)'],connections),size(deviation));
        
Error in RUNME (line 29)
fg = extractForeground(frames);

So how can I solve it? Please help me it's so crucial for me to settle that!!
Thanks!

The problem comes from the places where original code converts int's to pointers. In 32-bit machine this is okay, but with 64-bit, you need to use a 64-bit type instead of int. In this case, if you read the error in detail, it tells you that mwIndex (a 64-bit pointer of type unsigned long *) is being assigned to an int. If you go to that line you see ir = mxGetIr(prhs[0]); Find where ir is defined (line 127: int *ir, *jc;) and change its type to a unsigned long *. unsigned long *ir, *jc; And repeat a similar procedure for this kind of errors (occurs 5-6 times, including the ones in pixCon.cpp).
I did this and I was able to compile with large arrays, but my Matlab crashes when running the code. Good luck.

Kiwon Yun

I also have the same problem to compile the 'gcut.cpp' file by using 'mex' in a 64-bits machine. Does somebody solve this?

Cedric

Cedric (view profile)

I have this problem while doing the mex file (linux 64-bits version):

 mex gcut.cpp -largeArrayDims

Warning: You are using gcc version "4.6.3-1ubuntu5)". The version
         currently supported with MEX is "4.3.4".
         For a list of currently supported compilers see:
         http://www.mathworks.com/support/compilers/current_release/

gcut.cpp: In function ‘void matlabParse(int, const mxArray**, long int*, long int*, node**, arc**, long int**, node**, node**, long int*)’:
gcut.cpp:144:25: error: cannot convert ‘mwIndex* {aka long unsigned int*}’ to ‘int*’ in assignment
gcut.cpp:145:25: error: cannot convert ‘mwIndex* {aka long unsigned int*}’ to ‘int*’ in assignment

    mex: compile of ' "gcut.cpp"' failed.

zhang

zhang (view profile)

thank you

zhang

zhang (view profile)

thank you!

Sean Connery

That`s exactly what I need now.Thank you so much~!

saidi lotfi

Krishna Sridhar

Really cool code.. I dont have much of a vision expertise and I wanted the foreground images..
This code works with such ease.. Just remember to do mex gcut.cpp when u copy into ur machine..

Piyorot Khongchuay

cool

Alex Denone

anand karemola

This is the best one for caputuring image,i wan use this code for my project.Could you please help for getting the graph cut images of different frames.I will appreciate if you could help me out.

Ayesha Malik

Can you convert this piece of code for foreground segmentation on a live video?? I would certainly appreciate if you help me out in doing so.

Kamran Iqbal

MO Ahmed

Thank you

MATLAB Release
MATLAB 7.0.1 (R14SP1)

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video