Giter Site home page Giter Site logo

sjcam's Introduction

sjcam

A python CLI tool for controlling SJCAM WiFi Sports Cameras

installation

As far as I know, the only dependancies not catered for by the installation script are VideoLAN, used for viewing a live stream from the camera and opencv. To install under Ubuntu:

sudo apt-get install vlc python-opencv

For other ditros, visit the home pages for more info:

http://www.videolan.org/

http://opencv.org/

To install sjcam:

sudo python ./setup.py install

usage

Running the script with no arguments will show a help screen:

sjcam

Usage: /usr/local/bin/sjcam <COMMAND> [ARG(s)] [<COMMAND> [ARG(s)] ...]

Commands:

   BLAM                                   BlamCam mode - detect bullet hits on target (auto switch to PHOTO mode)
   CONFIG                                 Show camera config and status
   DATE <YYYY-MM-DD>                      Set camera date
   DEBUG <OFF | ON>                       Set DEBUG printing
   DIR                                    Show PHOTO and MOVIE directory listing
   GET <FILE>                             Copy file from camera to local storage
   IP <ADDRESS>                           Set IP address (default 192.168.1.254)
   MODE <[T]MOVIE | [T]PHOTO>             Set camera to [TIMED] MOVIE or PHOTO mode
   PASS <PASSWORD>                        Set WiFi PASSWORD (will not take effect until disconnect/reconnect)
   PATH <FILE PATH>                       Set PATH for saving snapshots and movies (default ./)
   PING                                   Check camera is visible and connectable on network
   PREVIEW                                View low-res PHOTO preview image (auto switch to PHOTO mode)
   SET <PARAMETER> <VALUE>                Set camera config ('?' to list parameters and/or values)
   START                                  START MOVIE recording (auto switch to MOVIE mode)
   STOP                                   STOP MOVIE recording or TIMED PHOTO
   SYNC                                   Synchronise camera TIME & DATE with host
   [G|V]SNAP                              Take a snapshot and optionally [V]iew and/or [G]et it (auto switch to PHOTO mode)
   SSID <SSID>                            Set WiFi SSID (will not take effect until disconnect/reconnect)
   STREAM                                 View live video stream (auto switch to MOVIE mode)
   TIME <HH:MM:SS>                        Set camera clock

Commands will be executed sequentially and must be combined as appropriate.

Most commands are self explanatory.

viewing camera config settings

sjcam config

Camera config:

  Movie_Resolution: 720P_1280x720_60fps
  Cyclic_Record: Off
  HDR/WDR: On
  1012: 0
  Motion_Detection: On
  Audio: Off
  Date_Stamping: On
  2010: 3
  Videolapse: Off
  Photo_Image_Size: 8M_3264x2448
  1005: 0
  Sharpness: Strong
  White_Balance: Auto
  Colour: Colour
  ISO: 100
  Exposure: +0.0
  Anti_Shaking: On
  Frequency: 60Hz
  Rotate: Off
  Default_Setting: Cancel
  Format: Cancel
  Auto_Power_Off: Off
  3003: 0
  3004: 0
  Language: English

Parameter names and values are translated to a keyword format that is easy to cut & paste for SET commands. Parameters that have not yet been reverse engineered or cannot be changed using the SET command are shown as their original numeric value.

setting camera parameters

Changeable parameters can be set using the SET command, followed by parameter name and value. To get a full list of parameters and values, use:

sjcam set ? ?

