Skip to main content

Python interface to the .NET Thor cameras.

Project description

ThorCam

Github Build Status

Python interface for the Thor scientific Cameras using .Net.

For more information and to get started: https://matham.github.io/thorcam/index.html.

To install https://matham.github.io/thorcam/installation.html.

Basic example

First create a subclass that prints the camera results:

from thorcam.camera import ThorCam
class MyThorCam(ThorCam):
    def received_camera_response(self, msg, value):
        super(MyThorCam, self).received_camera_response(msg, value)
        if msg == 'image':
            return
        print('Received "{}" with value "{}"'.format(msg, value))
    def got_image(self, image, count, queued_count, t):
        print('Received image "{}" with time "{}" and counts "{}", "{}"'
              .format(image, t, count, queued_count))

Then use the camera:

>>> # create camera
>>> cam = MyThorCam()
<__main__.MyThorCam at 0x25a72f6a748>
>>> # start the server etc.
>>> cam.start_cam_process()
>>> # get list of attached cams
>>> cam.refresh_cameras()
Received "serials" with value "['05761']"
>>> # open the camera
>>> cam.open_camera('05761')
Received "settings" with value "{'binning_x': 1, 'binning_x_range': [1, 24], ..."
Received "cam_open" with value "None"
>>> cam.exposure_range
[0.0, 1000000.0]
>>> cam.exposure_ms
241.948
>>> # update the exposure value
>>> cam.set_setting('exposure_ms', 150)
Received "settings" with value "{'exposure_ms': 150.0}"
>>> cam.exposure_ms
150.0
>>> # now play the camera
>>> cam.play_camera()
Received "playing" with value "True"
Received image "<ffpyplayer.pic.Image object at 0x000001D1D8D67900>" with time "2e-07" and counts "1", "1"
Received image "<ffpyplayer.pic.Image object at 0x000001D1D8D67990>" with time "0.2310473" and counts "2", "1"
Received image "<ffpyplayer.pic.Image object at 0x000001D1D8D67A68>" with time "0.4735178" and counts "3", "1"
Received image "<ffpyplayer.pic.Image object at 0x000001D1D8D67B40>" with time "0.7157285" and counts "4", "1"
Received image "<ffpyplayer.pic.Image object at 0x000001D1D8D67C18>" with time "0.9583721" and counts "5", "1"
>>> # now stop playing
>>> cam.stop_playing_camera()
Received "playing" with value "False"
>>> # close the camera
>>> cam.close_camera()
Received "cam_closed" with value "None"
>>> # close the server and everything
>>> cam.stop_cam_process(join=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

thorcam-0.1.3.tar.gz (15.0 kB view hashes)

Uploaded Source

Built Distributions

thorcam-0.1.3-cp38-cp38-win_amd64.whl (15.7 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

thorcam-0.1.3-cp38-cp38-win32.whl (13.4 MB view hashes)

Uploaded CPython 3.8 Windows x86

thorcam-0.1.3-cp37-cp37m-win_amd64.whl (15.7 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

thorcam-0.1.3-cp37-cp37m-win32.whl (13.4 MB view hashes)

Uploaded CPython 3.7m Windows x86

thorcam-0.1.3-cp36-cp36m-win_amd64.whl (15.7 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

thorcam-0.1.3-cp36-cp36m-win32.whl (13.4 MB view hashes)

Uploaded CPython 3.6m Windows x86

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page