Giter Site home page Giter Site logo

sony_camera_api's Introduction

Build Status

Pysony

python sony camera api

Install

using pip:

pip install pysony

using repo:

git clone https://github.com/Bloodevil/sony_camera_api.git
python setup.py install

Running tests

You will likely want to set up a virtualenv first and complete the following steps inside it.

Install requirements:

pip install -r test-requirements.txt

Run tests:

python -m unittest discover

(The run_tests.sh script does both of these automatically)

By default, the test suite verifies behavior locally using dummy services.

If you want to run tests live against your real camera, connect to the camera's wireless access point and set the TEST_LIVE_CAMERA environment variable. For example:

TEST_LIVE_CAMERA=1 python -m unittest discover

CAUTION: Use with your camera at your own risk. This is free software that offers no warranty. For details, see LICENSE.

Usage

simple example:

>>> api = pysony.SonyAPI()
>>> api.getAvailableApiList()

api_list

there api list that you can use.

branches

  • develop : please request merge here.
  • master : pip live

examples

liveview

  • can see the photo via liveview

timer

  • take a picture every n seconds

dump_camera_capabilities

  • show every supported api list

pyLiveView

  • Released under the GPL v2 (or later) by Simon Wood ([email protected])
  • Sample application to connect to camera, and start a video recording
  • with or without a GUI LiveView screen

sony_camera_api's People

Contributors

bjmc avatar bloodevil avatar chjr avatar dlahacz avatar juiceboxsingularity avatar mungewell avatar wenoptics avatar yeajishin 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sony_camera_api's Issues

scan_for_cameras.py not working for sony alpha 7r

Hello,

I connected my sony alpha 7r camera to the laptop via wifi and then ran python src/example/scan_for_cameras.py
But it is not able to detect the camera. Can this api work for the sony alpha 7r

Please help!

Unable to 'setShootMode'

Not sure how I should be issuing commands, but the following fails on my cameras

      camera = SonyAPI()
      mode = camera.getAvailableShootMode()
      if (mode['result'])[0] != 'movie':
         if 'movie' in (mode['result'])[1]:
            camera.setShootMode("movie")
         else:
            print "'movie' mode not supported"

Which seems to be getting fragmented to the following in 'def _cmd(self, method=None, param=[]):',

{'version': '1.0', 'params': ['m', 'o', 'v', 'i', 'e'], 'method': 'setShootMode', 'id': 1}

Possible to choose which interface to search on?

Hello,
I'm running VirtualBox sharing USB WIFI-dongle as Bridged Adapter from Windows. My virtualbox seems to have two network cards.

Also when running on Raspberry PI I have 3 network cards (1 wired and 2 WIFI).

By default dump_camera_capabilities.py does not find any camera. I need to modify __bind_sockets() and add .bind() to choose which interface should be searched. Like this:

    self.__udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    self.__udp_socket.bind(('192.168.122.178',0))
    self.__udp_socket.settimeout(0.1)

192.168.122.178 is IP which I get from camera.

Is there a way to search all interfaces and select which camera should be used?
I guess there may be several cameras found on different interfaces.

upload to pypi

upload to pypi.

After upload to pypi, people can use more easily than before.

_cmd Method from pysony.py is missing minversion variable

Method signature

def _cmd(self, method=None, param=[], target=None)://Line 283, pysony.py

Adding the variable with a default value of 1.0 to the method works.

It also does not have the verison variable.

final signature looks like

def _cmd(self, method=None, param=[], target=None, version=1.0, minversion="1.0")

Live view

Sir, could you please add a python program to stream a live view in qt5 using opencv

make runtest

make runtest frame for tttttttttttttttteeeeeeeeeeeeeeeeeeeeesssssssssssssssssssttttttttttttttttttttt

  • need get camera data stream.

zoom sony camera

I'm new to programming. Could you please create a code to zoom the camera as i feel its hard to create one.

'BULB' shooting

My A5000 offers 'BULB' as a shutter speed, but I have be unable to get this to function via the Remote API. Camera will take a 'BULB' picture with the 'Smart Remote' app running, whilst I hold the shutter button down.

I extended 'pysony.py' with

diff --git a/src/pysony.py b/src/pysony.py
index 9dac7a9..ea79f9e 100755
--- a/src/pysony.py
+++ b/src/pysony.py
@@ -1066,3 +1066,8 @@ class SonyAPI():
     def getSupportedWirelessFlashSetting(self):
         return self._cmd(method="getSupportedWirelessFlashSetting")
 
