Built in webcam server working on my new N2

Discussions about ideaMaker and other printing software.
JoeyC
Posts: 21
Joined: Tue Mar 13, 2018 5:57 pm

Built in webcam server working on my new N2

Postby JoeyC » Tue Apr 03, 2018 3:01 am

I just got a new N2 single last week and while it was printing I'd thought I'd take a look around the touch screen tablet using SSH shell. I was trying to see how they had it setup. Imagine my surprise when I saw they had put in mjpeg-streamer! I've used that app before on small robots to get video streaming from webcams and raspberry pi cams.

So I plugged a cheap USB web cam into the port on top and it showed up as a usb device. I ran the startup script for mjpeg-streamer in /usr/cam/bin and I got the web server in my browser, but it gave me a 404 page not found. So I took a look at the startup script and they had the web site dir wrong. I used nano to edit /usr/cam/bin/run.sh and changed the last option from -w /usr/cam/www/mjpg_streamer" to -w /usr/cam/www"

Bingo, web site with streaming video from the N2! The address is the IP of the tablet followed by :8080, i.e. 192.168.1.100:8080 When you get the index page just click on the word "Stream" on the left side to see the live stream. Hit CTRL-C in the shell to exit the server.

Now I just have to edit the web page to clean it up and add mjpeg-streamer as a service that starts on boot up. Should be able to get that together tomorrow.

Untitled.jpg

EldRick
Posts: 269
Joined: Thu Jun 22, 2017 5:55 am

Re: Built in webcam server working on my new N2

Postby EldRick » Tue Apr 03, 2018 4:23 pm

I'd appreciate more detailed directions on doing this, as Raise3D does not seem likely to deliver a camera for the N2 any time this decade.

User avatar
jetdillo
Posts: 84
Joined: Mon Jun 12, 2017 5:10 am

Re: Built in webcam server working on my new N2

Postby jetdillo » Tue Apr 03, 2018 4:47 pm

JoeyC wrote:I just got a new N2 single last week and while it was printing I'd thought I'd take a look around the touch screen tablet using SSH shell. I was trying to see how they had it setup. Imagine my surprise when I saw they had put in mjpeg-streamer! I've used that app before on small robots to get video streaming from webcams and raspberry pi cams.

So I plugged a cheap USB web cam into the port on top and it showed up as a usb device. I ran the startup script for mjpeg-streamer in /usr/cam/bin and I got the web server in my browser, but it gave me a 404 page not found. So I took a look at the startup script and they had the web site dir wrong. I used nano to edit /usr/cam/bin/run.sh and changed the last option from -w /usr/cam/www/mjpg_streamer" to -w /usr/cam/www"

Bingo, web site with streaming video from the N2! The address is the IP of the tablet followed by :8080, i.e. 192.168.1.100:8080 When you get the index page just click on the word "Stream" on the left side to see the live stream. Hit CTRL-C in the shell to exit the server.

Now I just have to edit the web page to clean it up and add mjpeg-streamer as a service that starts on boot up. Should be able to get that together tomorrow.

Untitled.jpg


I've poked around in the shell on my N2+ a few times but haven't done any deep explorations. This should be really easy to put together though if my firmware load is the same as yours. Thanks for reporting your findings.
I'll let you know how it works out.

JoeyC
Posts: 21
Joined: Tue Mar 13, 2018 5:57 pm

Re: Built in webcam server working on my new N2

Postby JoeyC » Sat Apr 07, 2018 9:31 pm

Got it working on boot up today. Mounted the camera in the top back corner:

20180407_165642.jpg


Steps:
1. Plug your web cam into the USB socket in the block at the top rear of the printer.

2. login to the SSH shell on your printer

3. Make sure the tablet sees it by doing ls /dev/v* you should see /dev/video0 in the list

4. In the directory /usr/cam/www do the following:
a. Rename index.html to something else
b. Rename stream_simple.html to index.html

5. use nano to edit /etc/rc.local and add the following lines just BEFORE the line the says exit 0

