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

feat: Add basic USB-Camera support #10

Merged
merged 21 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge branch 'main' into add_usbcam_support
Signed-off-by: Patrick Gehrsitz <mryel00.github@gmail.com>
  • Loading branch information
mryel00 committed Jun 14, 2024
commit 1c7a80f3fd18ed3076efb80346c2d90974f72f87
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## v0.14.0 (2024-06-05)

### Feat

- Expand camera control ability (#14)

## v0.13.1 (2024-06-05)

### Fix

- **install**: fix missing directory during install (#73)

## v0.13.0 (2023-07-22)

### Feat
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ all:
$(MAKE) help

install: ## Install Spyglass as service
@mkdir -p $(CONF_PATH)
@printf "\nCopying systemd service file ...\n"
@sudo cp -f "${PWD}/resources/spyglass.service" $(SYSTEMD)
@sudo sed -i "s/%USER%/$(USER)/g" $(SYSTEMD)/spyglass.service
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ A simple mjpeg server for Picamera2.
With Spyglass you are able to stream videos from a camera that is supported by [libcamera](http://libcamera.org) like
the [Raspberry Pi Camera Module 3](https://www.raspberrypi.com/products/camera-module-3/).

Current version: 0.13.0
Current version: 0.14.0

## Prerequisites

Expand Down Expand Up @@ -199,7 +199,7 @@ set up to check commit messages pre commit.

You may get the following error message when you try to push to your branch:
```
fatal: ambiguous argument 'origin/HEAD..HEAD': unknown revision or path not in the working tree.
fatal: ambiguous argument 'origin/HEAD..HEAD': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
```
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mock_use_standalone_module = true

[tool.commitizen]
name = "cz_conventional_commits"
version = "0.13.0"
version = "0.14.0"
tag_format = "v$version"
version_files = [
"spyglass/__version__.py",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
setuptools~=69.0.3
setuptools~=69.2.0
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = spyglass
version = 0.13.0
version = 0.14.0
description = A simple mjpeg server for Picamera2
url = https://github.com/roamingthings/spyglass
license = GPL-3.0-only
Expand Down
2 changes: 1 addition & 1 deletion spyglass/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.13.0"
__version__ = "0.14.0"
7 changes: 4 additions & 3 deletions spyglass/camera_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,11 @@ def get_libcamera_controls_string(camera_path: str) -> str:
ctrls_str = ""
libcam_cm = libcamera.CameraManager.singleton()
cam = libcam_cm.cameras[0]
for k, v in cam.controls.items():
def rectangle_to_tuple(rectangle):
return (rectangle.x, rectangle.y, rectangle.width, rectangle.height)

def rectangle_to_tuple(rectangle):
return (rectangle.x, rectangle.y, rectangle.width, rectangle.height)

for k, v in cam.controls.items():
if isinstance(v.min, libcamera.Rectangle):
min = rectangle_to_tuple(v.min)
max = rectangle_to_tuple(v.max)
Expand Down
22 changes: 3 additions & 19 deletions spyglass/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main(args=None):
parse_autofocus(parsed_args.autofocus),
parsed_args.lensposition,
parse_autofocus_speed(parsed_args.autofocusspeed),
parsed_args.controls,
controls,
parsed_args.upsidedown,
parsed_args.flip_horizontal,
parsed_args.flip_vertical,)
Expand All @@ -67,12 +67,12 @@ def main(args=None):

# region args parsers


def resolution_type(arg_value, pat=re.compile(r"^\d+x\d+$")):
if not pat.match(arg_value):
raise argparse.ArgumentTypeError("invalid value: <width>x<height> expected.")
return arg_value


def control_type(arg_value: str):
if '=' in arg_value:
return arg_value.split('=')
Expand All @@ -87,13 +87,6 @@ def orientation_type(arg_value):
raise argparse.ArgumentTypeError(f"invalid value: unknown orientation {arg_value}.")


def orientation_type(arg_value):
if arg_value in option_to_exif_orientation:
return option_to_exif_orientation[arg_value]
else:
raise argparse.ArgumentTypeError(f"invalid value: unknown orientation {arg_value}.")


def parse_autofocus(arg_value):
if arg_value == 'manual':
return libcamera.controls.AfModeEnum.Manual
Expand All @@ -120,20 +113,11 @@ def split_resolution(res):
raise argparse.ArgumentTypeError("Maximum supported resolution is 1920x1920")
return w, h


def control_type(arg_value: str):
if '=' in arg_value:
return arg_value.split('=')
else:
raise argparse.ArgumentTypeError(f"Invalid control: Missing value: {arg_value}")


# endregion args parsers


# region cli args


def get_args(args):
"""Parse arguments passed in from shell."""
return get_parser().parse_args(args)
Expand Down Expand Up @@ -188,11 +172,11 @@ def get_parser():
help='Define camera controls to start with spyglass. '
'Input as a long string.\n'
'Format: <control1>=<value1> <control2>=<value2>')
parser.add_argument('--list-controls', action='store_true', help='List available camera controls and exits.')
parser.add_argument('-tf', '--tuning_filter', type=str, default=None, nargs='?', const="",
help='Set a tuning filter file name.')
parser.add_argument('-tfd', '--tuning_filter_dir', type=str, default=None, nargs='?',const="",
help='Set the directory to look for tuning filters.')
parser.add_argument('--list-controls', action='store_true', help='List available camera controls and exits.')
parser.add_argument('-n', '--camera_num', type=int, default=0, help='Camera number to be used')
return parser

Expand Down
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.