+    def startBulbShooting(self):
+        return self._cmd(method="startBulbShooting")
+
+    def stopBulbShooting(self):
+        return self._cmd(method="stopBulbShooting")

And am using the attached example script. Anyone got suggestions, this doesn't seem to be documented in the latest API, but I've seen comments that it is (/was) supported in '2.20'
bulb_test.py.txt

Cannot discover camera

I tried your code and it keeps timing put as I do search.discover(5) However I pinged the ip address of the camera and it shows 0% packet loss when my pc is connected to camera's access point. Could you please give me some tips?

Send captured images to computer.

Sir, could you also add a python program to send the captured images to computer via WIFI. Note:- I am using a raspberry pie, so the Sony play memories does not support in the same.

NEX6 scan_for_cameras.py not working

hey there
after connecting to NEX6 wifi ap i try to run scan_for_cameras.py
i am getting the error message:

Traceback (most recent call last):
File "scan_for_cameras.py", line 5, in
cameras = search.discover(5)
File "build/bdist.linux-armv7l/egg/pysony.py", line 53, in discover
File "build/bdist.linux-armv7l/egg/pysony.py", line 69, in _listen_for_discover
UnboundLocalError: local variable 'host' referenced before assignment

What am i doing wrong please?

Unable to 'setLiveviewFrameInfo()'

`
$ python
Python 2.7.9 (default, Apr 2 2015, 15:34:55)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.

import pysony
camera = pysony.SonyAPI(QX_ADDR='http://192.168.122.1:8080/')
camera.setLiveviewFrameInfo([{"frameInfo": True}])
Trying.. {"version": "1.0", "params": [], "method": "getAvailableApiList", "id": 1}
Traceback (most recent call last):
File "", line 1, in
File "build/bdist.linux-i686/egg/pysony.py", line 229, in setLiveviewFrameInfo
File "build/bdist.linux-i686/egg/pysony.py", line 168, in _cmd
File "build/bdist.linux-i686/egg/pysony.py", line 146, in _truefalse
AttributeError: 'dict' object has no attribute 'lower'
`

uPNP does not find FDR-X1000V

as reported by @toufraita.

'src/example/dump_camera_capabilities.py' script does not find camera, but capabilities do list if QX_ADDR is manual set to correct IP.

This is probably an issue with the big regular expression which attempts to pull the IPs out of the XML file that the camera 'sends'. (note: QX10 has an extra space which we needed to appreciate). Script know to work on QX10, AS15 and HX60V at present.

X1000V is in the same group as AS200, so there code base is likely the same
https://developer.sony.com/develop/cameras/

Try some extra prints to see if there's something obvious, or upload the XML file for inspection....

    def _parse_device_definition(self, doc):
        """
        Parse the XML device definition file.
        """
        dd_regex = ('<av:X_ScalarWebAPI_Service>'
            '\s*'
            '<av:X_ScalarWebAPI_ServiceType>'
            '(.+?)'
            '</av:X_ScalarWebAPI_ServiceType>'
            '\s*'
            '<av:X_ScalarWebAPI_ActionList_URL>'
            '(.+?)'
            '/sony'                               # and also strip '/sony'
            '</av:X_ScalarWebAPI_ActionList_URL>'
            '\s*'
            '<av:X_ScalarWebAPI_AccessType\s*/>'  # Note: QX10 has 'Type />', HX60 has 'Type/>'
            '\s*'
            '</av:X_ScalarWebAPI_Service>')

        services = {}
+       print doc
        for m in re.findall(dd_regex, doc):
            service_name = m[0]
            endpoint = m[1]
            services[service_name] = endpoint
        return services

live view timesync

라이브 뷰 기능에 타임스탬프를 고려하는 기능이 전혀 없습니다.

  • 클래스에서 타임스탬프를 읽어야할듯.
  • 라이브 뷰 예제에서 타임스탬프 보여주는 기능.

Examples do not work

I cannot make this work on my HX90V:

$ python src/example/scan_for_cameras.py 

Available cameras [('HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=1800\r\nEXT: \r\nLOCATION: http://192.168.122.1:61000/scalarwebapi_dd.xml\r\nSERVER: UPnP/1.0 MINT-X/1.8.1\r\nST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\nUSN: uuid:000000001000-1010-8000-02AEFA7863EA::urn:schemas-sony-com:service:ScalarWebAPI:1\r\n\r\n', ('192.168.122.1', 48385))]

