Coder Social home page Coder Social logo

spyglass's Issues

FR: Add support for USB cameras

The use-case we are targeting with spyglass my include setups where Raspberry Pi cameras are used along with general USB cameras.

It's important to note that spyglass will only allow to use one camera at a time (e.g. if there is more than one camera you have to start spyglass multiple times).

Spyglass should be able to use USB cameras to capture images and videos.

Questions

  • Why do we need to support USB cameras
  • Are there any other projects that suite this use-case better than wie can/will do?
  • If there are other projects does this imply performance issues on the system that we aim to support (Raspberry Pi with restricted resources)

FR: Add option to rotate the image

Sometimes camera modules will be mounted at a rotated angle. To compensate for that it would be helpful to have an option that rotates the image so it will be displayed correctly.

FR: Update what, how and when things are logged

We need to find a balance that provides enough information when spyglass is running in normal operation and the ability to have extended logging when it's neccessary to investigate some problem.

Spyglass should provide the following log levels:

  • quiet - A minimum an logging information. Mostly warnings and errors will be displayed in this mode
  • verbose - More information what's going on without low level details
  • debug - Log every detail

Since spyglass is integrated into other applications like crowsnest we need a cli argument to set logging level.

FR: Add a release process to allow versioning of the application

At the moment spyglass does not have a release process. Changes/pull requests are directly merged into the main branch.

For the future it would be nice to have a release process with versioning.

As a versioning scheme like semver seems reasonable.

At the moment there are a lot of questions:

  • How to manage last/current versions in branches?
  • How is the process of creating a new release?
    • GitHub and/or PiPy?
    • Use GitHub Actions or a custom script?

Add support for usage with Fluidd

Spyglass doesn't seem to work well with Fluidd, as it (Fluidd) adds extra parameters to the URI which Spyglass does not recognize.

http://voron0.local/webcam/?action=snapshot&cacheBust=1683694863063 (or anything) returns a 404. Browsing to it shows the stream/snapshot as expected, but Fluidd seems to always add that cacheBust parameter.

[FR] Rotation flag

It would be a great feature to rotate the image, as many camera mounts for printers are upside down (for Ender 3 at least).

Runs for a few minutes, then freezes. Errors in dmesg log.

Trying this because Klipper's Crowsnest stopped working after a recent update. I'm running mailsailos on Raspberry Pi 4 with Raspberry Pi HQ camera connected via ribbon cable. Spyglass runs for a random amount of time (usually less than 5 minutes) and then image hangs. I check dmesg log and see this:

[ +19.760237] bcm2835-codec bcm2835-codec: Failed setting ctrl 00990a67, ret -3
[Jul26 10:36] edt_ft5x06 10-0038: Unable to fetch data, error: -121
[  +1.050539] i2c-bcm2835 fe205000.i2c: i2c transfer timed out
[  +0.000028] edt_ft5x06 10-0038: Unable to fetch data, error: -110

Restarting Spyglass works... but only for a few minutes at most, then errors out again.

NOTE: The first message in the log there happens when it starts, the other two when it freezes.

Typo on autofocus description and default example

in the description for autofocus it lists two options, there is a typo for the option "continuous", it is currently listed as "continous"
also in the "Starting the server without any argument" default example the same typo for continuous is shown.

Screenshot 2023-02-03 231143

Documentation for adding Spyglass as a service

I added Spyglass as a systemctl service, so it autostarts and is controllable like crowsnest. This could maybe be added to the Readme:

Step 1: Create and open a service description
sudo nano /etc/systemd/system/spyglass.service

Step 2: Insert the following text:

[Unit]
Description=Spyglass

[Service]
Type=simple
ExecStart=/usr/bin/python3 /run.py

[Install]
WantedBy=multi-user.target

Step 3: Reload systemcontrol
sudo systemctl daemon-reload

Step 4: Enable Autostart of Spyglass
sudo systemctl enable spyglass.service

Step 4.5: Maybe you have to disable crowsnest first, to prevent port collision:
sudo systemctl stop crowsnest.service && sudo systemctl disable crowsnest.service

Step 5: Start your new Spyglass Service:
sudo systemctl start spyglass.service

Note that as far as I know, this only works on debian-based systems like Raspberry Pi OS and MainsailOS

Image noise getting worse after very first frame taken when service is up

Very funny situation on my use case, when I use a resolution like "1920x1440", with "vr90" option, after restart spyglass and keep refreshing the snapshot endpoint till I get the very first image, the very first image is pretty good, but the second onward is VERY noisy ๐Ÿ˜ญ

Image 1:
image

Images after first snapshot call:
image

Do you have any idea what can be causing this?
I'm using tunning file: https://github.com/raspberrypi/libcamera/blob/main/src/ipa/rpi/pisp/data/ov5647_noir.json

Issue with Spyglass starting

I followed the instructions to install Spyglass as a service but when trying to start it I get the following

spyglass.service - spyglass - Picamera2 MJPG Streamer
   Loaded: loaded (/etc/systemd/system/spyglass.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Wed 2023-02-15 22:40:49 GMT; 2s ago
     Docs: https://github.com/roamingthings/spyglass
  Process: 9073 ExecStart=/usr/local/bin/spyglass (code=exited, status=1/FAILURE)
 Main PID: 9073 (code=exited, status=1/FAILURE)

Looking at journalctl I can see:

Feb 15 22:03:20 mainsailos systemd[1]: Started spyglass - Picamera2 MJPG Streamer.
Feb 15 22:03:20 mainsailos crowsnest[927]: Version Control: rtsp-simple-server new version available: v0.20.2 (v0.19.1).
Feb 15 22:03:20 mainsailos spyglass[920]: Python 2.7.16
Feb 15 22:03:20 mainsailos spyglass[920]: INFO: Configuration file found in /home/pi/printer_data/config/spyglass.conf
Feb 15 22:03:20 mainsailos spyglass[920]: INFO: Print Configfile: '/home/pi/printer_data/config/spyglass.conf'
Feb 15 22:03:20 mainsailos spyglass[920]:                 NO_PROXY="true"
Feb 15 22:03:20 mainsailos spyglass[920]:                 HTTP_PORT="8080"
Feb 15 22:03:20 mainsailos spyglass[920]:                 RESOLUTION="640x480"
Feb 15 22:03:20 mainsailos spyglass[920]:                 FPS="15"
Feb 15 22:03:20 mainsailos spyglass[920]:                 STREAM_URL="/stream"
Feb 15 22:03:20 mainsailos spyglass[920]:                 SNAPSHOT_URL="/snapshot"
Feb 15 22:03:20 mainsailos spyglass[920]:                 AUTO_FOCUS="continuous"
Feb 15 22:03:20 mainsailos spyglass[920]:                 FOCAL_DIST="0.0"
Feb 15 22:03:20 mainsailos spyglass[920]:                 AF_SPEED="normal"
Feb 15 22:03:20 mainsailos spyglass[920]: Traceback (most recent call last):
Feb 15 22:03:20 mainsailos spyglass[920]:   File "/home/pi/spyglass/run.py", line 3, in <module>
Feb 15 22:03:20 mainsailos spyglass[920]:     from spyglass.cli import main
Feb 15 22:03:20 mainsailos spyglass[920]:   File "/home/pi/spyglass/spyglass/cli.py", line 121
Feb 15 22:03:20 mainsailos spyglass[920]: SyntaxError: Non-ASCII character '\xc2' in file /home/pi/spyglass/spyglass/cli.py on line 121, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details
Feb 15 22:03:20 mainsailos systemd[1]: spyglass.service: Main process exited, code=exited, status=1/FAILURE
Feb 15 22:03:20 mainsailos systemd[1]: spyglass.service: Failed with result 'exit-code'.

OS info

cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_ID="11"
VERSION="11 (bullseye)"
VERSION_CODENAME=bullseye
ID=raspbian
ID_LIKE=debian

run.py camera init sequence did not complete failed to acquire camera

pi@VzBot:~ $ spyglass/run.py
INFO:root:Spyglass 0.13.0
[0:11:41.291767898] [1709]  INFO Camera camera_manager.cpp:297 libcamera v0.0.5+83-bde9b04f
[0:11:41.321646339] [1710]  INFO RPI vc4.cpp:437 Registered camera /base/soc/i2c0mux/i2c@1/imx708@1a to Unicam device /dev/media0 and ISP device /dev/media2
[0:11:41.321728469] [1710]  INFO RPI pipeline_base.cpp:1101 Using configuration file '/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml'
INFO:picamera2.picamera2:Initialization successful.
[0:11:41.324097467] [1709]  INFO Camera camera.cpp:840 Pipeline handler in use by another process
ERROR:picamera2.picamera2:Camera __init__ sequence did not complete.
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 242, in __init__
    self._open_camera()
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 446, in _open_camera
    self.camera.acquire()
RuntimeError: Failed to acquire camera: Device or resource busy

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/pi/spyglass/run.py", line 6, in <module>
    raise SystemExit(main())
  File "/home/pi/spyglass/spyglass/cli.py", line 44, in main
    picam2 = init_camera(
  File "/home/pi/spyglass/spyglass/camera.py", line 26, in init_camera
    picam2 = Picamera2(tuning=tuning)
  File "/usr/lib/python3/dist-packages/picamera2/picamera2.py", line 254, in __init__
    raise RuntimeError("Camera __init__ sequence did not complete.")
RuntimeError: Camera __init__ sequence did not complete.

I have just switched from crowsnest to spyglass and when I run the script I get the above. Help is much appreciated.
I'm trying to get my pi cam v3 wide to work on my printer

Impossible to install spyglass!!

hi,
few hours ago i try to install spyglass for use a pi camerza module 3 with mainsail and crowsnest.
but when i launch command i have ab error and when i clone manually the repo impossible to launch install what s wrong?
WM-Screenshots-20230528020020

can you tell me how install it on my pi 4 please?

i ve tried that:
cd ~

git clone https://github.com/roamingthings/spyglass

cd spyglass

./run.py

but no way i ve tried wit sudo too but same results. i ve tried to create folder manually with no results again

FR: Allow customisation of all camera controls offered by picamera2

Picamera2 provides a rich set of camera controls that allow to adjust the camera operation.

Spyglass should allow the user to configure these controls to optimize image, stream and video quality.

Questions

  • How should the controls be configured?
    • cli
    • configuration file (specified by cli argument)
    • HTTP/REST endpoint
  • Should it be possible to update the controls during streaming or just at the start of spyglass?

FR: Enable HDR for RPi camera v3

The Raspberry Pi camera module v3 is able to capture images in HDR (high dynamic range).

Configuration of the feature is a bit more complex. In addition an Profile has to be enabled.

Missing directions

When installing you have the user CD to ~/spyglass.

That directory hasn't been made, as you failed to include the portion where we should clone the repository (including the sometimes tricky addresses git likes to make).

Add the clone portion to be more in line with the platform you are developing for.

Reduce resource usage of spyglass

I have been experiencing MCU 'mcu' shutdown: Timer too close errors lately suggesting that my RPi is overloaded.
I noticed that spyglass service is running 8 processes and consuming over 30% cpu.
image

Is there any option to reduce this?

I have unsuccessfully tried:

  • updating to the latest spyglass
  • looking through your code, but haven't seen where you specify the number of handlers for a server or a way to reduce threads.
  • reduce the resolution of the camera

In a resource constrained situation, I would rather have the camera server fail / be reduced to snapshots than the print shutting down.

was working until last apt upgrade has been done for bullseye on my raspi 5 using picamera module 3

previously it worked fine, but I did an "sudo apt update and upgrade" a few days ago and now I'm getting the following error:

Traceback (most recent call last):
File "/home/pi/spyglass/./run.py", line 3, in
from spyglass.cli import main
File "/home/pi/spyglass/spyglass/cli.py", line 10, in
import libcamera
File "/usr/lib/python3/dist-packages/libcamera/init.py", line 4, in
from ._libcamera import *
ImportError: /usr/lib/python3/dist-packages/libcamera/_libcamera.cpython-311-aarch64-linux-gnu.so: undefined symbol: _ZN9libcamera8controls3rpi15PispStatsOutputE

My OS:
Distributor ID: Debian
Description: Debian GNU/Linux 12 (bookworm)
Release: 12
Codename: bookworm

Error during install as service - missing config directory

Hi,

I am not using this with any printer software. It seems spyglass was made for some software that uses the path ~/printer_data/config

I assume there is a missing mkdir ~/printer_data/config somewhere. I might create a PR for this, but if I do I would also change the config dir to /etc/spyglass.

How to reproduce on vanilla raspian OS:

root@hakkebo:~# git clone https://github.com/roamingthings/spyglass.git
Cloning into 'spyglass'...
remote: Enumerating objects: 443, done.
remote: Counting objects: 100% (208/208), done.
remote: Compressing objects: 100% (103/103), done.
remote: Total 443 (delta 134), reused 131 (delta 96), pack-reused 235
Receiving objects: 100% (443/443), 104.73 KiB | 674.00 KiB/s, done.
Resolving deltas: 100% (232/232), done.

root@hakkebo:~# cd spyglass/

root@hakkebo:~/spyglass# make install

Copying systemd service file ...

Copying Spyglass launch script ...

Copying basic configuration file ...
cp: cannot create regular file '/home/root/printer_data/config': No such file or directory
make: *** [Makefile:27: install] Error 1

Regards
Stian

White Balance is not working

Hey,

i am pretty sure that this is not a bug but a user error.
My pi cam is working fine but if the light situation changes a little the white balance fails.

Any recommendation how to fix this?

Any help is appreciated!

Automatic updating broken?

I've installed Spyglass following these steps:

  1. git clone https://github.com/roamingthings/spyglass.git
  2. make install
  3. Restarted the Raspberry Pi
  4. Installed the updater part inside the moonraker config.'
  5. Restarted Moonraker
  6. See Spyglass in the update list as 'Invalid'
  • Soft recovery gives: Recovery attempt failed, repo state not pristine
  • Hard recovery gives: Repo has not been verified, clone aborted

How can I fix this?

EDIT:
I've tried running make upgrade-moonraker, but still the same issue.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.