Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am working face detection with Emgu, it works fine, but when I try to crop the Image to save it the program breaks and threw an "OutOfMemoryException". I am using the next method (recomended here) to crop the image:
private static Image cutImage(Image img, Rectangle cropArea)
            {
                Bitmap bmpImage = new Bitmap(img);
                Bitmap bmpCrop = bmpImage.Clone(cropArea, bmpImage.PixelFormat);
                return (Image)(bmpCrop);
            }

But in line "bmpImage.Clone()" program stops. What am I doing wrong?

Thanks in advance.
Dumar
Posted
Comments
Sergey Alexandrovich Kryukov 14-Jun-13 13:18pm    
Maybe, nothing wrong in this very piece of code. Perhaps, just too big image, not enough memory? It it really big? Could your memory be already heavily overused, even before this call?
—SA
dlinaresg 14-Jun-13 13:38pm    
grayscale, 1920X1080, 32kb. Do you think is too much?
Sergey Alexandrovich Kryukov 14-Jun-13 13:41pm    
Certainly not. (This is merely one of the "High Def" specs.) Could your system deplete the memory even before this call? (Is it x86, 32-bit, or what?)
—SA
dlinaresg 14-Jun-13 13:51pm    
Certainly not much machine. Could it improve if I diminish camera definition to 640*480?
Sergey Alexandrovich Kryukov 14-Jun-13 14:20pm    
All you have to do is try, starting with some minimal size. It's time to start using diagnostics or even memory debuggers. Measure how much memory you have left in the system, and so on...
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900