Checking Camera : ('HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=1800\r\nEXT: \r\nLOCATION: http://192.168.122.1:61000/scalarwebapi_dd.xml\r\nSERVER: UPnP/1.0 MINT-X/1.8.1\r\nST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\nUSN: uuid:000000001000-1010-8000-02AEFA7863EA::urn:schemas-sony-com:service:ScalarWebAPI:1\r\n\r\n', ('192.168.122.1', 48385))
[ERROR] camera doesn't workcan only concatenate tuple (not "str") to tuple

This seems to be related to a bug on Line 285 in https://github.com/Bloodevil/sony_camera_api/blob/master/src/pysony.py

Adaptation for Action Cams

Hello,

Thanks a lot for sharing this code!

I'm using it to control an Action Cam (X1000V). I've changed the pysony.py file, it's in my repo in the X1000V branch. It's still under progress, it may not work properly yet (especially the function to get files within a specified time rang, getFileInRange).

I've changed the default IP address in SonyAPI(), for Action Cams it seems to be :

http://192.168.122.1:8080

A problem I had is that the APIs to retrieve data from the camera where not listed in getAvailableApiList() (even in Contents Transfer function), so I could not use them with the test written in _cmd that checks if the method is listed by getAvailableApiList(). Thus I run the test only if the target is /camera. Not very elegant but it works...

I also changed the attributes of the SonyAPI class : on my version the attributes are the IP addres, the uri of the scheme and the uri of the storage source. I'd rather define the parameters used for the API only in the _cmd method, it seems to me somehow more flexible.

I added a few methods to access data more conveniently than with the original getContentList.

Regards,
Toufraita

How to save captured still image on computer?

Thank you for the great library!
I was able to connect my Sony RX100IV to it and to take pictures via camera.actTakePicture(). However I cant figure out how to save the taken picture on my computer instead on the SD card. Can anybody help me on this? Any help would be greatly appreciated!

add parse payload def to SonyAPI class.

if you want to save jpeg to camera through liveview from camera, you should parse that stream.
already exist in pysony file but how to make new function that can extract the liveview images?

An error has occurred!

In [1]: import pysony
Traceback (most recent call last):

File "C:\Users*\IPython\core\interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)

File "", line 1, in
import pysony

File "C:*\Anaconda3\lib\site-packages\pysony.py", line 195
print "[WORN] liveview is not a dict type"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(print "[WORN] liveview is not a dict type")?

check support api list.

Camera has different support api list. so I should check connected camera can support or not of each class's properties.

like below:

class ..
def method():
if not method_name exist on available_api_list:
raise "This camera can't use this api"

example/sony_camera_liveview.py code could not work at the a6000

I tried the live view sample code by a6000, i could not got the liveview jpeg dump. When I read the official reference it turned out that old models can not transition to liveview mode unless they hit "StartRecMode" after camera start . It solved this. For your information.

Noob question - touch focus and take photo

Hi,

I am trying to understand how to use this software with my qx1. Example work as expected, but I am trying to script touch focus and take picture. My attempt below does not work, can you please help?

if 'setTouchAFPosition' in (mode['result'])[0]:
print camera.setTouchAFPosition([{'touchCoordinates': ["30.0,30.0"]}])
time.sleep(5)
if 'actTakePicture' in (mode['result'])[0]:
print camera.actTakePicture()
time.sleep(5)

Typo in 'getAvailableFNumber()'

Seems the code actually calls

trying 'getAvailableFNumber()':
[WARN] using unsupported camera api: getAvailabeFNumber
{'id': 1, 'error': [12, 'getAvailabeFNumber']}

