FormerLurker / Octolapse

Stabilized timelapses for Octoprint
GNU Affero General Public License v3.0
637 stars 99 forks source link

Unable to enable Custom Image Preferences #314

Closed KageKeeper closed 5 years ago

KageKeeper commented 5 years ago

If this is a feature request describe it here

FEATURE_REQUEST_DESCRIPTION_GOES_HERE

Version of Octolapse

Octolapse Version: Octolapse 0.3.4

Version of OctoPrint

OctoPrint Version: Octolapse 0.3.4 OctoPrint 1.3.10 running on OctoPi 0.15.1

When you ran into the problem, did you have diagnostic logging enabled?

Diagnostic Logging was Enabled: YES

What were you doing when the problem occurred

  1. Setting up Octolapse
  2. I am using a Pi Cam
  3. Setting up camera profile
  4. Attempting to enable 'Custom Image Preferences'

What should have happened?

I should be able to adjust my camera through the interface.

What happened instead?

When I click 'Enable and Apply Preferences Before Print', I receive the following error: Unable To Enable Custom Preferences webcam_settings_apply_error: An unexpected error was raised while testing custom image preferences for the 'PiCam' camera profile. - Inner Exception: ('Connection aborted.', BadStatusLine("''",))

Operating System running OctoPrint and Octolapse

OctoPi v 0.15.1

OS Name: OctoPrint Os Version: 1.3.10

Printer model & used firmware incl. version

Printer Model: Ender 3 Pro Printer Firmware Version: Marlin 1.1.9

Browser and version of browser, operating system running browser

Browser: Chrome Browser OS: Windows 10

Link to the gcode file you were printing when the problem occurred

Link to Gcode File: Not using any GCODE file

Link to settings.json

Link to settings.json with all passwords removed: https://pastebin.com/UZNLTdJk

Link to plugin_octolapse.log

Link to plugin_octolapse.log: https://pastebin.com/dSEjLnGq

Link to octoprint.log

Link to octoprint.log: https://pastebin.com/mahMehnu

Link to contents of Javascript console in the browser

Link to javascript console output: LINK_GOES_HERE

Screenshots and/or videos of the problem:

Screenshot/Video Links: LINKs_GO_HERE

Please consider becoming a patron

If you like this project, please support my work by becoming a patron, and consider adding a 'star' to the repository. It takes a lot of time and effort to maintain the project and respond to issues. The cost of test prints, software, cameras, printer parts, etc. can quickly add up, so every bit helps.

You can find various videos and tutorials by subscribing to my Youtube channel. You can also follow me on Twitter.

FormerLurker commented 5 years ago

Have you looked at this wiki article on the subject? Pay close attention to the necessary changes to boot/octopi.txt, which you can find here.

If you've tried that I'll dig a bit deeper :)

KageKeeper commented 5 years ago

Have you looked at this wiki article on the subject? Pay close attention to the necessary changes to boot/octopi.txt, which you can find here.

If you've tried that I'll dig a bit deeper :)

Yes. I have followed that article, and my octopi.txt file has been edited as per the troubleshooting guide.

I can view the stream from my cam, but when I attempt to enable and apply preferences before print I get the error I listed. :)

FormerLurker commented 5 years ago

Can you get to the control panel manually for mjpegstreamer:

control htm

Octolapse uses this page to control the camera.

Unfortunately there was nothing helpful in the logs. However, I noticed something odd about your settings file. The current profile guid is incorrect. Try this:

  1. Create a new camera profile from Octoprint Settings (wrench/spanner icon)->Octolapse->Camera Tab.
  2. Save the new camera profile.
  3. Set that profile to the default.
  4. Try again to get the camera and preferences working.

Did you upgrade to Octolapse V0.3.4, or did you do a fresh install? I did just completely re-write the settings code, so any bug you encountered is likely gone (though I'm sure there are lots of fresh ones :).

If you continue having trouble, I recommend you restore the default settings via Octoprint Settings (wrench/spanner icon)->Octolapse->Restore All Default Settings. Sorry about any lost settings if you have to do this. I'm working on simplifying setup right now (automatic slicer settings extraction from your gcode files), so in the future it won't be so painful...

KageKeeper commented 5 years ago

Interestingly, when I attempt to view the mjpegstreamer page, where yours says 'Camera 1', mine says 'null'. No other settings are on the page (which I would expect with a null)...

So that begs the question...wtf...I can still access my PiCam, stream it, get stills. etc.

I did create a new camera profile, as you suggested, but, as I expected, I experienced the same issue.

Seeing as how I have null listed at mjpegstreamer it makes me think that the problem is not with Octolapse at all.

Any suggestions on where to go for this issue?

FormerLurker commented 5 years ago

Hmm.. maybe you cannot control a pi camera via mjpegstreamer. I need to look into that.

I believe there are ways of controlling it from the command prompt. If so, Octolapse supports a 'Camera Init' script that runs before every print. It wouldn't be too hard to create a bash script to change the settings and run it before your prints. I don't think the picam has zoom built in (it's manual, right?)

Honestly, though, you'll get much better results with a USB webcam if you have one. They have more options (usually) and a nice long cable that makes moving the camera around easy! let me know if you need some links for altering the pi camera settings via scripts and I'll dig some up.

KageKeeper commented 5 years ago

No worries. I will look into getting a good webcam. Any suggestions? :)

FormerLurker commented 5 years ago

I like my Logitech 920. They can be found on sale all the time and have good 1080p quality. Don't get me wrong, they're not the best out there, but for the price they are very close! I'm 100% sure this camera is controllable via control.htm, and it has lots of capabilities including auto/manual focus, zoom (done via software by blowing the image up), pan and tilt (software, not motorized. Done by selectively cropping), and a lot more. I've also heard good things about the Brio, but that sucker is pricey and may be overkill.

Also, you might want to consider a DSLR if you have one. Many of them will work with Octolapse. I have a Nikon D5200, and it supports all of the necessary features to connect and control via USB. Let me know if you're interested in this.

garrathbond commented 5 years ago

I have same problem with my Pi CAM

garrathbond commented 5 years ago

any help would be usefull as I don't what to use another camera

FormerLurker commented 5 years ago

@garrathbond, have you tried looking at the wiki? Im not sure what settings mjpegstreamer supports for the picam, though. I need the get me one of those for testing.

garrathbond commented 5 years ago

Yes its since I have done this I get the issue

From: FormerLurker [mailto:notifications@github.com] Sent: 24 March 2019 02:58 To: FormerLurker/Octolapse Cc: Garrath B. Bond; Mention Subject: Re: [FormerLurker/Octolapse] Unable to enable Custom Image Preferences (#314)

@garrathbond https://github.com/garrathbond , have you tried looking at the wiki https://github.com/FormerLurker/Octolapse/wiki/Camera-Profiles#custom-image-preferences ? Im not sure what settings mjpegstreamer supports for the picam, though. I need the get me one of those for testing.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/FormerLurker/Octolapse/issues/314#issuecomment-475923626 , or mute the thread https://github.com/notifications/unsubscribe-auth/APXtz8HqeI-kdlwH0HJjyQ58IIKbOIJtks5vZum1gaJpZM4agPRe . https://github.com/notifications/beacon/APXtz_PkU_hvRQmQafNeytfo5Lm0sWJaks5vZum1gaJpZM4agPRe.gif

GR-Code commented 5 years ago

Same issue as above.

I can use Octolapse, but can't control the camera. Tried the /boot/octopi.txt fix too. Camera doesn't show up in the control panel of mjpg-streamer either (says null). Little help?

tvl83 commented 5 years ago

Same issue for me too. I am using picam. I rather not use a webcam because i got the picam specifically for this, it'd be wasted money. The zoom is manual, unfortunately

FormerLurker commented 5 years ago

I just got one of these cams, and hope to figure out what is going on with the pi cam. I've been thinking maybe i could write some bash scripts to control the settings if mjpegstreamer cant.

GR-Code commented 5 years ago

Sure thing, let us know if you manage to figure it out.

On Fri, Jul 5, 2019 at 11:25 PM FormerLurker notifications@github.com wrote:

I just got one of these cams, and hope to figure out what is going on with the pi cam. I've been thinking maybe i could write some bash scripts to control the settings if mjpegstreamer cant.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/FormerLurker/Octolapse/issues/314?email_source=notifications&email_token=AEWWYAQWH5GR6RMC63G23BLP6AGCPA5CNFSM4GUA6RPKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZKRRXY#issuecomment-508893407, or mute the thread https://github.com/notifications/unsubscribe-auth/AEWWYAUCWHGOUEN5Z24JQ4TP6AGCPANCNFSM4GUA6RPA .

mhcassiem commented 5 years ago

I'm also getting this issue, also unable to control the camera with mjpegstreamer or access custom image preferences. I have followed the wiki suggestions and edited the relevant lines in octopi.txt. Also getting the error:

Unable To Enable Custom Preferences webcam_settings_apply_error: An unexpected error was raised while testing custom image preferences for the 'Default Webcam' camera profile. - Inner Exception: ('Connection aborted.', BadStatusLine("''",))

FormerLurker commented 5 years ago

@mhcassiem, are you using a pi cam? If so I suspect some compatibility issues. I'm working to resolve those.

tvl83 commented 5 years ago

@FormerLurker i am using a picam and getting this same error.

FormerLurker commented 5 years ago

@tvl83, since control.htm is showing 'null' for the picam, I think the current settings adjustment method isn't going to work (update via get request to control.htm). The question is really do I fix this before or after releasing the next version?? Thoughts?

tvl83 commented 5 years ago

If the next version is nigh then it can probably wait.

I don't think a lot of adjustments might even be available? focus is definitely not an option. The only one I personally want is flipping the video 180 and I have a workaround for the time being.

If the fix can be directly ported to the new version without extra work then it might be worth it to fix it before release?

Thorlokk commented 5 years ago

Fwiw, I am having exact same issue with a Pi camera V1.3 on a Pi 3B...

FormerLurker commented 5 years ago

Hey, i think i have finally figured this out. Will post an update probably tomorrow once i nail down the steps to fix this.

mhcassiem commented 5 years ago

Apologies, I forgot to mention that I'm using the Pi Cam :disappointed:

Great to hear that you figured it out!

FormerLurker commented 5 years ago

OK so I'll need some volunteers to test this. It worked for me, but we all know that doesn't imply it will work for everyone :)

Also, I need to add a bit of a disclaimer. Many of the available custom image preferences in Octolapse still will NOT work even after following the steps (resolved in the next version of Octolapse), but there is a workaround I'll discuss later. This will help me to figure out how to write a guide for the raspi cam and to learn more about the various PI configurations in the wild. It should also let you change the raspi cam settings via control.htm, even if you can't in Octolapse right now.

We are basically going to load the raspi cam module on boot and will treat it like a USB camera. This will make it so that mjpg-streamer uses input_uvc.so instead of input_raspicam.so.

I'm assuming that the bcm2835-v4l2 module is already available on your pi (fingers crossed). If it is not, we will figure this out and can deal with that separately.

For now try this out, but keep in mind that if it fails you will need to UNDO these steps to get your camera stream back. That shouldn't be too difficult, and I'll help anyone that has problems.

  1. Make sure you have followed the guide for making control.htm accessible.
  2. Open a terminal connection to your pi and run the following command to edit the /etc/modules file: sudo nano /etc/modules
  3. Add the following line to the very bottom of the modules file: bcm2835-v4l2
  4. Press Ctrl+O to save the changes.
  5. Press Ctrl+X to exit the editor.
  6. Open up octopi.txt for editing by running the following command: sudo nano /boot/octopi.txt
  7. Make sure that you your camera settings looks like this: camera="auto" it should NOT be set to raspi (I'd like someone to verify this for me though to make sure it's like this for all versions of octopi)
  8. Take a look at your camera_usb_options setting and for now change it to this (you can customize it later): camera_usb_options="-r 1920x1080 -f 5"
  9. Press Ctrl+O to save the changes.
  10. Press Ctrl+X to exit the editor.
  11. Reboot your pi by running the following command: sudo reboot
  12. Wait for your pi to boot up, and try navigating to the following URL: {IP_ADDRESS_OF_PI}/webcam/control.htm You should see something like this (You will get two error messages too, just ignore them) image

That should be it. You MIGHT be able to use SOME of the custom image preferences in Octolapse (not verified since I haven't tried this on the old version of Octolapse so that I can focus on the update), but you WILL be able to use control.htm as a work around.

If you are still having problems, perhaps the bcm2835-v4l2 driver isn't on your system. First try updating and let me know if that helps. You must reboot after the update. If things still aren't working, let me know what kind of pi you have, what model camera, and if you can connect to a stream at {IP_ADDRESS_OF_PI}/webcam/?action=stream.

I REALLY hope this nails the issue. If anyone's willing to do a performance comparison between the input_raspicam.so (default octopi config for raspi cams) and this version, I'd LOVE to see that.

Thanks!

Thorlokk commented 5 years ago

I tried it, it works! I tried adjusting Brightness, Contrast, Saturation, and Auto Exposure with Exposure Time.. all works. The streaming quality is worse, but may be because the default bitrate is lower than on the input_raspicam.so version. I tried bumping it up and it did get better. Not sure about performance comparison between the two because I think we'd have to make sure compression was set the same for both to compare. Let me know if you want me to try any other settings..

FormerLurker commented 5 years ago

@Thorlokk, try navigating to {IP_ADDRESS_OF_PI}/webcam/control.htm, and adjust the 'Video Bitrate' setting. I find that increasing it by about 50% seems to give a really good video, but your mileage may vary.

Let me know if that helps, and THANK YOU for trying this out. I'm excited to hear about other attempts.

This was a very difficult issue to work out, and I'm SO SO glad that progress has been made! The next release of Octolapse will have a custom raspicam settings page, and you'll be able to access all of the settings that are available.

Edit.. Whoops, I see that you have already done this (read your reply on my phone and missed that), LOL!

Thorlokk commented 5 years ago

Ya.. it seems like bumping up video bitrate to around 100% brings it closer to the raspi cam quality. And thank YOU for getting it working, and for all your work on this!!

rossome2648 commented 5 years ago

Worked for me! Can enable Enable And Apply Preferences Before Print. Will be messing around with the settings. Thanks for the fix!

FormerLurker commented 5 years ago

@rossome2648, so good! That's 2 out of 2. I'm feeling pretty good about this one.

rossome2648 commented 5 years ago

@FormerLurker - I got that working but now it only takes the snapshot after it does a skirt for some reason. Doesn't for the rest of the print. I have logs attached - I canceled the print after about 7 layers with only one snapshot after the skirt (which I have no idea why it's doing it after the skirt). Not sure if it's related but it would be nice to have this working!

Edit: I cleared out the previous diagnostic file and started a new, quick print and logged it. plugin_octolapse.log

FormerLurker commented 5 years ago

@rossome2648,

Can you create a new issue here for this? I'll probably need your gcode file as well as your settings.json file, which you can download from OctoPrint Settings (wrench/spanner icon)->Octolapse. I already have your log. If you weren't using the 'layer trigger-compatibility' snapshot profile, you might want to give that a go. From what I saw in the log, it could be due to 'high quality' mode, which has been removed from the next soon-to-be-released version because of issues like this. Let me know.

rossome2648 commented 5 years ago

@FormerLurker done. https://github.com/FormerLurker/Octolapse/issues/364 Thanks for the help!

FormerLurker commented 5 years ago

So, some progress. I've been able to get three types of webcam control pages working:

  1. Dynamically generated settings based on input.json that mjpgstreamer provides.
  2. A custom page for the Logitech C920 camera
  3. A custom page for the raspberry pi camera module V2

There are some issues with the pi controls that I haven't worked out. I can't seem to turn off image stabilization without some tricks (disable stabilization, click either flip check box, click it again). Also, the exposure range seems off, and it only works at the lower end of the range. I think I can deal with that. There are a lot of interconnected controls to figure out, and I'm sure I won't get everything perfect, but it's a huge step up over the original. I may add a button to use the dynamically generated page instead of the custom page in case I mess up some of the interconnections (which is likely).

Here's a snapshot of what I have for the picam so far:

image

I also added the option to view in one or two columns, since some of the sliders are a bit sensitive: image

The Logitech page looks very similar, but is customized based on the available controls. I'm much more confident that one is working properly.

Thoughts? Ideas? Comments?

Edit: I pasted the wrong image for the single column view initially.

Thorlokk commented 5 years ago

Looking great! Will be nice to be able to easily adjust the exposure for those white filament prints on the black print bed!

FormerLurker commented 5 years ago

Thanks @Thorlokk! Exposure is HORRIBLE with white. Either it glows like the sun, or everything else is too dark. That's one place where the C920 is not good. Perhaps there is a way to get it right, but I've never found the perfect balance.

Lewis-Hashbrown commented 5 years ago

Just want to say thank you for the guide. I had to update raspbian for it to work but after that I've now got the control menu!

Just because I struggled if you're on windows to get into the terminal (SSH) I used a puTTy guide https://www.raspberrypi.org/documentation/remote-access/ssh/windows.md

Just noticed when I turn the Raspberry pi off it loses the control settings, Anyway to permanently save them?

FormerLurker commented 5 years ago

@Lewis-Hashbrown,

There is no way to do this now really, at least not for most of the settings. There will be in the next version of Octolapse. See this for more info: https://youtu.be/7Xr2ED5Utak

Lewis-Hashbrown commented 5 years ago

Ah ok no worries! Just watched through the video and can't wait for the new version!

Thanks for all the help!

FormerLurker commented 5 years ago

I completed this a while back, but neglected to post it for anyone who wants to get the picam working for the next version of Octolapse: https://github.com/FormerLurker/Octolapse/wiki/Configuring-a-Raspberry-Pi-Camera

Since the picam (at least v2) is now fully supported in Octolapse, and controls are fully supported when using mjpgstreamer, I'm going to go ahead and close this issue. Feels great!

Thanks to everyone who contributed here since this has really improved Octolapse for the average user!

DuckersMcQuack commented 2 years ago

I completed this a while back, but neglected to post it for anyone who wants to get the picam working for the next version of Octolapse: https://github.com/FormerLurker/Octolapse/wiki/Configuring-a-Raspberry-Pi-Camera

Since the picam (at least v2) is now fully supported in Octolapse, and controls are fully supported when using mjpgstreamer, I'm going to go ahead and close this issue. Feels great!

Thanks to everyone who contributed here since this has really improved Octolapse for the average user!

I did this now, and after i set up the camera, i started a print, but now printer just starts to move X, Y and Z, but not E and pretends to print without even heating up.