bw4sz / OpenCV_HummingbirdsMotion

Motion Detection using OpenCV and python
http://benweinstein.weebly.com/motionmeerkat.html
GNU General Public License v3.0
13 stars 5 forks source link

error processing video #19

Closed monkeymoves closed 9 years ago

monkeymoves commented 9 years ago

hi there

Many thanks for your work on this application! Really useful stuff and keen to test it out on some field footage :)

I managed to run the app from the windows exe and was working fine but thought I'd like to play around running the python install but hitting an error on run?

followed all instructions here https://github.com/bw4sz/OpenCV_HummingbirdsMotion, think all the modules are installed properly, numpy, scpiy, shapley, and FFmpeg etc

All paths appear to be correct and im running main.py from cmd prompt (tried in IDLE as well) and its allowing me to input video and select save location, but as its running motion detect I get this error?

Set advanced options? (n) : n Processing file C:\Users\luke\Desktop\J.mp4 AccAvg begin value is: 0.35 Output path will be C:\Users\luke\Desktop\motion\J frame rate: 0.0 Beginning Motion Detection Traceback (most recent call last): File "C:\Users\luke\Desktop\OpenCV_HummingbirdsMotion-master\OpenCV_HummingbirdsMotion-master\MotionMeerkat\wrapper.py", line 48, in wrap ob.prep() File "C:\Users\luke\Desktop\OpenCV_HummingbirdsMotion-master\OpenCV_HummingbirdsMotion-master\MotionMeerkat\motionClass.py", line 134, in prep orig = orig_image.copy() AttributeError: 'NoneType' object has no attribute 'copy' Error in input file: C:\Users\luke\Desktop\J.mp4 Press r to reboot, press any key to exit

bw4sz commented 9 years ago

Hey, thanks for trying the python version out.

I'm 99% sure you haven't installed FFMpeg correctly. i want to make sure i've pushed the latest version. Then i'll try to replicate your error. My first gut idea (could be wrong) is its something with ffpeg. Double check by using another file, but the line orig = orig_image.copy() is the very first thing that happens in the file, and it would only create that error if the file had no image. If the file path didn't exist, it would flag before that, so you are in a situation where you have a path to video but no video 'exists' according to python. This is classic ffmpeg problem. It can be quite tricky to install, check out the online forums for a number of installation attempts and different solutions. The main thing is to make sure the path to ffmpeg is active, so go to the command line and type ffmpeg. If it loads you did it right, if it can't find ffmpeg you need to export the PATH in the system environment variables. There are a couple other possible installation errors depending on exactly how you installed opencv and which version.

How did you hear about the software, from the paper or just googling? I'd love to hear your use case, and let me know how it all goes.

best,

ben

monkeymoves commented 9 years ago

Hi Ben

Sorry for the late reply, and thank you so for contacting me, much appreciated!

I've been absolutely manic recently so not had chance to look at the advice above in any detail although I would agree that it seems perhaps ffpeg is not installed correctly (although I think i did follow your install instructions and did call ffpeg from command line but it didst through an error so i assumed it was ok/at least installed ok)

tbh I've had loads of different python installations on my main rig (its quite a beast overclocked hexcore 32gb ram, SSD raids etc as I do a lot of motion graphics, films and 3d so could be to do with the system set up and general complicated path issues haha, so i'll check all the path installations on the weekend and let you know how i get on)

