https://github.com/matham/thorcam
Python interface to the .NET Thor cameras.
https://github.com/matham/thorcam
Last synced: 3 months ago
JSON representation
Python interface to the .NET Thor cameras.
- Host: GitHub
- URL: https://github.com/matham/thorcam
- Owner: matham
- License: mit
- Created: 2019-10-28T22:13:42.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-08-18T01:40:06.000Z (almost 4 years ago)
- Last Synced: 2025-11-28T05:19:34.171Z (7 months ago)
- Language: Python
- Homepage:
- Size: 2.72 MB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
ThorCam
==========
[](https://github.com/matham/thorcam/actions)
A Python interface to the Thor scientific Cameras using `.Net`.
This library does **not** support the **DCx cameras**, only the **scientific cameras**.
See the [docs](https://matham.github.io/thorcam/index.html) for more information
and to get started.
To install in **Anaconda** or **native Python** see the
[installation instructions](https://matham.github.io/thorcam/installation.html).
Basic example
-------------
First create a subclass that prints the camera results:
```python
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:
```python
>>> # 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 "['03756']"
>>> # open the camera
>>> cam.open_camera('03756')
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 "" with time "2e-07" and counts "1", "1"
Received image "" with time "0.2310473" and counts "2", "1"
Received image "" with time "0.4735178" and counts "3", "1"
Received image "" with time "0.7157285" and counts "4", "1"
Received image "" 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)
```