Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 58 additions & 61 deletions deapi/client.py

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions deapi/tests/original_tests/01_fps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
deClient = DEAPI.Client()
deClient.Connect()

cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/02_hwRoisize.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
# Connect to the server
deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/03_hwBinning.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
# Connect to the server
deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/04_swBinning.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
# Connect to the server
deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/05_swhwBinning.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
# Connect to the server
deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/06_patternPixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@
deClient = DEAPI.Client()
# Connect to the Server
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/07_reference.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
# Connect to the server
deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/08_virtmask.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@
# Connect to the server
deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version is: {serverVersion}")
Expand Down
3 changes: 0 additions & 3 deletions deapi/tests/original_tests/09_scanRoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
# Connect to the server
deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]
deClient.SetCurrentCamera(camera)
serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
print(f"Camera Name: {cameraName}, Server Software Version: {serverVersion}")
Expand Down
31 changes: 16 additions & 15 deletions deapi/tests/original_tests/10_imageStatistics.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import math
import sys
import unittest
import deapi as DEAPI
Expand All @@ -22,8 +23,6 @@

deClient = DEAPI.Client()
deClient.Connect()
cameras = deClient.ListCameras()
camera = cameras[0]

serverVersion = deClient.GetProperty(propertyName.PROP_SERVER_SOFTWARE_VERSION)
cameraName = deClient.GetProperty(propertyName.PROP_CAMERA_NAME)
Expand Down Expand Up @@ -75,8 +74,7 @@
numPrecision = 6
frameCount = 1

deClient.SetCurrentCamera(camera)
# deClient.SetProperty("Test Pattern", testPattern)
deClient.SetProperty("Test Pattern", testPattern)
deClient.SetProperty(propertyName.PROP_INSTRUMENT_CLIENT_ADDRESS, "Manual")
deClient.SetProperty(
propertyName.PROP_INSTRUMENT_PROJECT_MAGNIFICATION, instrumentProjectMagnification
Expand Down Expand Up @@ -139,6 +137,7 @@ def UpdateStats(


def statisticsValueCheck(imageProcessingMode, correctionMode):
ret = True
deClient.SetProperty(propertyName.PROP_IMAGE_PROCESSING_MODE, imageProcessingMode)
deClient.SetProperty(
propertyName.PROP_IMAGE_PROCESSING_FLATFIELD_CORRECTION, correctionMode
Expand All @@ -163,14 +162,17 @@ def statisticsValueCheck(imageProcessingMode, correctionMode):
print(f"imagemean: {attributes.imageMean}")
print(stats.eppix)
print(stats.epa2)
# Sometimes the float number are not equal due to the
func.compare2FloatValue(stats.eppix, attributes.eppix, numPrecision, "e-/pix")
func.compare2FloatValue(stats.eppixps, attributes.eppixps, numPrecision, "e-/pix/s")
func.compare2FloatValue(stats.eps, attributes.eps, numPrecision, "e-/s")
func.compare2FloatValue(stats.epa2, attributes.epa2, numPrecision, "e-/a^2")
# precision issue, we will compare the float number with a tolerance value. The tolerance value is set to 10**-numPrecision * frameCount for e-/pix, 10**-numPrecision * fps for e-/pix/s and 10**-numPrecision * fps * numPhysicalPixels for e-/s.
ret &= math.isclose(stats.eppix, attributes.eppix, rel_tol=0, abs_tol=10**-numPrecision * frameCount)
ret &= math.isclose(stats.eppixps, attributes.eppixps, rel_tol=0, abs_tol=10**-numPrecision * fps)
ret &= math.isclose(stats.eps, attributes.eps, rel_tol=0, abs_tol=10**-numPrecision * fps * numPhysicalPixels)

ret &= func.compare2FloatValue(stats.epa2, attributes.epa2, numPrecision, "e-/a^2")
return ret


def compareBin1Bin2(imageProcessingMode, correctionMode, swBinningFactor):
ret = True
deClient.SetProperty(propertyName.PROP_IMAGE_PROCESSING_MODE, imageProcessingMode)
deClient.SetProperty(
propertyName.PROP_IMAGE_PROCESSING_FLATFIELD_CORRECTION, correctionMode
Expand Down Expand Up @@ -210,12 +212,11 @@ def compareBin1Bin2(imageProcessingMode, correctionMode, swBinningFactor):
swBinY,
)

func.compare2FloatValue(statsBin1.eppix, statsBin2.eppix, numPrecision, "e-/pix")
func.compare2FloatValue(
statsBin1.eppixps, statsBin2.eppixps, numPrecision, "e-/pix/s"
)
func.compare2FloatValue(statsBin1.eps, statsBin2.eps, numPrecision, "e-/s")
func.compare2FloatValue(statsBin1.epa2, statsBin2.epa2, numPrecision, "e-/a^2")
ret &= func.compare2FloatValue(statsBin1.eppix, statsBin2.eppix, numPrecision, "e-/pix")
ret &= func.compare2FloatValue(statsBin1.eppixps, statsBin2.eppixps, numPrecision, "e-/pix/s")
ret &= func.compare2FloatValue(statsBin1.eps, statsBin2.eps, numPrecision, "e-/s")
ret &= func.compare2FloatValue(statsBin1.epa2, statsBin2.epa2, numPrecision, "e-/a^2")
return ret


class TestPatternPixelValues(unittest.TestCase):
Expand Down
2 changes: 2 additions & 0 deletions deapi/tests/original_tests/func.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def compare2FloatValue(expectVal, actualVal, numPrecision, name):
f"{name}: expect {round(expectVal, numPrecision)} actual {round(actualVal, numPrecision)}"
)
return False
else:
return True


def writeLogFile(caseName, scriptName):
Expand Down
9 changes: 0 additions & 9 deletions deapi/tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,6 @@ def teardown(self):
def test_client_connection(self, client):
assert client.connected

def test_list_cameras(self, client):
cameras = client.list_cameras()
assert isinstance(cameras, list)

def test_set_current_camera(self, client):
cameras = client.list_cameras()
client.set_current_camera(cameras[0])
assert client.get_current_camera() == cameras[0]

def test_list_properties(self, client):
properties = client.list_properties()
assert isinstance(properties, list)
Expand Down
Loading