/usr/cam/bin/mjpg_streamer \
-i "/usr/cam/lib/input_uvc.so -d /dev/video0 -y -r 640x480 -f 10 -q 85" \
-o "/usr/cam/lib/output_http.so -p 8080 -w /usr/cam/www" &

6. Reboot the printer.

7. Using your web browser to go to the IP address of your printer, port 8080, like so: (substitute your printers IP address)
192.168.1.100:8080

8. You should now see the web cam video, like this:

stream.jpg

User avatar
easysofts
Posts: 20
Joined: Thu Mar 22, 2018 3:27 pm
Contact:

Re: Built in webcam server working on my new N2

Postby easysofts » Sun Apr 08, 2018 11:47 pm

Rha ! I can't test it, N2 is printing for 50h
Machines Brand : Raise3D / Wanhao / BCN3D

User avatar
easysofts
Posts: 20
Joined: Thu Mar 22, 2018 3:27 pm
Contact:

Re: Built in webcam server working on my new N2

Postby easysofts » Sun Apr 08, 2018 11:51 pm

You don't need user/password in SSH ?

anybody has tested yet? apart him? Apart @JoeyC ?
Machines Brand : Raise3D / Wanhao / BCN3D

Jetguy
Posts: 2352
Joined: Tue Mar 22, 2016 1:40 am
Location: In a van, down by the river

Re: Built in webcam server working on my new N2

Postby Jetguy » Mon Apr 09, 2018 12:12 am

easysofts wrote:You don't need user/password in SSH ?

anybody has tested yet? apart him? Apart @JoeyC ?

It all depends on what version of Raise Touch application you are running on the LCD screen.
If you never updated your LCD screen, then yes, early versions had no password.
At the same time, if you didn't update your screen, you are ALSO missing out on several new features.
Example would be, if you have no SSH password, your firmware is pre 0.7.0 dated June of 2016.
https://www.raise3d.com/pages/touchscre ... ease-notes
Version 0.9.7 - January 16, 2018
Read more about this version

Lower Printing Temperature Available
User-defined Screen Lock Timeout
Empty Password for Screen Lock
SSH Password Security for Privacy and Security
Backup Credential File
Export Local Storage
Check Storage Space before Operation
User-defined Jerk
User-defined Acceleration
Save More Records for Serial Port Log
Fixed the bug of temperature not updating in time
Pause Reason Prompt

Version 0.9.2 - June 14, 2017

Added option to clear print statistics
Added option to reset privacy and security settings
Added option to restore factory settings
Added option to disable or enable collecting print statistics in dashboard
Added option to set steps per unit and PID settings
Fixed the issue that the height ratio of the printed models is incorrect when printing multiple models in sequential order

Version 0.9.0 - March 29, 2017

Added support for Russian language
Added support for Japanese language
Added a feature to restore last saved screen brightness
Added a feature to show the estimated completed time
Added a feature to show the initialization stage of WiFi and Ethernet
Added option to set the target pre-heat temperature while recovering the print job
Added option to clear print information after the print job is completed
Added option to enable screen lock
Cooling down the extruders after finishing loading or unloading filaments
Improved connecting via ethernet with a static IP address
Corrected gcode name and file size in dashboard

Version 0.8.0 - November 21, 2016

Added print time and material used in preview mode
Added a function to sync real time when turning on the printer
Added a function to record printing time and material used amount
Improve the uploading speed of gcode
Show target parameter and current parameter in Tune menu
Fixed a bug of not enabling DHCP when connected with LAN
Fixed the problem of wrong printing speed after resuming

Version 0.7.2 - August 19, 2016

Added a cursor in input box
Added a record of serial port log which can be loaded out to USB device or SD card
Added a prompt of the error of motion board
Added a Z drop when print finish in order to remove the model easily
Fixed some problems of UI display
Fixed a bug of keyboard letter
Fixed a bug of recognizing notes when reading gcode

Version 0.7.0 - June 15, 2016