I managed to use it via the exe install fine, and gave up witt the anaconda installation as I need other python modules so its a default installation into python 2.7 which seemed to go smoothly but then crapped out at running line one, despite appearing ffpeg installed? (I did have to install shapely as well into 2.7 installation btw incase anyone else gives you the can't find Shapley.obj error)

I work for natural resources wales in the day job (new welsh env body), so quite a lot of us ecology/earth science folks here (im more earth science) and many opportunities for us to gather data on sites, aerials and the like!

We've been playing around with Rasberry Pi's & motion capture scripts but the triggers are too slow, so your video analysis works much better IMHO and I'd like to adapt the scripts, we've also played with drones/quads so im just really interested on understanding how the software works and what application we can use from it!

If you are interested I have a vimeo channel with loads of stuff on it , here is a little link to a work film http://vimeo.com/115721449 & here is a personal one http://vimeo.com/55340339

Anyway, I'll be in touch soon once i trouble shoot installation but I have a major animation on the go atm so it may be a week or so before I get chance to look! Neverthelss I wanted to say thank you, and if you ever need help with video editing/colour grading, graphics etc I'd love to return the favour and help you out!!

Cheers, and look forward to chatting soon!

Luke

On Mon, Jan 5, 2015 at 3:34 PM, Ben Weinstein notifications@github.com wrote:

Hey, thanks for trying the python version out.

I'm 99% sure you haven't installed FFMpeg correctly. i want to make sure i've pushed the latest version. Then i'll try to replicate your error. My first gut idea (could be wrong) is its something with ffpeg. Double check by using another file, but the line orig = orig_image.copy() is the very first thing that happens in the file, and it would only create that error if the file had no image. If the file path didn't exist, it would flag before that, so you are in a situation where you have a path to video but no video 'exists' according to python. This is classic ffmpeg problem. It can be quite tricky to install, check out the online forums for a number of installation attempts and different solutions. The main thing is to make sure the path to ffmpeg is active, so go to the command line and type ffmpeg. If it loads you did it right, if it can't find ffmpeg you need to export the PATH in the system environment variables. There are a couple other possible installation errors dependin g on exactly how you installed opencv and which version.

How did you hear about the software, from the paper or just googling? I'd love to hear your use case, and let me know how it all goes.

best,

ben

— Reply to this email directly or view it on GitHub https://github.com/bw4sz/OpenCV_HummingbirdsMotion/issues/19#issuecomment-68724040 .

monkeymoves commented 9 years ago

Hi Ben

Apologies for the late reply, million deadlines etc! Update on my install issues :)

have tried to trouble shoot the install of ffmpeg as you described previously (I deleted the original install after it didnt work and reinstalled from scratch) , I also have typed "ffmpeg" into cmd prompt and it seems to work (allows me to see version, call help etc ver, 2.5.3) sp appears to be installed

my path has ffmpeg appended as far as I can see (I removed the old 2.5.2 and replaced with 2.5.3)

My path text below: C:\Users\luke\AppData\Roaming\npm;C:\Program Files\Java\jdk1.8.0_25\bin;C:\Program Files\apache-ant-1.9.4\bin;C:\Users\luke\AppData\Local\Android\sdk1\platform-tools;C:\Users\luke\AppData\Local\Android\sdk1\tools;C:\ffmpeg-2.5.3;C:\Python27

I opened up idle and ran the main.py and passed it a video file (which is in a folder on my desktop) & i get this error below: 'batch' run or single 'file'? (file): file Enter video input: C:/Users/luke/Desktop/motion/APERU.mp4 File Destination Folder (C:/MotionMeerkat/): C:/Users/luke/Desktop/motion Threshold for movement tolerance ranging from 0 [all] to 255 no movement: 30 Minimum motion contour size (0.2):

Set advanced options? (n) :

Processing file C:/Users/luke/Desktop/motion/APERU.mp4 AccAvg begin value is: 0.35 Output path will be C:/Users/luke/Desktop/motion\APERU frame rate: 0.0 Beginning Motion Detection Traceback (most recent call last): File "C:\Users\luke\Desktop\OpenCV_HummingbirdsMotion-master\OpenCV_HummingbirdsMotion-master\MotionMeerkat\wrapper.py", line 48, in wrap ob.prep() File "C:\Users\luke\Desktop\OpenCV_HummingbirdsMotion-master\OpenCV_HummingbirdsMotion-master\MotionMeerkat\motionClass.py", line 134, in prep orig = orig_image.copy() AttributeError: 'NoneType' object has no attribute 'copy' Error in input file: C:/Users/luke/Desktop/motion/APERU.mp4 Press r to reboot, press any key to exit

I have ffmpeg , open cv and python 2.7 installed in C: (screen shot below)

It worked fine when I run from the exe but I'm sure what im doing wrong?

the error opens up the same error? orig = orig_image.copy()

Thanks for your help, not sure if the above is of any use, but any tips would be useful!