ie without the second 'l'. :-(

Can't connect to the Sony RX100 III

Hi!
I would like to use sony_camera_api but unfortunately, I'm not able to connect to my camera. The way I try to do it is:

  1. Turn on the camera and enter Smart Remote Embedded.
  2. Connect to the WiFi network with my PC (Ubuntu). After the connection is established the screen on the camera stays at "Connecting".
  3. On my PC I try to run some Python scripts from the repository e.g. scan_for_cameras.py which returns an empty list of found devices.

I checked if an Android app is going to work with my camera and everything went smooth. I believe that the problem is with my PC. I also sniffed the wlp1s0 interface after running the scripts and I can see the outgoing SSDP packet and the camera's response packet. Sometimes after some time camera issues a couple more of them. I don't know if it is a desirable operation. Below I attached a screenshot from Wireshark.

sony_camera_api

Thanks for your help.

Examples do not close properly - required a ^Z to pause and then be killed.

I think that this is related to 'class LiveviewStreamThread()' running it it's own thread and then in a tight loop. Maybe we need some 'stop()' or 'de-init()' call for it?

$ python2 src/example/sony_camera_liveview.py
('Supported liveview size:', {'result': ['M'], 'id': 1})
[i] LiveviewStreamThread started.
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1 - - [03/Nov/2017 16:15:25] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [03/Nov/2017 16:15:25] "GET /video_feed HTTP/1.1" 200 -
^C----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55232)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 203, in handle
    rv = BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 238, in handle_one_request
    return self.run_wsgi()
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 180, in run_wsgi
    execute(self.server.app)
  File "/usr/lib/python2.7/dist-packages/werkzeug/serving.py", line 170, in execute
    for data in application_iter:
  File "/usr/lib/python2.7/dist-packages/werkzeug/wsgi.py", line 693, in __next__
    return self._next()
  File "/usr/lib/python2.7/dist-packages/werkzeug/wrappers.py", line 81, in _iter_encoded
    for item in iterable:
  File "src/example/sony_camera_liveview.py", line 35, in gen
    frame = flask_app.get_frame_handle()
  File "build/bdist.linux-x86_64/egg/pysony.py", line 354, in get_latest_view
    data_img = self._lilo_jpeg_pool.get()
  File "/usr/lib/python2.7/Queue.py", line 168, in get
    self.not_empty.wait()
  File "/usr/lib/python2.7/threading.py", line 340, in wait
    waiter.acquire()
KeyboardInterrupt
----------------------------------------
^C^C^C^C^Z
[1]+  Stopped                 python2 src/example/sony_camera_liveview.py
$ killall -9 python2

python3: comp_urllib not found.

Looks like the recent changes in commit 8dd4ae2 don't work for Python3 (on Xubuntu).

$ python3 src/example/dump_camera_capabilities.py 
Traceback (most recent call last):
  File "src/example/dump_camera_capabilities.py", line 1, in <module>
    import pysony
  File "/usr/local/lib/python3.5/dist-packages/pysony-0.1.11-py3.5.egg/pysony.py", line 9, in <module>
ImportError: No module named 'comp_urllib'

Print syntax errors on Python3

It looks like there might be some compatibility issues running this library under Python3:

$ pip install pysony
Collecting pysony
Installing collected packages: pysony
Successfully installed pysony-0.1.11
$ python
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pysony
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bjmc/Sandbox/sony_camera_api/.env/lib/python3.6/site-packages/pysony.py", line 195
    print "[WORN] liveview is not a dict type"
                                             ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("[WORN] liveview is not a dict type")?

Livestream 'lockup' with slow computer

I am seeing a problem when running on a slow computer (namely a Raspberry Pi), it seems that the image decode is not faster enough and at some point lags so far behind that the camera gives up - closing the connection and leaving the app hanging.

Looking at profiling the code it seems that there is just 1 call to liburl2 which returns a pointer to a 'never ending bowl' from which we read the image frames from in turn.
screenshot_2016-03-23_00-13-54

There is a time stamp in the common header, and mention in the API that:

The client may not display all the JPEG because of the decoding time. In that case, the
client should skip some JPEG images.

I think this is the solution, but can't quite understand (it's late night here :-) how to evaluate the frame rate/time stamp to decide we're running too far behind. The solution will probably fit here:

    if common['payload_type']==1:
       payload = payload_header(data)
