1

I am trying to capture images using webcam but I came across a null exception:

http://i89.photobucket.com/albums/k218/lololovelola/frame1null2_zps54bd24ce.png

Frame1 as shown during the debugging has null value. However, the fact that I put an error handler that if(frame1 != null) then it should not enter the condition because Frame1 is null.

What makes it even more odd is that frame2 accepts data from frame1 which in the previous image shows that it has null value and do not hold an image capture. Just to add, frame4 also accept the same image from frame1.

http://i89.photobucket.com/albums/k218/lololovelola/frame2null_zps2198fbb0.png

Any help from above will be very much appreciated. Thank you in advance!

1 Answers1

0

frame1 isn't null. frame1's data property is null. That means that it will pass the test frame1!=null but you would avoid the problem if you used frame1.Data!=null.

That said, the fact that there's no data from a webcam capture might be a whole different problem (or not; individual frames can can be a little odd sometimes depending on your webcam). This might just be a case of sticking a band-aid on a much larger problem.

mike1952
  • 493
  • 5
  • 12
  • Hi mike, I'll try that. I'm using Logitech webcam and my concern is why did it became null when it was working fine before editing the code inside the if statement. Also, the webcam controller pops up means that the webcam is detected and should be working but after 2 seconds the null exception appear. Do you have any idea why didn't the webcam capture an image and receive a null data? – lololovelola Apr 02 '14 at 14:47
  • You'll need to post the actual code. Also, the model of the camera you're using and the resolution etc. There's not much I can do from the screenshots. – mike1952 Apr 02 '14 at 16:28
  • I'm using Logitech C910, capturing a video of 640 X 480 and the saved video file extension is .wmv and I converted it into .avi using Freemake Video Converter. I made a separate cleaner program here: https://www.dropbox.com/s/8ieed8x1lxow50a/videoFeed.rar And here is the converted .avi video https://www.dropbox.com/s/8ieed8x1lxow50a/videoFeed.rar What I want is to be able to analyze the video frame by frame. – lololovelola Apr 09 '14 at 13:20
  • @lololovelola It would **really** help to have some source code. By your comment above, do you mean that you are crunching to video first and then try to process it, or that is what you did to send it to me? – mike1952 Apr 11 '14 at 12:24
  • my new source code / project is at the link above. But I used the wrong link for the video. Yes, from a video file I will load it in my program in C# and it was suppose to show a playback and simultaneously it should process it by frame. And, I found the solution to my problem. I overlooked the opencv_ffmpeg.dll to be "copy always" and I follow this http://stackoverflow.com/questions/8472946/emgu-cv-get-all-frames-from-video-file . It seems to do the trick. Thank you for reaching out. – lololovelola Apr 12 '14 at 10:58