SET config help:

  Default_Setting: Cancel, OK
  HDR/WDR: Off, On
  Language: English, French, Spanish, Polish, German, Italian, Unknown_1, Unknown_2, Russian, Unknown_3, Unknown_4, Unknown_5, Portugese
  Rotate: Off, On
  Format: Cancel, OK
  Exposure: +2.0, +5/3, +4/3, +1.0, +2/3, +1/3, +0.0, -1/3, -2/3, -1.0, -4/3, -5/3, -2.0
  Frequency: 50Hz, 60Hz
  Auto_Power_Off: Off, 3_Minutes, 5_Minutes, 10_Minutes
  Anti_Shaking: Off, On
  Movie_Resolution: 1080FHD_1920x1080, 720P_1280x720_60fps, 720P_1280x720_30fps, WVGA_848x480, VGA_640x480
  Cyclic_Record: Off, 3_Minutes, 5_Minutes, 10_Minutes
  Videolapse: Off, 1_Second, 2_Seconds, 5_Seconds, 10_Seconds, 30_Seconds, 1_Minute
  Motion_Detection: Off, On
  Audio: Off, On
  ISO: Auto, 100, 200, 400
  Colour: Colour, B/W, Sepia
  White_Balance: Auto, Daylight, Cloudy, Tungsten, Flourescent
  Sharpness: Strong, Normal, Soft
  Date_Stamping: Off, On
  Photo_Image_Size: 12M_4032x3024, 10M_3648x2736, 8M_3264x2448, 5M_2592x1944, 3M_2048x1536, 2MHD_1920x1080, VGA_640x480, 1.3M_1280x960

To get the list of values for a specific parameter, use e.g.:

sjcam set Photo_Image_Size ?

SET config help:

  Photo_Image_Size: 12M_4032x3024, 10M_3648x2736, 8M_3264x2448, 5M_2592x1944, 3M_2048x1536, 2MHD_1920x1080, VGA_640x480, 1.3M_1280x960

To change a parameter, specify the parameter name and new value:

sjcam set Photo_Image_Size 2MHD_1920x1080

Setting Photo_Image_Size to 2MHD_1920x1080
  OK

special parameters

There are two 'parameters' that are actually executable functions: Format and Default_Setting.

Format will wipe the SD card and Default_Setting will set all parameters back to defaults.

There is no 'are you sure?' prompt, so running the command:

sjcam set format ?

SET config help:

  Format: Cancel, OK

shows the options, and:

sjcam set format ok

Setting format to ok
  OK

will immediately wipe your SD card. Use with caution!

sjcam dir

Camera directory:

  PHOTO:


  MOVIE:

BlamCam mode

BlamCam mode was the main reason for writing this code in the first place. The idea is that you place the camera in front of a target, then monitor it from the firing point. The camera on its own would be very useful for this, but with a bit of image processing it can be even more so. Accordingly, in this mode, each time you press a key a new image is taken and compared to the last. The difference should be the most recent shot, which will be highlighted. You can also review previous shots at any time, which will highlight each shot in situ on the current target image.

BlamCam

known issues / further development

Since there is no published API for this type of camera, it was reverse engineered by sniffing packets from the Android app. Not all settings visible on the camera can be changed from the app, so some things are still unknown or may be incorrect.

There are several tools out there for doing this, and I used one that allows sniffing of only the local network traffic without rooting the phone:

https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture&hl=en_GB

It's a bit clunky and doesn't have any kind of filtering support, so you have to wade through a lot of irrelevant data to find the packet you're looking for, but it was easy to install and run and got the ball rolling, so I stuck with it.

I only have access to the SJ4000 camera, so it's possible other cameras behave completely differently - please let me know your experiences!

Commands can be tested by sending them directly to the camera using a browser. For example, to change the WiFi name:

http://192.168.1.254/?custom=1&cmd=3003&str=%22MyShinySJ4000%22

If you find any new or useful commands, please email me details, or send me a pull request. I have commented some as yet unexplored options in sj4000.py

At some point, it would be nice to have a GUI.

Need to add GET option to video start/stop...

Need to fix camera directory to show file sizes, dates etc. (strange problem with BS4)

Find better lens options for BlamCam (in progress)

Really really need a better GUI for BlamCam!

sjcam's People

Contributors

adamlaurie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sjcam's Issues

API Documentation

Hey, I'm working on API documentation and I have some commands that you haven't got yet, but I'm not too sure if those are specific to the 5000x elite or also for the 4000. Take a look :)

