-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from nqminds/from-iam3dpo-code-repo
Mockup the `nqm.irimager.IRImager` class with dummy functions
- Loading branch information
Showing
6 changed files
with
271 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<imager xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<videoformatindex>0</videoformatindex> <!-- index of the used video format (USB endpoint) --> | ||
<formatspath>/usr/share/libirimager</formatspath> | ||
<calipath>/usr/share/libirimager/cali</calipath> | ||
<!-- Uncomment the following lines to specify user-defined parameters for the desired optic | ||
and temperature range. Be aware to specify meaningful parameters. | ||
See documentation for further information: http://evocortex.com/libirimager2/html/index.html | ||
By default, the first available optic and the first meaningful temperature range are selected. | ||
--> | ||
<fov>25</fov> | ||
<temperature> | ||
<min>450</min> | ||
<max>1800</max> | ||
</temperature> | ||
<optics_text></optics_text> | ||
<framerate>27.0</framerate> <!-- scaled down frame rate, must be less or equal than camera frame rate --> | ||
<bispectral>0</bispectral> <!-- 0=only thermal sensor, 1=bispectral technology (only PI200/PI230) --> | ||
<average>0</average> <!-- average callback frames over intermediate frames --> | ||
<autoflag> | ||
<enable>1</enable> | ||
<mininterval>15.0</mininterval> | ||
<maxinterval>0.0</maxinterval> | ||
</autoflag> | ||
<pif_in_mode>0</pif_in_mode> <!-- 0=Image capture (default), 1=Flag control --> | ||
<pif_out_mode>0</pif_out_mode> <!-- 0=Off (default), 1=Frame sync signal --> | ||
<pif_out_voltage>5000</pif_out_voltage> <!-- PIF out voltage in mV --> | ||
<tchipmode>0</tchipmode> <!-- 0=Floating (default), 1=Auto, 2=Fixed value --> | ||
<tchipfixedvalue>40.0</tchipfixedvalue> <!-- Fixed value for tchipmode=2 --> | ||
<focus>50.0</focus> <!-- position of focus motor in % of range [0; 100] --> | ||
</imager> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,62 @@ | ||
"""Tests for nqm.irimager.IRImager""" | ||
import datetime | ||
import pathlib | ||
|
||
import numpy as np | ||
import pytest | ||
|
||
from nqm.irimager import IRImager | ||
|
||
|
||
def test_irimager_test(): | ||
"""Tests nqm.irimager.IRImager""" | ||
def test_irimager_loads_xml(): | ||
"""Tests nqm.irimager.IRImager(xmlPath) can load an XML file""" | ||
# should work with a valid XML file | ||
IRImager(pathlib.Path("tests/__fixtures__/382x288@27Hz.xml")) | ||
|
||
with pytest.raises(RuntimeError, match="Invalid XML file"): | ||
IRImager(pathlib.Path("README.md")) | ||
|
||
|
||
def test_get_frame_fails_when_not_streaming(): | ||
"""Calling `get_frame()` should raise an error when not streaming""" | ||
irimager = IRImager() | ||
|
||
with pytest.raises(RuntimeError, match="IRIMAGER_STREAMOFF"): | ||
irimager.get_frame() | ||
|
||
|
||
def test_get_frame_in_context_manager(): | ||
"""Calling `get_frame()` should work when starting streaming with `with`""" | ||
irimager = IRImager() | ||
|
||
# context manager should auto-start streaming | ||
with irimager: | ||
irimager.get_frame() | ||
|
||
# context manager should auto-stop streaming | ||
with pytest.raises(RuntimeError, match="IRIMAGER_STREAMOFF"): | ||
irimager.get_frame() | ||
|
||
|
||
def test_irimager_get_frame(): | ||
"""Tests nqm.irimager.IRImager#get_frame""" | ||
irimager = IRImager() | ||
|
||
with irimager: | ||
array, timestamp = irimager.get_frame() | ||
|
||
assert array.dtype == np.uint16 | ||
# should be 2-dimensional | ||
assert array.ndim == 2 | ||
assert array.shape == (128, 128) | ||
|
||
# image should have been taken in the last 30 seconds | ||
assert timestamp > datetime.datetime.now() - datetime.timedelta(seconds=30) | ||
|
||
|
||
def test_irimager_get_temp_range_decimal(): | ||
"""Tests that nqm.irimager.IRImager#get_temp_range_decimal returns an int""" | ||
irimager = IRImager() | ||
|
||
assert irimager.test() == 42 | ||
assert irimager.get_temp_range_decimal() >= 0 | ||
assert isinstance(irimager.get_temp_range_decimal(), int) |