Cheers

Luke

On Fri, Jan 9, 2015 at 10:44 AM, luke maggs lukejjmaggs@gmail.com wrote:

Hi Ben

Sorry for the late reply, and thank you so for contacting me, much appreciated!

I've been absolutely manic recently so not had chance to look at the advice above in any detail although I would agree that it seems perhaps ffpeg is not installed correctly (although I think i did follow your install instructions and did call ffpeg from command line but it didst through an error so i assumed it was ok/at least installed ok)

tbh I've had loads of different python installations on my main rig (its quite a beast overclocked hexcore 32gb ram, SSD raids etc as I do a lot of motion graphics, films and 3d so could be to do with the system set up and general complicated path issues haha, so i'll check all the path installations on the weekend and let you know how i get on)

I managed to use it via the exe install fine, and gave up witt the anaconda installation as I need other python modules so its a default installation into python 2.7 which seemed to go smoothly but then crapped out at running line one, despite appearing ffpeg installed? (I did have to install shapely as well into 2.7 installation btw incase anyone else gives you the can't find Shapley.obj error)

I work for natural resources wales in the day job (new welsh env body), so quite a lot of us ecology/earth science folks here (im more earth science) and many opportunities for us to gather data on sites, aerials and the like!

We've been playing around with Rasberry Pi's & motion capture scripts but the triggers are too slow, so your video analysis works much better IMHO and I'd like to adapt the scripts, we've also played with drones/quads so im just really interested on understanding how the software works and what application we can use from it!

If you are interested I have a vimeo channel with loads of stuff on it , here is a little link to a work film http://vimeo.com/115721449 & here is a personal one http://vimeo.com/55340339

Anyway, I'll be in touch soon once i trouble shoot installation but I have a major animation on the go atm so it may be a week or so before I get chance to look! Neverthelss I wanted to say thank you, and if you ever need help with video editing/colour grading, graphics etc I'd love to return the favour and help you out!!

Cheers, and look forward to chatting soon!

Luke

On Mon, Jan 5, 2015 at 3:34 PM, Ben Weinstein notifications@github.com wrote:

Hey, thanks for trying the python version out.

I'm 99% sure you haven't installed FFMpeg correctly. i want to make sure i've pushed the latest version. Then i'll try to replicate your error. My first gut idea (could be wrong) is its something with ffpeg. Double check by using another file, but the line orig = orig_image.copy() is the very first thing that happens in the file, and it would only create that error if the file had no image. If the file path didn't exist, it would flag before that, so you are in a situation where you have a path to video but no video 'exists' according to python. This is classic ffmpeg problem. It can be quite tricky to install, check out the online forums for a number of installation attempts and different solutions. The main thing is to make sure the path to ffmpeg is active, so go to the command line and type ffmpeg. If it loads you did it right, if it can't find ffmpeg you need to export the PATH in the system environment variables. There are a couple other possible installation errors dependin g on exactly how you installed opencv and which version.

How did you hear about the software, from the paper or just googling? I'd love to hear your use case, and let me know how it all goes.

best,

ben

— Reply to this email directly or view it on GitHub https://github.com/bw4sz/OpenCV_HummingbirdsMotion/issues/19#issuecomment-68724040 .

bw4sz commented 9 years ago

Hi Luke,

Sorry for the very slow response, github notifications don't go directly to my email. Can you send me the file? Its weird that it works in the exe but not on the command line. The error you get is still consistent with a ffmpeg error, the none type means that there was no frames reading. I'll push a newer version that gives an explicit error in this case. Ffmpeg is installed within the exe directly, which is probably why it works. I think you still haven't installed opencv, python and the videocapture correctly. You need to move the third party libraries over to the python path and rename it fit the python version. Its a pain.

See here:

http://stackoverflow.com/questions/11699298/opencv-2-4-videocapture-not-working-on-windows

I'm almost certain this is an install issue on your end, but sending me the file will confirm that.

I'm almost done with a server online version that you will be able to upload videos and get the results returned. this will get around all installs. It doesn't work yet, but working on it actively

http://bovary.iplantcollaborative.org/module_service/MotionMeerkat/

Thanks,

Ben