COMPLETE OctoPrint Raspberry Pi Camera Tweaks

Discussion in 'Guides, Mods, and Upgrades' started by PsyVision, Mar 5, 2016.

  1. PsyVision

    PsyVision Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    798
    Likes Received:
    248
    Hi All,

    I have now got my Raspberry Pi running OctoPrint and connected it to my printer with the standard RPi camera using parts I've printed. Note that the OctoPrint upgrade from BigBox comes with an improved RPi camera.

    The standard camera settings in OctoPrint don't look the best and can be changed:

    This document is the official RPi Cam manual that explains the possible camera configuration options:
    https://www.raspberrypi.org/wp-content/uploads/2013/07/RaspiCam-Documentation.pdf

    This is the OctoPrint file we are going to modify:
    https://github.com/guysoft/OctoPi/blob/devel/src/filesystem/home/root/bin/webcamd

    And these are the possible settings - the image is actually sourced from MJPG-streamer:
    https://github.com/foosel/OctoPrint/wiki/MJPG-Streamer-configuration

    Simply:

    1. SSH to your RPi using a tool like Putty with username//password of pi//raspbery.
    2. Then do:
    Code:
    cd /root/bin
    sudo nano webcamd
    3. Then find the following (line 10):
    Code:
    camera_raspi_options="-fps 10"
    4. I've changed mine to:
    Code:
    camera_raspi_options="-fps 10 -awb off -sh 50 -ex auto -quality 100"
    5. Press Ctrl + O, Enter to save and then Ctrl + X to exit
    6. Reboot with:
    Code:
    sudo reboot
    You should now see an improved picture. Experiment and see what works for you!

    Note: I tried increasing the resolution using -w 1280 -h 720 and it didn't work :/
     
    dz., Madeinoz67, mike01hu and 3 others like this.
  2. PsyVision

    PsyVision Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    798
    Likes Received:
    248
    Next up - the timelapse videos that OctoPrint can produce have an OctoPrint watermark over them. If, like me, you want to remove this then:

    1. Open the OctoPrint config file:
    Code:
    cd ~/.octoprint/
    sudo nano config.yaml
    2. Find the "webcam:" section towards the bottom of the file and you should see something like:
    Code:
    ffmpeg: /usr/bin/avconv
    snapshot:......
    3. Add the watermark option and set it to false:
    Code:
    ffmpeg: /usr/bin/avconv
    watermark: false
    snapshot:......
    4. Save the file with Ctrl + O, Enter and Ctrl + X to exit nano

    5. Restart OctoPrint (from the UI is easiest)[/CODE]
     
    #2 PsyVision, Mar 5, 2016
    Last edited: Mar 10, 2016
    mike01hu, Spoon Unit and Jonas like this.
  3. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    @PsyVision, I haven't tweaked mine yet as per your settings above, but there may be a difference in default settings from the nightly I took in order to get the Pi3 working. Here's what I get from <ip>:8080/static_simple.html

    [​IMG]

    Does this look like some tuned with your settings or not to you?
     
  4. PsyVision

    PsyVision Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    798
    Likes Received:
    248
    Looks better than mine, not sure what the cause is tho!
     
  5. PsyVision

    PsyVision Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    798
    Likes Received:
    248
    Code:
    camera_raspi_options="-fps 10 -x 1280 -y 720"
    Works!
     
  6. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    I've also now upped it to 1920 x 1200 and, in addition, fitted the focus ring and dialled in the focus to the center of the bed. Will post some results when I have them.
     
  7. Alex9779

    Alex9779 Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    2,411
    Likes Received:
    735
    According to the specs of the cam it can 1080p30 as video, since 10 fps is enough you can go a bit further I think.
    But that's way too much if you plan to make time-lapse videos. Once I killed a print in the middle because the SD card was full...
    Then I switched to the solution I described in another post, mounting a share on my NAS and use this for all the files of the OctoPI...
     
  8. PsyVision

    PsyVision Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    798
    Likes Received:
    248
    Yes I should probably switch to my NAS too at some point. I'm interested on the focus ring results.
     
  9. Henry feldman

    Henry feldman Well-Known Member

    Joined:
    Sep 5, 2015
    Messages:
    969
    Likes Received:
    391
    For a robotics project I did, I refocused the Pi camera all the time, and you can really dial it in. I was doing macro work (could focus down to about 2cm) just takes a steady hand. Once you get it dialed in can rift a tad with a lot of vibration if you don't tack it in some way.
     
    PsyVision likes this.
  10. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    OK. So.... Pi3 capturing screenshots at 1920x1080. Everything stored on NAS now as it goes. Focus rung about as good as I can get it. Sometimes it all still looks a bit blurred due to machine vibrations.

    https://www.youtube.com/watch?v=aJ0fMSrNXJ4

    Oh, also I changed the settings so it wasn't quite so crazy a pace. Actually, no, I see messing around with config.yaml has yet again returned me to the original 25,10,10. I think 10,10,10 might be a bit less crazy.
     
  11. JohnEsc

    JohnEsc Well-Known Member

    Joined:
    Sep 4, 2015
    Messages:
    229
    Likes Received:
    144
    @PsyVision Just checking before I perform this when I get home this afternoon... In Step 4 of your original post change the code to the following:
    camera_raspi_options="-fps 10 -x 1280 -y 720"

    I want HD quality, but 720 is sufficient for me.
    Also, the watermark can be turned on and off from the OctoPrint Webcam Settings window.
     
  12. PsyVision

    PsyVision Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    798
    Likes Received:
    248
    Correct on your camera_raspi_options.

    Didn't know about the watermark option, not sure how I didn't spot that. New in the new version of OctoPrint?
     
  13. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
  14. JohnEsc

    JohnEsc Well-Known Member

    Joined:
    Sep 4, 2015
    Messages:
    229
    Likes Received:
    144
    @Spoon Unit What effect does the Timelapse bitrate 12600k have? Mine was set to 5000k by default.
     
  15. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    @JohnEsc when you take a set of pictures and turn them into a picture, you typically don't store a perfect copy of every picture for each of the frames in the video. Those pictures are compressed in some way. The more you compress, the more information you lose. So, a higher bitrate will make less of a sacrifice in quality. Run yourself a few tests if you want to see what happens. Just print some tiny objects and use bitrates of say, 2000, 5000, 8000, 11000 and see what you get. I chose 12600 after a little research on Google. One thing is certain though. If you up the size of each image, you will want a higher bitrate. TO go from 640x480 to 1280x720 is to increase the total size of each picture considerably.
     
  16. JohnEsc

    JohnEsc Well-Known Member

    Joined:
    Sep 4, 2015
    Messages:
    229
    Likes Received:
    144
    Finally got around to making this upgrade, thanks @PsyVision [​IMG]
     
  17. Spoon Unit

    Spoon Unit Well-Known Member

    Joined:
    Sep 6, 2015
    Messages:
    1,561
    Likes Received:
    483
    Highly recommend you also consider dialing in the focus. There's a slight risk involved allegedly, but I didn't have any issue. I printed this and glued it to the focus ring:

    http://www.thingiverse.com/thing:211641

    To dial in the focus, I placed an item at the center of the bed with relatively small text and then tweaked the focus ring until it was sharp. It really was quite a way off by default.
     
    JohnEsc likes this.
  18. Henry feldman

    Henry feldman Well-Known Member

    Joined:
    Sep 5, 2015
    Messages:
    969
    Likes Received:
    391
    I've done it many, many times (not on the printer, on other projects) and never had an issue. Just don't treat it like a bulletproof Canon L-series lens which you can abuse, it's a flimsy delicate thing...
     
  19. JohnEsc

    JohnEsc Well-Known Member

    Joined:
    Sep 4, 2015
    Messages:
    229
    Likes Received:
    144
    Hopefully someone can help me out... since making the change to 1280 x 720, with the following:
    camera_raspi_options="-fps 10 -x 1280 -y 720"
    I have had 4 out of 6 timelapse videos not finish processing properly. When completed the videos are showing up as Zero bytes and the files don't open. I can not tell what the difference is with the two timelapse vids that created successfully. Help... I love this feature.
     
  20. Alex9779

    Alex9779 Moderator
    Staff Member

    Joined:
    Sep 4, 2015
    Messages:
    2,411
    Likes Received:
    735
    What are your options for the time lapse?
     

Share This Page