Feature Request: Change network settings

I'm not sure if someone tried to change network address so you can monitorize several camera streams with a single computer (without changing from one wifi to another).

I'd like to see this implemented.

Setup configuration fails (debian)

First hurdle encountered after initially running: sudo python ./setup.py install

output:

[...]
Installed /usr/local/lib/python2.7/dist-packages/sjcam-1.0-py2.7.egg
Processing dependencies for sjcam==1.0
Searching for lxml
Reading https://pypi.python.org/simple/lxml/
Best match: lxml 4.2.5
Downloading https://files.pythonhosted.org/packages/4b/20/ddf5eb3bd5c57582d2b4652b4bbcf8da301bdfe5d805cb94e805f4d7464d/lxml-4.2.5.tar.gz#sha256=36720698c29e7a9626a0dc802ef8885f8f0239bfd1689628ecd459a061f2807f
Processing lxml-4.2.5.tar.gz
Writing /tmp/easy_install-cACsIA/lxml-4.2.5/setup.cfg
Running lxml-4.2.5/setup.py -q bdist_egg --dist-dir /tmp/easy_install-cACsIA/lxml-4.2.5/egg-dist-tmp-yVehX0
Building lxml version 4.2.5.
Building without Cython.
ERROR: /bin/sh: 1: xslt-config: not found

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt 
In file included from src/lxml/etree.c:662:0:
src/lxml/includes/etree_defs.h:14:31: fatal error: libxml/xmlversion.h: No such file or directory
compilation terminated.
Compile failed: command 'x86_64-linux-gnu-gcc' failed with exit status 1
/tmp/easy_install-cACsIA/lxml-4.2.5/temp/xmlXPathInitHw2meW.c:2:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
 main (int argc, char **argv) {
 ^
error: Setup script exited with error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

The following installation solved this issue:
sudo apt-get install python-dev libxml2-dev libxslt1-dev zlib1g-dev

However, after the setup script is done setting up, I tried running some of the commands to test the API functionality but get the following errors:

(venv) peter@boop-Latitude-E6420:~/Documents/Programming/sjcam$ sjcam config
/home/peter/.local/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.23) or chardet (2.3.0) doesn't match a supported version!
  RequestsDependencyWarning)
/home/peter/.local/lib/python2.7/site-packages/requests/__init__.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
  warnings.warn(warning, RequestsDependencyWarning)

  Camera config:
    Failed! Couldn't read config!

I tried deactivating the virtual environment but still got the same error messages.

packaging for arch linux

Hi Adam,

Just FYI, I packaged your sjcam tool

https://github.com/AdamLaurie/sjcam

on AUR (Arch linux User Repositories)

https://aur.archlinux.org/packages/sjcam-git/

I couldn't find the license so I choose GPL (let me know if that's
wrong to change it) related with #5

Thanks for coding sjcam, is nice to operate a camera without get it
out of the case.

I use a sjcam M20 and works perfectly!

If I found time I would like to connect to camera without loose the
internet connection (but that's related with network manager). In any
case, if I found how to do it will open a PR on your repo.

Cheers,
Alberto

Camera Ultra Technology Bold3 black edition

Hey, how you doing?
A few days ago I bought a BOLD3 Black edition sports camera from Ultra Technology, similar to the jscam, both in firmware interface design and in the case.
I found your code because I have integration plans with arduino, and I'm using a nodeMcu, but I can't make the commands work.
On the other hand, the ip assigned to me is 192.168.25.101, and if I log in to 192.168.25.1, I can configure the camera's wifi.

Did you make any particular configuration? there's no documentation on my camera.

Thank you in advance, if I can get it to work on my camera, I can help you complete what you're missing from the list.

License ?

Hi !

I need to control automatically my sjcam and i was really glad to find this repo.

As this script is made for python2 and is no longer maintained, i would like to know if you could switch it under a more permissive license, so i can fork it for use in my projects (I would understand if you don't want to though).

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.