+      if payload['timestamp"] : #??? not sure how to eval "much too late"
+         # running too slow, skip displaying this frame
+         read(payload['jpeg_data_size'] + payload['padding_size'])
+         continue
       image_file = io.BytesIO(incoming.read(payload['jpeg_data_size']))
       incoming_image = pygame.image.load(image_file).convert()
       if options.zoom:
          incoming_image = pygame.transform.scale(incoming_image, \
             (infoObject.current_w, infoObject.current_h))
       incoming.read(payload['padding_size'])

More undocumented functions from "imaging-edge-mobile-7-5-1"

It looks like there are more undocumented functions from "imaging-edge-mobile-7-5-1" (the APK that one would install on their phone).

For example

simon@thevoid:~/camera_fw/imaging_edge/imaging-edge-mobile-7-5-1/smali/com/sony/mexi/orb
/client/camera$ grep "const-string v1" CameraClient.smali | sort | uniq

    const-string v1, "actChangeFocalPosition"
    const-string v1, "actFormatStorage"
    const-string v1, "actHalfPressShutter"
    const-string v1, "actShiftFocalPosition"
    const-string v1, "actSuperSlowRecBuffering"
    const-string v1, "actSuperSlowRecRecording"
    const-string v1, "actTakePicture"
    const-string v1, "actTrackingFocus"
    ...

Attached below is an 'authenticate.py' which requests to use EVERYTHING that ImagingEdge knows about, wonder how much more capabilities this adds to various cameras.
authenticate-imaging-edge-mobile-7-5-1.py.txt

Scanning for QX10 broken

It appears that '0823bb11261059b597d8d7ad796f8f519310d88c' is the last revision in which the QX10 can be found.... preventing it's use :-(


$ python2 src/example/scan_for_cameras.py 
Available cameras ['http://10.0.0.1:10000']

Checking Camera : http://10.0.0.1:10000
{'id': 1, 'result': [['getMethodTypes', 'getAvailableApiList', 'setShootMode', 'getShootMode', 'getSupportedShootMode', 'getAvailableShootMode', 'setSelfTimer', 'getSelfTimer', 'getSupportedSelfTimer', 'getAvailableSelfTimer', 'setPostviewImageSize', 'getPostviewImageSize', 'getSupportedPostviewImageSize', 'getAvailablePostviewImageSize', 'startLiveview', 'stopLiveview', 'actTakePicture', 'startMovieRec', 'stopMovieRec', 'awaitTakePicture', 'actZoom', 'setExposureMode', 'getExposureMode', 'getSupportedExposureMode', 'getAvailableExposureMode', 'setBeepMode', 'getBeepMode', 'getSupportedBeepMode', 'getAvailableBeepMode', 'setCameraFunction', 'getCameraFunction', 'getSupportedCameraFunction', 'getAvailableCameraFunction', 'setStillSize', 'getStillSize', 'getSupportedStillSize', 'getAvailableStillSize', 'actFormatStorage', 'getStorageInformation', 'setTouchAFPosition', 'cancelTouchAFPosition', 'getTouchAFPosition', 'getSupportedExposureCompensation', 'getSupportedWhiteBalance', 'getSupportedIsoSpeedRate', 'actHalfPressShutter', 'cancelHalfPressShutter', 'getApplicationInfo', 'getVersions', 'getEvent']]}

Verify jpeg image format.

sometime jpeg image is broken. I don't know about the reason. but there are two point.

  1. wrong jpeg size.
  2. wrong jpeg data.

sony official app have similar act looks like broken image. then official app don't update latest image and show previous image. (looks like stopped)

there are two solution.

  1. Same as like official app
  2. fix wrong size or data. (if can....)

make test automation tool.

  • make test automation tool (exactly, test generator)
  • make fakestream and data (capture livesetreamdata and pretend to camera connected)
  • .. Do I should make fake camera server work as like real sony API camera ???

Error using anaconda with python 3.6

I installed the module using pip install pysony.

To test I wrote code

import pysony
api = pysony.SonyAPI()
api.getAvailableApiList()

but it is giving this error ...

SyntaxError: Missing parentheses in call to 'print'. Did you mean print("[WORN] liveview is not a dict type")?

Add example script for controlling/setting the Zoom of the attached lens

ma1co/OpenMemories-Tweak#70 (comment)
Was asked on another project whether it was possible to set the zoom to a particular setting... it is, but on my lens the control is a bit limited and it tends to overshoot - even if you use the '1shoot' capability to nudge it into position.

Script attached, is this worth adding as an example?
set_zoom.py.txt

simon@thevoid:~/sony_camera_api-sdw-github/examples$ python3 set_zoom.py -p 0
Searching for camera...
Found: http://192.168.122.1:8080
Zoom currently 100

simon@thevoid:~/sony_camera_api-sdw-github/examples$ python3 set_zoom.py -v -n 30 
Searching for camera...
Found: http://192.168.122.1:8080
Setting Zoom to 30
{'zoomPositionCurrentBox': 100, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 100}
{'zoomPositionCurrentBox': 100, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 100}
{'zoomPositionCurrentBox': 100, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 100}
{'zoomPositionCurrentBox': 96, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 96}
{'zoomPositionCurrentBox': 87, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 87}
{'zoomPositionCurrentBox': 87, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 87}
{'zoomPositionCurrentBox': 80, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 80}
{'zoomPositionCurrentBox': 77, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 77}
{'zoomPositionCurrentBox': 77, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 77}
{'zoomPositionCurrentBox': 70, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 70}
{'zoomPositionCurrentBox': 64, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 64}
{'zoomPositionCurrentBox': 61, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 61}
{'zoomPositionCurrentBox': 61, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 61}
{'zoomPositionCurrentBox': 54, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 54}
{'zoomPositionCurrentBox': 54, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 54}
{'zoomPositionCurrentBox': 54, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 54}
{'zoomPositionCurrentBox': 45, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 45}
{'zoomPositionCurrentBox': 35, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 35}
{'zoomPositionCurrentBox': 19, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 19}
Nudge:
{'zoomPositionCurrentBox': 12, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 12}
Nudge:
{'zoomPositionCurrentBox': 16, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 16}
Nudge:
{'zoomPositionCurrentBox': 22, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 22}
Nudge:
{'zoomPositionCurrentBox': 32, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 32}
Nudge:
{'zoomPositionCurrentBox': 25, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 25}
Nudge:
{'zoomPositionCurrentBox': 29, 'type': 'zoomInformation', 'zoomIndexCurrentBox': 0, 'zoomNumberBox': 1, 'zoomPosition': 29}

simon@thevoid:~/sony_camera_api-sdw-github/examples$ python3 set_zoom.py -p 0
Searching for camera...
Found: http://192.168.122.1:8080
Zoom currently 38

Camera connectivity issues

I am able to find my camera and command it to take a picture, etc. using pysony. However, over WiFi (using the camera as an access point) using, for instance the scan_for_cameras.py example code, it takes several minutes for the computer to detect the camera. Also, once found the connection is often lost. Is there a better way to connect to the camera?

branch 'master' broken - local variable 'host' referenced before assignment

branch 'master' is broken, but 'develop' appears to function OK.

simon@thevoid:~/sony_camera_api-github$ python2 examples/scan_for_cameras.py 
Traceback (most recent call last):
  File "examples/scan_for_cameras.py", line 7, in <module>
    cameras =  search.discover(5)
  File "build/bdist.linux-x86_64/egg/pysony.py", line 54, in discover
  File "build/bdist.linux-x86_64/egg/pysony.py", line 70, in _listen_for_discover
UnboundLocalError: local variable 'host' referenced before assignment
simon@thevoid:~/sony_camera_api-github$ git branch -v
  develop d65482c  add 3.8
* master  ad78953  fix typo

Manual Focus Adjustment

I am wondering if this package can do the manual focus adjustment. I have managed to get this working on the A7R4 with the Sony SDK with the following commands

SDK::CrDeviceProperty prop;
prop.SetCode(SDK::CrDevicePropertyCode::CrDeviceProperty_NearFar);
prop.SetCurrentValue(selected_index);
prop.SetValueType(SDK::CrDataType::CrDataType_Int8);
SDK::SetDeviceProperty(m_device_handle, &prop);

I was wondering if you have this control in this package.

Error when running example code: timer_photo.py

Unhandled exception in thread started by <function liveview_and_save at 0x0296A170>
Traceback (most recent call last):
File "timer_photo.py", line 24, in liveview_and_save
live = camera.startLiveview()
File "..\pysony.py", line 588 in startLiveview
return self._cmd(method="startLiveview")
File "..\pysony.py", line 268, in _cmd
camera_api_list = self.getAvailableApiList()["result"][0]
TypeError: string indices must be integers, not str

liveview url

QX1 send me a url for liveview as http:\/\/192.168.122.1:8080\/liveview\/liveviewstream which is incorrect for urllib2 and function SonyAPI.liveview() return dict instead of urllib2 object.
add following code to prevent this situation:

if isinstance(f, dict):
url = f['result'][0]
f = urllib2.urlopen(url.replace('\', ''))

Thanks

pyLiveView.py Example network error

When running the pyLiveView.py example I get the following error:

Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "pyLiveView.py", line 77, in run
cameras = search.discover(1)
File "/Library/Python/2.7/site-packages/pysony.py", line 38, in discover
self.__udp_socket.sendto(msg, (SSDP_ADDR, SSDP_PORT))
error: [Errno 51] Network is unreachable

I'm running the code on IOS.
Any suggestions where to start troubleshooting?

Gtk gui not supported in ubuntu

Thank you for such a great library. Sir the problem is gtk gui is not supported in ubuntu. As to the same pylive.py function is not opening it's gui.

Does not find HX60V, need to specify IP address

Got my hands on a DSC-HX60V, and sample scripts do not find it by default as it allocates a different IP address/range.

Needed to include the actual IP address, after which it seems to work (see below)

-      camera = SonyAPI()
+      camera = SonyAPI(QX_ADDR='http://192.168.122.1:8080/')

simon@retrobox:~/sony_camera_api-git/src/example$ python pyLiveView.py -g -a -d
using LiveView grabber
Versions: {'result': [['1.0', '1.1', '1.2', '1.3', '1.4']], 'id': 1}
API List: {'result': [['getVersions', 'getMethodTypes', 'getApplicationInfo', 'getAvailableApiList', 'getEvent', 'startRecMode', 'stopRecMode']], 'id': 1}
Event: {'result': [{'type': 'availableApiList', 'names': ['getVersions', 'getMethodTypes', 'getApplicationInfo', 'getAvailableApiList', 'getEvent', 'stopRecMode', 'startMovieRec', 'startLiveview', 'stopLiveview', 'startLiveviewWithSize', 'actZoom', 'setShootMode', 'getShootMode', 'getAvailableShootMode', 'getSupportedShootMode', 'getExposureMode', 'getSupportedExposureMode', 'getExposureCompensation', 'getAvailableExposureCompensation', 'getSupportedExposureCompensation', 'getFNumber', 'getAvailableFNumber', 'getSupportedFNumber', 'getIsoSpeedRate', 'getAvailableIsoSpeedRate', 'getSupportedIsoSpeedRate', 'getLiveviewSize', 'getAvailableLiveviewSize', 'getSupportedLiveviewSize', 'getShutterSpeed', 'getAvailableShutterSpeed', 'getSupportedShutterSpeed', 'getWhiteBalance', 'getSupportedWhiteBalance', 'getAvailableWhiteBalance', 'getFocusMode', 'getAvailableFocusMode', 'getSupportedFocusMode', 'setZoomSetting', 'getAvailableZoomSetting', 'getZoomSetting', 'getSupportedZoomSetting', 'getStorageInformation', 'setLiveviewFrameInfo', 'getLiveviewFrameInfo']}, {'type': 'cameraStatus', 'cameraStatus': 'IDLE'}, {'zoomPositionCurrentBox': 0, 'zoomNumberBox': 2, 'zoomIndexCurrentBox': 0, 'type': 'zoomInformation', 'zoomPosition': 0}, {'liveviewStatus': False, 'type': 'liveviewStatus'}, None, [], [], None, None, None, [{'recordableTime': 125, 'recordTarget': True, 'storageID': 'Memory Card 1', 'type': 'storageInformation', 'numberOfRecordableImages': -1, 'storageDescription': 'Storage Media'}], None, {'cameraFunctionCandidates': ['Contents Transfer', 'Remote Shooting'], 'type': 'cameraFunction', 'currentCameraFunction': 'Remote Shooting'}, None, None, None, None, None, {'currentExposureMode': 'Intelligent Auto', 'type': 'exposureMode', 'exposureModeCandidates': ['Intelligent Auto']}, {'currentPostviewImageSize': '2M', 'type': 'postviewImageSize', 'postviewImageSizeCandidates': ['Original', '2M']}, None, {'currentShootMode': 'movie', 'type': 'shootMode', 'shootModeCandidates': ['movie']}, None, None, None, None, None, {'fNumberCandidates': [], 'type': 'fNumber', 'currentFNumber': '3.5'}, {'type': 'focusMode', 'focusModeCandidates': [], 'currentFocusMode': 'AF-C'}, {'currentIsoSpeedRate': 'AUTO', 'type': 'isoSpeedRate', 'isoSpeedRateCandidates': []}, None, {'type': 'programShift', 'isShifted': False}, {'shutterSpeedCandidates': [], 'currentShutterSpeed': '1/30', 'type': 'shutterSpeed'}, {'checkAvailability': True, 'currentColorTemperature': -1, 'type': 'whiteBalance', 'currentWhiteBalanceMode': 'Auto WB'}, None], 'id': 1}
adjusted width from 800 to 640
adjusted height from 512 to 360
started capture
Stopped capture: frames = 505 , delta = 20.754361 , fps = 24.3322355239
terminating...
terminated

Running on Mac

After connecting to camera WIFI (QX10)

Korr:sony_camera_api Mac$ python src/example/pygameLiveView.py
Traceback (most recent call last):
File "src/example/pygameLiveView.py", line 90, in
cameras = search.discover()
File "build/bdist.macosx-10.9-intel/egg/pysony.py", line 46, in discover
socket.error: [Errno 51] Network is unreachable

Add/Confirm support for RX0

Kind of a wish list item, I don't know for certain that the RX0 actually supports the Sony Remote API (as the API pages have note been updated).

However the Android 'Playmemories' app has:

6.1.0

  • Supports RX0.
  • By connecting RX0 to a smartphone via Wi-Fi and using the app, you can now remotely check up to 5 view angles at the same time from Live View, and also take photos or apply settings at once.

The spec page for the camera talks about some pretty nice features (shame the camera can only record video as 1080P).
http://www.sony.ca/en/electronics/cyber-shot-compact-cameras/dsc-rx0/specifications#features

Discovery confused by HTTP errors

Have AS100 connected to router and 'scan for cameras' fails, a bit of debug shows that the router is returning a error and this appears confuse the discovery mechanism.

$ python2 src/example/scan_for_cameras.py 
('192.168.1.1', 1122, 'HTTP/1.1 412 Precondition Failed\r\n\r\n')
Oh, ignoring Router


('192.168.1.100', 56963, 'HTTP/1.1 200 OK\r\nCACHE-CONTROL: max-age=1800\r\nEXT: \r\nLOCATION: http://192.168.1.100:64321/scalarwebapi_dd.xml\r\nSERVER: UPnP/1.0 SonyImagingDevice/1.0\r\nST: urn:schemas-sony-com:service:ScalarWebAPI:1\r\nUSN: uuid:00000000-0005-0010-8000-fcc2dec724bb::urn:schemas-sony-com:service:ScalarWebAPI:1\r\nX-AV-Physical-Unit-Info: pa=""; pl=;\r\nX-AV-Server-Info: av=5.0; hn=""; cn="Sony Corporation"; mn="SonyImagingDevice"; mv="1.0";\r\n\r\n')
['http://192.168.1.100:10000']
Available cameras: ['http://192.168.1.100:10000']

Checking Camera: http://192.168.1.100:10000
{'id': 1, 'result': [['getMethodTypes', 'getAvailableApiList', 'setShootMode', 'getShootMode', 'getSupportedShootMode', 'getAvailableShootMode', 'setSteadyMode', 'getSteadyMode', 'getSupportedSteadyMode', 'getAvailableSteadyMode', 'setMovieQuality', 'getMovieQuality', 'getSupportedMovieQuality', 'getAvailableMovieQuality', 'startLiveview', 'stopLiveview', 'actTakePicture', 'startMovieRec', 'stopMovieRec', 'startIntervalStillRec', 'stopIntervalStillRec', 'getStorageInformation', 'getApplicationInfo', 'getVersions', 'getEvent']]}

HDR-AS15: Supported Movie Quality [ERROR] camera doesn't work

Looks like the HDR-AS15 does not like this request, but the QX10 does....

HDR-AS15

$ python sony_camera_liveview.py
 * Running on http://127.0.0.1:5000/
Found Camera:
Application Info {'id': 1, 'result': ['Smart Remote Control', '2.0.0']}
Versions {'id': 1, 'result': [['1.0']]}
Supported Shoot Modes {'id': 1, 'result': [['movie', 'intervalstill']]}
Supported Movie Quality [ERROR] camera doesn't workHTTP Error 403: Forbidden
Supported Movie File Format {'id': 1, 'error': [12, 'getSupportedMovieFileFormat']}
Supported Movie Steady Mode [ERROR] camera doesn't workHTTP Error 403: Forbidden

QX10

$ python sony_camera_liveview.py
 * Running on http://127.0.0.1:5000/
Found Camera:
Application Info {'id': 1, 'result': ['Smart Remote Control', '2.1.1']}
Versions {'id': 1, 'result': [['1.0', '1.1']]}
Supported Shoot Modes {'id': 1, 'result': [['still', 'movie']]}
Supported Movie Quality {'id': 1, 'error': [12, 'getSupportedMovieQuality']}
Supported Movie File Format {'id': 1, 'error': [12, 'getSupportedMovieFileFormat']}
Supported Movie Steady Mode {'id': 1, 'error': [12, 'getSupportedSteadyMode']}

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.