Added a feature to pre-extrude manually while retracting filaments
Added "FastStop" function to stop printing while pre-heating extruders and heat bed
Added update notifier
Added a feature to set SSH password
Added French language support
Added support for setting up custom WiFi
Added a function of system monitoring to shut down touchscreen under crash situation
Improved virtual keyboard for extended symbols
Added a function to check uploaded file information and print uploaded file in upload queue
Improved WiFi connection



I highly suggest every single user reads and follows this additional information
viewtopic.php?f=3&t=1652&p=13896#p13896

User avatar
easysofts
Posts: 20
Joined: Thu Mar 22, 2018 3:27 pm
Contact:

Re: Built in webcam server working on my new N2

Postby easysofts » Mon Apr 09, 2018 12:25 am

Thank you Jetguy. I have v0.9.7 since 2 months. Sorry I haven't read all release notes, just the 2 earlier
Machines Brand : Raise3D / Wanhao / BCN3D

JoeyC
Posts: 21
Joined: Tue Mar 13, 2018 5:57 pm

Re: Built in webcam server working on my new N2

Postby JoeyC » Mon Apr 09, 2018 3:28 pm

I am running the latest version available on the download page, V0.97

EldRick
Posts: 269
Joined: Thu Jun 22, 2017 5:55 am

Re: Built in webcam server working on my new N2

Postby EldRick » Mon Apr 09, 2018 7:31 pm

What camera did you use, and what's its current draw?
I've been looking for one with a wide field of view and no IR features to draw unnecessary power.

Jetguy
Posts: 2352
Joined: Tue Mar 22, 2016 1:40 am
Location: In a van, down by the river

Re: Built in webcam server working on my new N2

Postby Jetguy » Tue Apr 10, 2018 12:08 am

FWIW, let's say that Raise 3D releases a Raisetouch update that enabled the camera. It's totally up to them if they do that and what that update is so do not take this as a hint or me saying they will, they might not. They control that aspect on what they release, what they sell and so forth.

If that were to happen, then maybe this specific camera (I tested a bunch that did not work, this one did)
OV7725 based camera.
The ones I specifically bought had a 150 degree wide angle lens but is no longer available https://www.amazon.com/gp/product/B073SLVPCF
Also, testing power draw of this specific camera max load ever is 70mA using a USB plug current meter.

However, the same basic camera with different lens options is still on Amazon.
Here is 180 degree https://www.amazon.com/dp/B073SMLSX4
95 degree https://www.amazon.com/dp/B073SL9QT5
90 degree https://www.amazon.com/dp/B075TJCDD7

Again, there a million what if things at play here. None of this is official or supported information and might well be wrong.
But, these cameras do support Plug-&-Play (UVC compliant), USB 2.0 camera module with USB2.0 cable.
That key spec, and this one VGA resolution, support 640x480 @60fps, MJPEG video streaming are what is important- because as stated in the Pro2 series thread as official camera questions, the video supported is actually 320x240, and what I found is that a camera that supported those VGA and UVC compliant specs, then it also did the half resolution 320x240.

Conversely, the style camera JoeyC used, did not work.

What I'm saying is, if you go your own and run the built in streamer and use that for the camera function, then a lot of web cameras work, including the ones I linked above. Think of the streamer code being used in this thread as a more "universal" app. If Raise 3D implements the camera in the QT5 app you know as the LCD interface, in my experience in testing, that will likely self limit to very specific cameras. I make no guarantee the ones above work, just if one was placing bets, the odds are higher.

JoeyC
Posts: 21
Joined: Tue Mar 13, 2018 5:57 pm

Re: Built in webcam server working on my new N2

Postby JoeyC » Tue Apr 10, 2018 1:55 pm

Jetguy wrote:That key spec, and this one VGA resolution, support 640x480 @60fps, MJPEG video streaming are what is important- because as stated in the Pro2 series thread as official camera questions, the video supported is actually 320x240, and what I found is that a camera that supported those VGA and UVC compliant specs, then it also did the half resolution 320x240.


Actually the camera I used did not support MJPEG video streaming. In fact the options that Raise3D used for mjpeg-streamer were specifically for cameras that did not have that capability. Also, the video is steaming at 640x480 resolution, not 320x240.

The command line options for mjpeg-streamer can be set to stream whatever resolution your camera has. You can also set the frame rate, they default to 10 frames a second, which seems OK.

The only issue is if the Linux build they used has drivers for the chip set in the camera. I find that the cheaper cams tend to use chips that are more likely supported.

JoeyC
Posts: 21
Joined: Tue Mar 13, 2018 5:57 pm

Re: Built in webcam server working on my new N2

Postby JoeyC » Tue Apr 10, 2018 1:57 pm

EldRick wrote:What camera did you use, and what's its current draw?
I've been looking for one with a wide field of view and no IR features to draw unnecessary power.


I used a sub $10 cam that I got from Microcenter. I don't think they carry it anymore.

User avatar
jetdillo
Posts: 84
Joined: Mon Jun 12, 2017 5:10 am

Re: Built in webcam server working on my new N2

Postby jetdillo » Tue Apr 10, 2018 3:20 pm

Getting a compatible camera working that is A. affordable and B. not a malware factory is a bit of a crapshoot. One of my business partners at our old space bought the camera that's supposed to be compatible w/ the N2+ and fits the printable bracket. I took a look at it and basically refused to use it. The install directions were basically:
Plug the camera into the Raise3D USB port. Join its built-in WiFi AP with your phone. Point the camera at a QR code, which will then use your phone to download an App onto your phone and update the firmware on the camera all at once. Then hope you didn't download some sort of malware onto both your printer AND your phone. Oh, and the phone app appeared to be the only way to access the camera.
I put it back in its box and handed it back to him and told him to return it.

*MAYBE* it's perfectly legit and they're trying to make it easy for everybody to get things set up w/ out editing configs or ssh'ing into places, but it just seemed super-sketchy to me.

If I wanted a camera on my printer, I could hook up a Raspberry Pi w/ camera to our VPN and I would at least know what's going on inside.

Jetguy
Posts: 2352
Joined: Tue Mar 22, 2016 1:40 am
Location: In a van, down by the river

Re: Built in webcam server working on my new N2

Postby Jetguy » Tue Apr 10, 2018 3:48 pm

Integrated into Ideamaker VS non-integrated- the next debate frontier. Should be a good one, be sure to get some popcorn.
It's going to be scorching blows on both sides of this one.
image.png

image(1).png

EldRick
Posts: 269
Joined: Thu Jun 22, 2017 5:55 am

Re: Built in webcam server working on my new N2

Postby EldRick » Tue Apr 10, 2018 4:32 pm

Personally I'd prefer that it not be integrated with iM, as it's a bit of a pain opening/hiding/manipulating the various windows, and I rarely use iM as a slicer. Let us view the camera in a browser.
For those using multiple printers, it seems that multiple instances of a separate program would be more useful, and viewing the camera in a browser seems like a natural solution.
Last edited by EldRick on Tue Apr 10, 2018 7:47 pm, edited 1 time in total.

User avatar
easysofts
Posts: 20
Joined: Thu Mar 22, 2018 3:27 pm
Contact:

Re: Built in webcam server working on my new N2

Postby easysofts » Tue Apr 10, 2018 5:56 pm

JoeyC wrote:Steps:
1. Plug your web cam into the USB socket in the block at the top rear of the printer.

2. login to the SSH shell on your printer

3. Make sure the tablet sees it by doing ls /dev/v* you should see /dev/video0 in the list

4. In the directory /usr/cam/www do the following:
a. Rename index.html to something else
b. Rename stream_simple.html to index.html

5. use nano to edit /etc/rc.local and add the following lines just BEFORE the line the says exit 0

/usr/cam/bin/mjpg_streamer \
-i "/usr/cam/lib/input_uvc.so -d /dev/video0 -y -r 640x480 -f 10 -q 85" \
-o "/usr/cam/lib/output_http.so -p 8080 -w /usr/cam/www" &

6. Reboot the printer.

7. Using your web browser to go to the IP address of your printer, port 8080, like so: (substitute your printers IP address)
192.168.1.100:8080



Hi JoeyC

I do all the tasks listed and I checked but I can't launch the webcam via IP address of my printer (192.168.0.26:8080).
Have you an idea ?

Tested with same webcam as you and other Logitech
Machines Brand : Raise3D / Wanhao / BCN3D

JoeyC
Posts: 21
Joined: Tue Mar 13, 2018 5:57 pm

Re: Built in webcam server working on my new N2

Postby JoeyC » Tue Apr 10, 2018 6:55 pm

easysofts wrote:I do all the tasks listed and I checked but I can't launch the webcam via IP address of my printer (192.168.0.26:8080).
Have you an idea ?


Couple of things to check:
1. When you do "ls /dev/v*" do you see the /dev/video0 device? If not, the tablet does not have a driver for that camera.

2. Did you restart the printer after changing the /etc/rc.local file?

3. If you do "ps -ef | grep mjp" You should see the motion jpeg process running, if not, it did not start.

4. If it is not running try starting it manually by entering the following command line:

/usr/cam/bin/mjpg_streamer -i "/usr/cam/lib/input_uvc.so -d /dev/video0 -y -r 640x480 -f 10 -q 85" -o "/usr/cam/lib/output_http.so -p 8080 -w /usr/cam/www" &

NOTE: the above must be entered on a single line to work properly.

Let me know what happens.

User avatar
easysofts
Posts: 20
Joined: Thu Mar 22, 2018 3:27 pm
Contact:

Re: Built in webcam server working on my new N2

Postby easysofts » Tue Apr 10, 2018 7:36 pm

Code below :roll:



Code: Select all

login as: root
root@192.168.0.26's password:
root@imx6qdlsolo:~# ls /dev/v*
/dev/vcs  /dev/vcs1  /dev/vcs2  /dev/vcsa  /dev/vcsa1  /dev/vcsa2  /dev/video0
root@imx6qdlsolo:~# ps -ef | grep mjp
root     23560 23370  0 19:24 pts/0    00:00:00 grep mjp


root@imx6qdlsolo:~# /usr/cam/bin/mjpg_streamer -i "/usr/cam/lib/input_uvc.so -d /dev/video0 -y -r 640x480 -f 10 -q 85" -o "/usr/cam/lib/output_http.so -p 8080 -w /usr/cam/www" &
[1] 1783
root@imx6qdlsolo:~# MJPG Streamer Version: svn rev: Unversioned directory
 i: Using V4L2 device.: /dev/video0
 i: Desired Resolution: 640 x 480
 i: Frames Per Second.: 10
 i: Format............: YUV
 i: JPEG Quality......: 85
Adding control for Pan (relative)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Tilt (relative)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Pan Reset
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Tilt Reset
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Pan/tilt Reset
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
Adding control for Focus (absolute)
UVCIOC_CTRL_ADD - Error: Inappropriate ioctl for device
mapping control for Pan (relative)
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Tilt (relative)
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Pan Reset
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Tilt Reset
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Pan/tilt Reset
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Focus (absolute)
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for LED1 Mode
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for LED1 Frequency
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Disable video processing
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
mapping control for Raw bits per pixel
UVCIOC_CTRL_MAP - Error: Inappropriate ioctl for device
 o: www-folder-path...: /usr/cam/www/
 o: HTTP TCP port.....: 8080
 o: username:password.: disabled
 o: commands..........: enabled
Machines Brand : Raise3D / Wanhao / BCN3D

JoeyC
Posts: 21
Joined: Tue Mar 13, 2018 5:57 pm

Re: Built in webcam server working on my new N2

Postby JoeyC » Tue Apr 10, 2018 7:44 pm

That looks good. Did you try it after that? What error if any do you get in the browser?


Return to “Software”

Who is online

Users browsing this forum: No registered users and 3 guests