Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No video displaying #1

Closed
lezabour opened this issue Jan 29, 2015 · 19 comments
Closed

No video displaying #1

lezabour opened this issue Jan 29, 2015 · 19 comments

Comments

@lezabour
Copy link

Hi,
thank you for your code and work! I saw your video, seems really good.

I've have search for similar project, to be able to understand how to send pictures to opencv, detect face (later recognize) and display live feed of the video... exactly what you did.

i've been trying to make it run on raspberry pi, with usb camera. But it's not working ;(

I run the "npm install" in server, everything is OK.
Then i run "sudo node server.js", and it seems to work.

But when i use my browser 2 things:

  1. no video is displaying ("Loading....")
  2. i can see that my camera is not used (not launch)

Do you have an idea from where it could come?

Thanks for your help!!

@estherjk
Copy link
Owner

@lezabour, I'd be happy to help. Have you been able to use your webcam successfully with other applications on your pi? If not, can you try typing lsusb to see if your webcam is listed?

@lezabour
Copy link
Author

Hi,

Thanks for your help.
Yes, the webcam works perfectly with other app.
I have tried the following:
opencv + python -> face detection / face recognition -> works OK
node.js + mjpg_streamer (or motion) -> works OK
All case webcam works, but with your code it seams no to launch the webcam.

thanks for your help

@estherjk
Copy link
Owner

@lezabour, does the camera turn on when running the server? I just want to make sure that the camera at least turns on when you start the server. (The green LED indicator on my webcam turns on when I start the server).

If not, let's double-check that node-opencv is installed correctly. Can you run any of the node-opencv examples? For example, try face-detection-rectangle.js; you may need to create a tmp folder before running it though. You can also try camera.js, which opens a new window with the video feed from your camera (not sure how this will look on your pi though).

And also, out of curiosity... are you attempting to open the page locally on your pi or on a computer on the same network? If the latter, modify the socket variable in client/app.js with the address of your pi. In the code, it's currently set to localhost. I originally created the demo to run locally on my computer.

@lezabour
Copy link
Author

Hi,

Thanks again for your help.
Yes, node-opencv is installed, and work. Not all examples (seems i don't have some requested modules), but for example face-detection-rectangle or face-detection are working well on the "mona lisa" image, image is created on the tmp folder, with the face shown.

I go with my browser on my laptop (not the pi). So as you ask, i just changed the URL in client/apps.js, for 192.168.xx.xx:8080 is now it seems more active!!
It's not solve yet, but this helps ;)
To answer you, no the green led of the camera don't switch on when i turn on the server.
It only do it when i connect with my browser. And i does it only since i change the IP adress in client/apps.js like you said.
But not solve cause:

  1. on turning server On: no green light(camera Off) , but when a connection is active (with my browser on my laptop), camera goes On. From your previous answer i assume that it supposed to turn On as soon as i start the server.
  2. When camera is On, still nothing displaying on the browser (loading...), and after 5-10 secondes, camera goes off, and server goes down...
    Here is a copy of the command line..
    pi@RPI ~/projets/nodejs/face-detection-node-opencv/server $ sudo node server.js
    HTTP server listening on port 8080
    pi@RPI ~/projets/nodejs/face-detection-node-opencv/server $

So we are moving on, almost their, but not yet ;)

thanks again!!

@estherjk
Copy link
Owner

Ok, progress!

So, the camera indicator does turn on for me when I start the server on my laptop before I connect to it on the browser. I think it's okay if the camera turns on once you connect though -- images are only read from the camera once there is an active connection anyway.

For the other issues, I wonder if the frame rate might also be too high for the pi? Can you try lowering camFps in server/lib/routes/socket.js? You can also try reducing the camera image size by adjusting camWidth and camHeight. I also don't recommend having more than 1 browser page connected to the server either... this might also impact performance.

@lezabour
Copy link
Author

Hi,

Thanks ;)
No still not working ;( I change the framerate, and dimension.
But framerate was at 10 fps which is low already.. it put it at 5, wich 160*120 size image, but not change, still crach after 5-10 secondes, and not displaying webcam

@estherjk
Copy link
Owner

Hm... not sure what the issue is. Which version of OpenCV are you using?

@lezabour
Copy link
Author

2.4.9...

@estherjk
Copy link
Owner

@lezabour, I'm hoping to set up a raspberry pi and try it out, to see what the issues might be. It might take me a bit, but hopefully I'll have answers for you soon.

@lezabour
Copy link
Author

lezabour commented Feb 1, 2015

Ok no problem
thank you very much for your help!

@estherjk
Copy link
Owner

@lezabour, ugh I accidentally deleted your last post. Apologies about that. It certainly is odd that the server goes down without outputting anything. Can you also check the console on the browser? Is anything outputted there?

In any case, I am trying to test this on a pi, but I've been running into issues building opencv 2.4.9 (and node-opencv). It seems like someone else has been running into issues with node-opencv on Raspberry Pi too -- see peterbraden/node-opencv#196.

@lezabour
Copy link
Author

Hey,
Ok here is the post and things i do to install opencv & node opencv
(cf. https://learn.adafruit.com/raspberry-pi-face-recognition-treasure-box/software)

sudo apt-get install build-essential cmake pkg-config python-dev libgtk2.0-dev libgtk2.0 zlib1g-dev libpng-dev libjpeg-dev libtiff-dev libjasper-dev libavcodec-dev swig unzip

sudo apt-get -y install build-essential cmake cmake-curses-gui pkg-config libpng12-0 libpng12-dev libpng++-dev libpng3 libpnglite-dev zlib1g-dbg zlib1g zlib1g-dev pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools libeigen3-dev

sudo apt-get -y install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-progs ffmpeg libavcodec-dev libavcodec53 libavformat53 libavformat-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 libgstreamer0.10-dev libxine1-ffmpeg libxine-dev libxine1-bin libunicap2 libunicap2-dev swig libv4l-0 libv4l-dev python-numpy libpython2.6 python-dev python2.6-dev libgtk2.0-dev

wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9.zip

cd opencv-2.4.9
sudo cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_PERF_TESTS=OFF -DBUILD_opencv_gpu=OFF -DBUILD_opencv_ocl=OFF -DBUILD_PYTHON_SUPPORT=ON -DBUILD_EXAMPLES=ON
sudo make (will take 5-7 hours!!)
sudo make install

dependencies

sudo apt-get install python-pip
sudo apt-get install python-dev
sudo pip install picamera
sudo pip install rpio

NODE.JS
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
sudo dpkg -i node_latest_armhf.deb

To make sure it ran correctly, run node -v. It should return the current version.
Running npm -v or npm --version

NODE.JS & OPENCV (NODE-OPENCV)
https://github.com/peterbraden/node-opencv

sudo apt-get install libopencv-dev python-opencv python-dev python-picamera
sudo pip install numpy
npm install opencv

Hope it will help you. With this, i reinstall opencv / node.js / node-opencv , 2 or 3 times on raspberry & raspbarian and every thing works.

Thanks

@estherjk
Copy link
Owner

@lezabour thanks for the instructions. Another question though: opencv 2.4.9 is built from source first, but then libopencv-dev is installed from apt-get under the NODE.JS & OPENCV instructions. This installs opencv 2.4.1... you didn't face any issues with having two different versions of opencv on your pi?

@estherjk
Copy link
Owner

@lezabour I managed to get OpenCV 2.4.9 installed from source (from the first part of your instructions). I also installed node-opencv without using the extra set of installations listed under NODE.JS & OPENCV.

Unfortunately, performance is very poor. I reduced the frame rate to 1 fps and the image size to 160x120, and it was very slow. It takes awhile for an image to show up. A few frames will process, but then the server eventually goes down with a Segmentation fault error:

drejkim@drejkim-pi ~/face-detection-node-opencv/server $ node server.js 
HTTP server listening on port 8080
GET /favicon.ico 200 145.683 ms - 410
Segmentation fault

Not sure of the best way to resolve this....

@lezabour
Copy link
Author

Hi,

Thank again for taking time to test!
I was able to have a better resolution and fps, but with a lot of delay (around 3-4sec delay)
with small resolution and fps, i have less delay (around 2 sec)
in all case, it goes off after few seconds it goes off,
I don't have the error message like you, it's just goes as it was finish

But i think that the Raspberry is has not enough power to run opencv in node.js
I will try it on the new Raspberry PI 2, which is more powerfull, and i will let you know

Thanks

@estherjk
Copy link
Owner

@lezabour I also think it's a performance issue with the pi. I am also curious as to how well it run on the raspberry pi 2.

@lezabour
Copy link
Author

Hi,
I got my PI2, so i could run some test.
The app is running of Pi2, but still have same problem.
Video is not going for a long time (few seconds).
And if it detects a face, it goes off directly.
Now i have the error message when the app is crashing

pi@RPI ~/projets/nodejs/face-detection-node-opencv/server $ node server.js
HTTP server listening on port 8080
Segmentation fault

Anyway, thanks for your help ;)

@estherjk
Copy link
Owner

@lezabour sorry to hear the the pi 2 also has the same issue. I guess it is also not powerful enough to run opencv with node and websockets. I'll go ahead and close this issue for now.

@PetrutaB
Copy link

Hi! Although this issue was close, I'd like to give some clarifications, thus I've been in the same situation as @lezabour. I was using an RPi 2 with an usual web cam, and I noticed, just like you that the video is not loading. So I've switched to RPi3, decreased the fps to 5 and finally I was able to run the application. Still, after 30s or so, I got Segmentation fault error. I've noticed that it was caused by SoC overheating. So, I've glued some radiators on the SoC and memory to dissipate the heat and now it work better. Still Segmentation fault after some time though... :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants