Git Product home page Git Product logo

icd's Introduction

Image Capture Service

[WIP]: this project is in an unfinished state, some of the goals of the project were not implemented. The API generated was what was being worked towards but time didn't allow for all to be completed and was used when it was good enough. The router file has what routes were actually implemented.

Use libgphoto2 to capture images using compatible cameras and expose certain functionality over a REST API as a service.

The API is generated from RAML and can be viewed here.

Setup

Fedora

sudo dnf install python-pip3 cmake valac flex bison gettext \
    libgphoto2-devel libgee-devel json-glib-devel libgda-devel libgda-sqlite \
    libgda-mysql libgda-postgres libsoup2.4-devel libxml2-devel openssl-devel \
    libxml2-devel libgtop2-devel glib2-devel meson ninja-build git

Debian/Ubuntu

sudo apt-get install python3-pip cmake valac flex bison gettext \
    libgda-5.0-dev libgee-0.8-dev libgirepository1.0-dev libglib2.0-dev \
    libgphoto2-dev libjson-glib-dev libsoup2.4-dev libssl-dev libxml2-utils \
    libgtop2-dev libgudev-1.0-dev meson ninja-build git

Common

A couple of the build dependencies are added to this repository as meson subprojects and during testing it isn't necessary to install them.

sudo pip3 install scikit-build
git clone https://gitlab.gnome.org/GNOME/template-glib
cd template-glib
meson --prefix=/usr _build
ninja -C _build
sudo ninja -C _build install
cd ..
git clone https://github.com/valum-framework/valum.git
cd valum
meson --prefix=/usr --buildtype=release _build
ninja -C _build
sudo ninja -C _build install

Cameras

USB cameras need to have the permissions changed, possibly just if the settings will be changed. The example udev rule below is for a Canon camera that was used during development.

echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="04a9", ATTR{idProduct}=="3218", MODE="0666"' | \
    sudo tee /etc/udev/rules.d/50-canon.rules >/dev/null
sudo udevadm control --reload
sudo udevadm trigger

Build/Install

git clone https://github.com/geoffjay/icd.git icd
cd icd
# During development
meson _build
ninja -C _build
# or
# For deployment
meson --prefix=/usr --sysconfdir=/etc --buildtype=plain _build
meson configure -Denable-systemd=true _build
ninja -C _build
sudo ninja -C _build install

Post Install

Valum doesn't set the library path for the VSGI .so files that are needed so this is necessary to execute icd once installed.

Fedora / Ubuntu

echo /usr/lib64/vsgi-0.4/servers | \
  sudo tee /etc/ld.so.conf.d/valum-x86_64.conf >/dev/null
sudo ldconfig

Raspberry Pi

echo /usr/lib/arm-linux-gnueabihf/vsgi-0.4/servers | \
  sudo tee /etc/ld.so.conf.d/valum-x86_64.conf >/dev/null
sudo ldconfig

Ansible

This method is what's currently used to deploy on a RaspberryPi, it hasn't been tested anywhere else.

sudo apt-get install python3-pip git
python3 -m pip install --user ansible cryptography
echo -e '\nPATH=$HOME/.local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 20
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 10
sudo update-alternatives --config python
# pick python3
git clone <not sure yet> playbook # FIXME
cd playbook
ansible-playbook icd.yml

Docker

Build and run the application using Docker.

docker build -t icd .
docker run --rm -it --privileged -v /dev/bus/usb:/dev/bus/usb -p 3003:3003 icd

Or with Docker Compose.

docker-compose up

This will put the database for the application in /usr/share/icd. This can be changed by editing the configuration file in data/config to point at a different volume that is mapped in a similar way as is done with the USB bus.

Running

Configuration

Properties

Group Name Data Type Description
general address string Service IP address to use
general port int Service port number to use
database reset boolean Flag to reset the database
database host string Database host IP address
database port int Database port number
database name string Database name
database provider string Database provider
database username string Database user name
database password string Database password
database dsn string Data service name

SQLite Sample

[general]
address = 127.0.0.1
port = 3003

[database]
reset = false
name = icd
provider = SQLite
path = /usr/share/icd/

icd's People

Contributors

dreamer-coding-555 avatar geoffjay avatar sroy66 avatar

Watchers

 avatar  avatar

Forkers

sroy66

icd's Issues

About Valum as a subproject.

I'm wondering why where not depending on the Valum wrap file to handle getting that dependency in the Dockerfile declaration?

Image storage has issues

Image data is stored in the database as a blob, it's not a major issue for low rate applications but can be if you for example run this on a Raspberry Pi with a smaller SD card. Once the disc fills there can be performance issues related to copying and deleting the data. Some databases have image types that might be supported, or this could be done instead by writing files to disc and storing the reference. The reason that wasn't done initially was concerns over someone deleting a file and breaking a reference, but that seems like a corner case that isn't worth supporting.

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.