From b05dcc1b59365c9be4a41b1912e14d837d11fda7 Mon Sep 17 00:00:00 2001 From: "robert.briegel" Date: Wed, 8 Feb 2023 11:11:35 +0100 Subject: [PATCH 01/12] initial python sdk commit for version 3.1.2 --- .../Classification/.gitkeep => .gitignore | 0 LICENSE | 2 +- Python/Applications/Examples/.gitkeep | 0 Python/LICENSE | 201 +++ Python/README.md | 2 + Python/SDK/.gitkeep | 0 Python/pyproject.toml | 3 + Python/src/cuvis/AcquisitionContext.py | 293 +++++ Python/src/cuvis/Async.py | 70 ++ Python/src/cuvis/Calibration.py | 35 + Python/src/cuvis/Export.py | 70 ++ Python/src/cuvis/FileWriteSettings.py | 227 ++++ Python/src/cuvis/General.py | 83 ++ Python/src/cuvis/Measurement.py | 260 ++++ Python/src/cuvis/ProcessingContext.py | 113 ++ Python/src/cuvis/Session.py | 67 + Python/src/cuvis/Viewer.py | 66 + Python/src/cuvis/Worker.py | 102 ++ Python/src/cuvis/__init__.py | 25 + Python/src/cuvis/classificator/__init__.py | 6 + Python/src/cuvis/classificator/auxiliary.py | 614 +++++++++ .../src/cuvis/classificator/classificator.py | 310 +++++ Python/src/cuvis/classificator/indices.py | 85 ++ Python/src/cuvis/classificator/labelingGUI.py | 664 ++++++++++ Python/src/cuvis/classificator/model.py | 62 + .../src/cuvis/classificator/modelclasses.py | 257 ++++ .../src/cuvis/classificator/postprocessor.py | 559 +++++++++ .../src/cuvis/classificator/preprocclasses.py | 265 ++++ .../src/cuvis/classificator/preprocessor.py | 175 +++ Python/src/cuvis/cuvis_aux.py | 61 + Python/src/cuvis/cuvis_il.py | 1095 +++++++++++++++++ Python/src/cuvis/cuvis_types.py | 161 +++ .../cuvis/examples/EX01_loadMeasurement.py | 80 ++ .../examples/EX02_reprocessMeasurement.py | 135 ++ .../cuvis/examples/EX03_exportMeasurement.py | 81 ++ .../src/cuvis/examples/EX04_changeDistance.py | 82 ++ .../cuvis/examples/EX05_recordSingleImage.py | 98 ++ Python/src/cuvis/examples/EX06_recordVideo.py | 143 +++ .../EX99_classification_experimental.py | 104 ++ Python/src/cuvis/examples/__init__.py | 7 + Python/src/setup.py | 65 + 41 files changed, 6727 insertions(+), 1 deletion(-) rename Python/Applications/Classification/.gitkeep => .gitignore (100%) delete mode 100644 Python/Applications/Examples/.gitkeep create mode 100644 Python/LICENSE create mode 100644 Python/README.md delete mode 100644 Python/SDK/.gitkeep create mode 100644 Python/pyproject.toml create mode 100644 Python/src/cuvis/AcquisitionContext.py create mode 100644 Python/src/cuvis/Async.py create mode 100644 Python/src/cuvis/Calibration.py create mode 100644 Python/src/cuvis/Export.py create mode 100644 Python/src/cuvis/FileWriteSettings.py create mode 100644 Python/src/cuvis/General.py create mode 100644 Python/src/cuvis/Measurement.py create mode 100644 Python/src/cuvis/ProcessingContext.py create mode 100644 Python/src/cuvis/Session.py create mode 100644 Python/src/cuvis/Viewer.py create mode 100644 Python/src/cuvis/Worker.py create mode 100644 Python/src/cuvis/__init__.py create mode 100644 Python/src/cuvis/classificator/__init__.py create mode 100644 Python/src/cuvis/classificator/auxiliary.py create mode 100644 Python/src/cuvis/classificator/classificator.py create mode 100644 Python/src/cuvis/classificator/indices.py create mode 100644 Python/src/cuvis/classificator/labelingGUI.py create mode 100644 Python/src/cuvis/classificator/model.py create mode 100644 Python/src/cuvis/classificator/modelclasses.py create mode 100644 Python/src/cuvis/classificator/postprocessor.py create mode 100644 Python/src/cuvis/classificator/preprocclasses.py create mode 100644 Python/src/cuvis/classificator/preprocessor.py create mode 100644 Python/src/cuvis/cuvis_aux.py create mode 100644 Python/src/cuvis/cuvis_il.py create mode 100644 Python/src/cuvis/cuvis_types.py create mode 100644 Python/src/cuvis/examples/EX01_loadMeasurement.py create mode 100644 Python/src/cuvis/examples/EX02_reprocessMeasurement.py create mode 100644 Python/src/cuvis/examples/EX03_exportMeasurement.py create mode 100644 Python/src/cuvis/examples/EX04_changeDistance.py create mode 100644 Python/src/cuvis/examples/EX05_recordSingleImage.py create mode 100644 Python/src/cuvis/examples/EX06_recordVideo.py create mode 100644 Python/src/cuvis/examples/EX99_classification_experimental.py create mode 100644 Python/src/cuvis/examples/__init__.py create mode 100644 Python/src/setup.py diff --git a/Python/Applications/Classification/.gitkeep b/.gitignore similarity index 100% rename from Python/Applications/Classification/.gitkeep rename to .gitignore diff --git a/LICENSE b/LICENSE index 261eeb9..957d07d 100644 --- a/LICENSE +++ b/LICENSE @@ -186,7 +186,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright [yyyy] [name of copyright owner] + Copyright 2023 Cubert GmbH Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. diff --git a/Python/Applications/Examples/.gitkeep b/Python/Applications/Examples/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Python/LICENSE b/Python/LICENSE new file mode 100644 index 0000000..957d07d --- /dev/null +++ b/Python/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2023 Cubert GmbH + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/Python/README.md b/Python/README.md new file mode 100644 index 0000000..acd9121 --- /dev/null +++ b/Python/README.md @@ -0,0 +1,2 @@ +In order to import cuvis to your CMake project, Cuvis must be installed. +Download the installer for windows or the .deb files for Ubuntu 20.04 here: https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 \ No newline at end of file diff --git a/Python/SDK/.gitkeep b/Python/SDK/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/Python/pyproject.toml b/Python/pyproject.toml new file mode 100644 index 0000000..c4fdad2 --- /dev/null +++ b/Python/pyproject.toml @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools>=63.0", "wheel", "Cython"] +build-backend = "setuptools.build_meta" \ No newline at end of file diff --git a/Python/src/cuvis/AcquisitionContext.py b/Python/src/cuvis/AcquisitionContext.py new file mode 100644 index 0000000..32a9f96 --- /dev/null +++ b/Python/src/cuvis/AcquisitionContext.py @@ -0,0 +1,293 @@ +from . import cuvis_il +from .Async import Async, AsyncMesu +from .Calibration import Calibration +from .General import ComponentInfo +from .Measurement import Measurement +from .cuvis_aux import SDKException, SessionData +from .cuvis_types import HardwareState, OperationMode + + +class AcquisitionContext(object): + def __init__(self, base): + self.__handle__ = None + + if isinstance(base, Calibration): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_create_from_calib(base.__handle__, _ptr): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + else: + raise SDKException("Could not interpret input of type {}.".format(type(base))) + pass + + def getState(self): + val = cuvis_il.new_p_cuvis_hardware_state_t() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_get_state(self.__handle__, val): + raise SDKException() + return [key for key, vald in HardwareState.items() + if vald == cuvis_il.p_cuvis_hardware_state_t_value(val)][0] + + def getComponentCount(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_get_component_count(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getComponentInfo(self, idref): + ci = cuvis_il.cuvis_component_info_t() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_get_component_info(self.__handle__, idref, ci): + raise SDKException() + return ComponentInfo(info=ci) + + def getQueueSize(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_queue_size_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def setQueueSize(self, val): + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_queue_size_set(self.__handle__, val): + raise SDKException() + pass + + def getOnline(self, idref): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_online_get(self.__handle__, idref, val): + raise SDKException() + return cuvis_il.p_int_value(val) == 1 + + def getGain(self, idref): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_gain_get(self.__handle__, idref, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def setGain(self, idref, val): + if cuvis_il.status_ok != cuvis_il.cuvis_comp_gain_set(self.__handle__, idref, val): + raise SDKException() + pass + + def setGainAsync(self, idref, val): + _pAsync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_gain_set_async(self.__handle__, idref, _pAsync, val): + raise SDKException() + return Async(cuvis_il.p_int_value(_pAsync)) + + def setOperationMode(self, val): + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_operation_mode_set(self.__handle__, OperationMode[val]): + raise SDKException() + pass + + def setOperationModeAsync(self, val): + _pAsync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_operation_mode_set_async(self.__handle__, _pAsync, + OperationMode[val]): + raise SDKException() + return Async(cuvis_il.p_int_value(_pAsync)) + + def getOperationMode(self): + val = cuvis_il.new_p_cuvis_operation_mode_t() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_operation_mode_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_cuvis_operation_mode_t_value(val) + + def setIntegrationTime(self, val): + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_integration_time_set(self.__handle__, val): + raise SDKException() + pass + + def setIntegrationTimeAsync(self, val): + _pAsync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_integration_time_set_async(self.__handle__, _pAsync, val): + raise SDKException() + return Async(cuvis_il.p_int_value(_pAsync)) + + def getIntegrationTimeFactor(self, idref): + val = cuvis_il.new_p_double() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_integration_time_factor_get(self.__handle__, idref, val): + raise SDKException() + return cuvis_il.p_double_value(val) + + def setIntegrationTimeFactor(self, idref, val): + if cuvis_il.status_ok != cuvis_il.cuvis_comp_integration_time_factor_set(self.__handle__, idref, val): + raise SDKException() + pass + + def setIntegrationTimeFactorAsync(self, idref, val): + _pasync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_integration_time_factor_set_async(self.__handle__, idref, _pasync, + val): + raise SDKException() + return Async(cuvis_il.p_int_value(_pasync)) + + def getIntegrationTime(self): + val = cuvis_il.new_p_double() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_integration_time_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_double_value(val) + + def capture(self): + _pasync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_capture_async(self.__handle__, _pasync): + raise SDKException() + return AsyncMesu(cuvis_il.p_int_value(_pasync)) + + def captureAt(self, timeout_ms): + this_mesu = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_capture(self.__handle__, this_mesu, timeout_ms): + raise SDKException() + return Measurement(cuvis_il.p_int_value(this_mesu)) + + def setFPS(self, val): + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_fps_set(self.__handle__, val): + raise SDKException() + pass + + def setFPSAsync(self, val): + _pasync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_fps_set_async(self.__handle__, _pasync, val): + raise SDKException() + return Async(cuvis_il.p_int_value(_pasync)) + + def getFPS(self): + val = cuvis_il.new_p_double() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_fps_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_double_value(val) + + def hasNextMeasurement(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_has_next_measurement(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) != 0 + + def getNextMeasurement(self, timeout_ms): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_get_next_measurement(self.__handle__, val, timeout_ms): + raise SDKException() + return Measurement(cuvis_il.p_int_value(val)) + + def setSessionInfo(self, val): + session = cuvis_il.cuvis_session_info_t() + try: + session.name = val["Name"] + session.sequence_no = val["SequenceNumber"] + session.session_no = val["SessionNumber"] + except KeyError as e: + raise ValueError("Missing {} in Session Info dictionary.".format(e)) + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_set_session_info(self.__handle__, session): + raise SDKException() + pass + + def getSessionInfo(self): + session = cuvis_il.cuvis_session_info_t() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_get_session_info(self.__handle__, session): + raise SDKException() + return SessionData(session.name, session.session_no, session.sequence_no) + + def getQueueUsed(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_queue_used_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getDriverQueueUsed(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_driver_queue_used_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getHardwareQueueUsed(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_hardware_queue_used_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getDriverQueueSize(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_driver_queue_size_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getHardwareQueueSize(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_hardware_queue_size_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getTemperature(self, idref): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_comp_temperature_get(self.__handle__, idref, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def setAverage(self, avg): + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_average_set(self.__handle__, avg): + raise SDKException() + pass + + def getAverage(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_average_get(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def setAverageAsync(self, avg): + _pasync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_average_set_async(self.__handle__, _pasync, avg): + raise SDKException() + return Async(cuvis_il.p_int_value(_pasync)) + + def setContinuous(self, val): + _pasync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_continuous_set_async(self.__handle__, _pasync, int(val)): + raise SDKException() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_continuous_set(self.__handle__, int(val)): + raise SDKException() + return Async(cuvis_il.p_int_value(_pasync)) + + def getBandwidth(self): + _ptr = cuvis_il.new_p_double() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_bandwidth_get(self.__handle__, _ptr): + raise SDKException() + return cuvis_il.p_double_value(_ptr) + + def getAutoExp(self): + _ptr = cuvis_il.new_p_double() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_auto_exp_get(self.__handle__, _ptr): + raise SDKException() + return cuvis_il.p_double_value(_ptr) + + def setAutoExp(self, val): + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_auto_exp_set(self.__handle__, val): + raise SDKException() + pass + + def setAutoExpAsync(self, val): + _pasync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_auto_exp_set_async(self.__handle__, _pasync, val): + raise SDKException() + return Async(cuvis_il.p_int_value(_pasync)) + + def getPreviewMode(self): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_preview_mode_get(self.__handle__, _ptr): + raise SDKException() + return bool(cuvis_il.p_int_value(_ptr)) + + def setPreviewMode(self, val): + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_preview_mode_set(self.__handle__, val): + raise SDKException() + return + + def setPreviewModeAsync(self, val): + _pasync = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_acq_cont_preview_mode_set_async(self.__handle__, val): + raise SDKException() + return Async(cuvis_il.p_int_value(_pasync)) + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_acq_cont_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) diff --git a/Python/src/cuvis/Async.py b/Python/src/cuvis/Async.py new file mode 100644 index 0000000..0c881d1 --- /dev/null +++ b/Python/src/cuvis/Async.py @@ -0,0 +1,70 @@ +from . import cuvis_il +from .Measurement import Measurement +from .cuvis_aux import SDKException +from .cuvis_types import AsyncResult + + +class AsyncMesu(object): + def __init__(self, handle): + self.__handle__ = handle + + pass + + def get(self, timeout): + _ptr = cuvis_il.new_p_int() + _pmesu = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + res = cuvis_il.cuvis_async_capture_get(_ptr, int(timeout.total_seconds() * 1000), _pmesu) + + ret = { + "state": None, + "Measurement": None + } + + if res == cuvis_il.status_ok: + ret["state"] = "done" + ret["Measurement"] = Measurement(cuvis_il.p_int_value(_pmesu)) + elif res == cuvis_il.status_deferred: + ret["state"] = "deferred" + elif res == cuvis_il.status_overwritten: + ret["state"] = "overwritten" + elif res == cuvis_il.status_timeout: + ret["state"] = "timeout" + else: + raise SDKException() + + return ret + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_async_capture_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) + + +class Async(object): + def __init__(self, handle): + self.__handle__ = handle + + def get(self, timeout): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + res = cuvis_il.cuvis_async_call_get(_ptr, int(timeout.total_seconds() * 1000)) + + if res == cuvis_il.status_ok: + return AsyncResult["done"] + elif res == cuvis_il.status_deferred: + return AsyncResult["deferred"] + elif res == cuvis_il.status_overwritten: + return AsyncResult["overwritten"] + elif res == cuvis_il.status_timeout: + return AsyncResult["timeout"] + else: + raise SDKException() + pass + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_async_call_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) diff --git a/Python/src/cuvis/Calibration.py b/Python/src/cuvis/Calibration.py new file mode 100644 index 0000000..990f311 --- /dev/null +++ b/Python/src/cuvis/Calibration.py @@ -0,0 +1,35 @@ +from . import cuvis_il +from .cuvis_aux import SDKException, __bit_translate__ +from .cuvis_types import ProcessingMode, OperationMode + + +class Calibration(object): + def __init__(self, calibdir=None): + self.__handle__ = None + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_calib_create_from_path(calibdir, _ptr): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + pass + + def getCapabilities(self): + All_Modes = {} + # All_Modes.update(ProcessingMode) + All_Modes.update(OperationMode) + Usable_Modes = [] + _ptr = cuvis_il.new_p_int() + for k, v in All_Modes.items(): + try: + if cuvis_il.status_ok != cuvis_il.cuvis_calib_get_capabilities(self.__handle__, v, _ptr): + raise SDKException() + else: + Usable_Modes.append(k) + except SDKException: + raise SDKException() + return Usable_Modes # __bit_translate__(cuvis_il.p_int_value(_ptr)) + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_calib_free(_ptr) + pass diff --git a/Python/src/cuvis/Export.py b/Python/src/cuvis/Export.py new file mode 100644 index 0000000..32e5147 --- /dev/null +++ b/Python/src/cuvis/Export.py @@ -0,0 +1,70 @@ +from . import cuvis_il +from .cuvis_aux import SDKException + + +class Exporter(object): + def __init__(self): + self.__handle__ = None + pass + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_exporter_free(_ptr) + pass + + def apply(self, mesu): + if cuvis_il.status_ok != cuvis_il.cuvis_exporter_apply(self.__handle__, mesu.__handle__): + raise SDKException() + mesu.refresh() + return mesu + + def getQueueUsed(self): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_exporter_get_queue_used(self.__handle__, _ptr): + raise SDKException() + return cuvis_il.p_int_value(_ptr) + + +class CubeExporter(Exporter): + def __init__(self, fs): + super().__init__() + _ptr = cuvis_il.new_p_int() + ge, fs = fs.getInternal() + if cuvis_il.status_ok != cuvis_il.cuvis_exporter_create_cube(_ptr, ge, fs): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + pass + + +class TiffExporter(Exporter): + def __init__(self, fs): + super().__init__() + _ptr = cuvis_il.new_p_int() + ge, fs = fs.getInternal() + if cuvis_il.status_ok != cuvis_il.cuvis_exporter_create_tiff(_ptr, ge, fs): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + pass + + +class EnviExporter(Exporter): + def __init__(self, ge): + super().__init__() + _ptr = cuvis_il.new_p_int() + ge, _ = ge.getInternal() + if cuvis_il.status_ok != cuvis_il.cuvis_exporter_create_envi(_ptr, ge): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + pass + + +class ViewExporter(Exporter): + def __init__(self, fs): + super().__init__() + _ptr = cuvis_il.new_p_int() + ge, fs = fs.getInternal() + if cuvis_il.status_ok != cuvis_il.cuvis_exporter_create_view(_ptr, ge, fs): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + pass diff --git a/Python/src/cuvis/FileWriteSettings.py b/Python/src/cuvis/FileWriteSettings.py new file mode 100644 index 0000000..27464b4 --- /dev/null +++ b/Python/src/cuvis/FileWriteSettings.py @@ -0,0 +1,227 @@ +from . import cuvis_il +from .cuvis_aux import SDKException +from .cuvis_types import PanSharpeningInterpolationType, PanSharpeningAlgorithm, TiffCompressionMode, TiffFormat, \ + OperationMode, ProcessingMode + + +class GeneralExportSettings(object): + + def check_kwargs(self, kwargs): + [self.__setattr__(key, kwargs.pop(key, None)) for + key in kwargs.copy().keys() if key in self.__dict__.keys()] + pass + + def __init__(self, **kwargs): + self.ExportDir = "." + self.ChannelSelection = "all" + self.SpectraMultiplier = 1.0 + self.PanScale = 0.0 + self.PanSharpeningInterpolationType = "Linear" + self.PanSharpeningAlgorithmType = "CubertMacroPixel" + self.AddPan = False + self.AddFullscalePan = False + self.Permissive = False + + self.check_kwargs(kwargs) + + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_export_general_settings_t): + ge = list(kwargs.values())[0] + self.ExportDir = ge.export_dir + self.ChannelSelection = ge.channel_selection + self.SpectraMultiplier = ge.spectra_multiplier + self.PanScale = ge.pan_scale0 + self.PanSharpeningInterpolationType = \ + [key for key, val in PanSharpeningInterpolationType.items() if + val == ge.pan_interpolation_type][0] + self.PanSharpeningAlgorithmType = \ + [key for key, val in PanSharpeningAlgorithm.items() if val == ge.pan_algorithm][0] + self.AddPan = ge.add_pan > 0 + self.AddFullscalePan = ge.add_fullscale_pan > 0 + self.Permissive = ge.permissive > 0 + # elif len(kwargs) != 0: + # raise SDKException("Could not handle every input parameter in GeneralExportSettings!") + + pass + + def getInternal(self): + ge = cuvis_il.cuvis_export_general_settings_t() + ge.export_dir = self.ExportDir + ge.channel_selection = self.ChannelSelection + ge.spectra_multiplier = float(self.SpectraMultiplier) + ge.pan_scale = float(self.PanScale) + ge.pan_interpolation_type = PanSharpeningInterpolationType[self.PanSharpeningInterpolationType] + ge.pan_algorithm = PanSharpeningAlgorithm[self.PanSharpeningAlgorithmType] + ge.add_pan = int(self.AddPan) + ge.add_fullscale_pan = int(self.AddFullscalePan) + ge.permissive = int(self.Permissive) + return ge + + +class EnviExportSettings(GeneralExportSettings): + def __init__(self, **kwargs): + super().__init__(**kwargs) + pass + + def getInternal(self): + ge = super().getInternal() + es = None + return ge, es + + +class TiffExportSettings(GeneralExportSettings): + + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.CompressionMode = "None" + self.Format = "MultiChannel" + + self.check_kwargs(kwargs) + + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_export_tiff_settings_t): + ts = list(kwargs.values())[0] + self.CompressionMode = \ + [key for key, val in TiffCompressionMode.items() if val == ts.compression_mode][0] + self.Format = [key for key, val in TiffFormat.items() if val == ts.format][0] + elif len(kwargs) != 0: + raise SDKException("Could not handle input parameter(s) in TiffExportSettings: {}".format(kwargs.keys())) + pass + + def getInternal(self): + ge = super().getInternal() + ts = cuvis_il.cuvis_export_tiff_settings_t() + ts.compression_mode = TiffCompressionMode[self.CompressionMode] + ts.format = TiffFormat[self.Format] + return ge, ts + + +class ViewExportSettings(GeneralExportSettings): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.Userplugin = None + + self.check_kwargs(kwargs) + + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_export_view_settings_t): + vs = list(kwargs.values())[0] + self.Userplugin = vs.userplugin + elif len(kwargs) != 0: + raise SDKException("Could not handle input parameter(s) in ViewExportSettings: {}".format(kwargs.keys())) + pass + + if '' not in self.Userplugin: + try: + with open(self.Userplugin) as f: + userplugintmp = f.readlines() + self.Userplugin = "".join(userplugintmp) + except: + raise ValueError("Could not read plugin from {}".format(self.Userplugin)) + + def getInternal(self): + ge = super().getInternal() + vs = cuvis_il.cuvis_export_view_settings_t() + vs.userplugin = self.Userplugin + return ge, vs + + +class CubertSaveArgs(GeneralExportSettings): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.AllowOverwrite = False + self.AllowFragmentation = False + self.AllowDrop = False + self.AllowSessionFile = True + self.AllowInfoFile = True + self.OperationMode = "Software" + self.FPS = 0 + self.SoftLimit = 20 + self.HardLimit = 100 + self.MaxBuftime = 10000 + + self.check_kwargs(kwargs) + + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_save_args_t): + sa = list(kwargs.values())[0] + self.AllowOverwrite = sa.allow_overwrite > 0 + self.AllowFragmentation = sa.allow_fragmentation > 0 + self.AllowDrop = sa.allow_drop > 0 + self.AllowSessionFile = sa.allow_session_file > 0 + self.AllowInfoFile = sa.allow_info_file > 0 + self.OperationMode = [k for k, v in OperationMode.items() if v == sa.operation_mode][0] + self.FPS = sa.fps + self.SoftLimit = sa.soft_limit + self.HardLimit = sa.hard_limit + self.MaxBuftime = sa.max_buftime + elif len(kwargs) != 0: + raise SDKException("Could not handle input parameter(s) in CubertSaveArgs: {}".format(kwargs.keys())) + + pass + + def getInternal(self): + ge = super().getInternal() + sa = cuvis_il.cuvis_save_args_t() + sa.allow_overwrite = int(self.AllowOverwrite) + sa.allow_fragmentation = int(self.AllowFragmentation) + sa.allow_drop = int(self.AllowDrop) + sa.allow_session_file = int(self.AllowSessionFile) + sa.allow_info_file = int(self.AllowInfoFile) + sa.operation_mode = OperationMode[self.OperationMode] + sa.fps = int(self.FPS) + sa.soft_limit = int(self.SoftLimit) + sa.hard_limit = int(self.HardLimit) + sa.max_buftime = int(self.MaxBuftime) + return ge, sa + + +class CubertProcessingArgs(GeneralExportSettings): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.AllowRecalib = False + self.ProcessingMode = "Raw" + + self.check_kwargs(kwargs) + + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_proc_args_t): + pa = list(kwargs.values())[0] + self.AllowRecalib = pa.allow_recalib > 0 + self.ProcessingMode = [k for k, v in ProcessingMode.items() if v == pa.processing_mode][0] + elif len(kwargs) != 0: + raise SDKException("Could not handle input parameter(s) in CubertProcessingArgs: {}".format(kwargs.keys())) + pass + + def getInternal(self): + ge = super().getInternal() + pa = cuvis_il.cuvis_proc_args_t() + pa.allow_recalib = int(self.AllowRecalib) + pa.processing_mode = int(ProcessingMode[self.ProcessingMode]) + return ge, pa + + +class CubertWorkerSettings(GeneralExportSettings): + def __init__(self, **kwargs): + super().__init__(**kwargs) + self.WorkerCount = 0 + self.PollInterval = 10 + self.KeepOutOfSequence = False + self.WorkerQueueSize = 100 + + self.check_kwargs(kwargs) + + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_worker_settings_t): + wa = list(kwargs.values())[0] + self.WorkerCount = wa.worker_count + self.PollInterval = wa.poll_interval + self.KeepOutOfSequence = wa.keep_out_of_sequence > 0 + self.WorkerQueueSize = wa.worker_queue_size + elif len(kwargs) != 0: + raise SDKException("Could not handle input parameter(s) in CubertWorkerArgs: {}".format(kwargs.keys())) + + pass + + def getInternal(self): + ge = super().getInternal() + wa = cuvis_il.cuvis_worker_settings_t() + wa.worker_count = int(self.WorkerCount) + wa.poll_interval = int(self.PollInterval) + wa.keep_out_of_sequence = int(self.KeepOutOfSequence) + wa.worker_queue_size = int(self.WorkerQueueSize) + return ge, wa diff --git a/Python/src/cuvis/General.py b/Python/src/cuvis/General.py new file mode 100644 index 0000000..a37c73c --- /dev/null +++ b/Python/src/cuvis/General.py @@ -0,0 +1,83 @@ +import logging +import os + +from . import cuvis_il +from .cuvis_aux import SDKException +from .cuvis_types import ComponentType + + +class General(object): + def __init__(self, path=""): + FORMAT = '%(asctime)s -- %(levelname)s: %(message)s' + if os.path.exists(path): + log_path = path + os.sep + else: + log_path = os.getenv('APPDATA') + os.sep + ".cuvis" + os.sep + + if os.path.exists(log_path): + logging.basicConfig(filename=log_path + "cuvisSDK_python.log", + format=FORMAT, + encoding='utf-8', + level=logging.DEBUG, + filemode='w') + else: + raise SDKException("path {} does not exist...".format(os.path.abspath(log_path))) + logging.info("Logger ready.") + + if cuvis_il.status_ok != cuvis_il.cuvis_init(log_path): + raise SDKException() + pass + + def getVersion(self): + return cuvis_il.cuvis_version_swig() + + def setLogLevel(self, lvl): + lvl_dict = {"info": {"cuvis": cuvis_il.loglevel_info, + "logging": logging.INFO}, + "debug": {"cuvis": cuvis_il.loglevel_debug, + "logging": logging.DEBUG}, + "error": {"cuvis": cuvis_il.loglevel_error, + "logging": logging.ERROR}, + "fatal": {"cuvis": cuvis_il.loglevel_fatal, + "logging": logging.CRITICAL}, + "warning": {"cuvis": cuvis_il.loglevel_warning, + "logging": logging.WARNING}, + } + + cuvis_il.cuvis_set_log_level(lvl_dict[lvl]["cuvis"]) + logging.basicConfig(level=lvl_dict[lvl]["logging"]) + + +class ComponentInfo(object): + def __init__(self, **kwargs): + self.Type = None + self.DisplayName = None + self.SensorInfo = None + self.UserField = None + self.Pixelformat = None + + [self.__setattr__(key, kwargs.pop(key, None)) for key in self.__dict__ if not key.startswith("__")] + + if all([getattr(self, key) is None for key in self.__dict__ if not key.startswith("__")]): + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_component_info_t): + ci = list(kwargs.values())[0] + self.Type = [key for key, val in ComponentType.items() if val == ci.type][0] + self.DisplayName = ci.displayname + self.SensorInfo = ci.sensorinfo + self.UserField = ci.userfield + self.Pixelformat = ci.pixelformat + elif len(kwargs) != 0: + raise SDKException("Could not handle every input parameter in ComponentInfo!") + else: + if len(kwargs) == 1 and isinstance(list(kwargs.values())[0], cuvis_il.cuvis_component_info_t): + raise SDKException("Could not handle every input parameter in ComponentInfo!") + pass + + def getInternal(self): + ci = cuvis_il.cuvis_component_info_t() + ci.type = ComponentType[self.Type] + ci.displayname = self.DisplayName + ci.sensorinfo = self.SensorInfo + ci.userfield = self.UserField + ci.pixelformat = self.Pixelformat + return ci diff --git a/Python/src/cuvis/Measurement.py b/Python/src/cuvis/Measurement.py new file mode 100644 index 0000000..35c498b --- /dev/null +++ b/Python/src/cuvis/Measurement.py @@ -0,0 +1,260 @@ +import os +import datetime +from copy import deepcopy + +from . import cuvis_il +from .cuvis_aux import SDKException, __bit_translate__, __object_declassifier__ +from .cuvis_types import DataFormat, ProcessingMode + +base_datetime = datetime.datetime(1970, 1, 1) + + +class Measurement(object): + + def __init__(self, base): + self.__handle__ = None + self.__metaData__ = cuvis_il.cuvis_mesu_metadata_t() + + self.Data = None + + self.CaptureTime = None + self.MeasurementFlags = None + self.Path = None + self.Comment = None + self.FactoryCalibration = None + self.Assembly = None + self.Averages = None + self.IntegrationTime = None + self.SerialNumber = None + self.ProductName = None + self.ProcessingMode = None + self.Name = None + self.Session = None + + if isinstance(base, int): + self.__handle__ = base + elif isinstance(base, str) and os.path.exists(base): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_load(base, _ptr): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + else: + raise SDKException("Could not open Measurement! Either handle not available or file not found!") + self.__metaData__ = cuvis_il.cuvis_mesu_metadata_allocate() + self.refresh() + pass + + def load(self, file): + self.__init__(file) + pass + + def refresh(self): + self.Data = {} + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_get_metadata(self.__handle__, self.__metaData__): + raise SDKException + + base_datetime = datetime.datetime(1970, 1, 1) + self.CaptureTime = base_datetime + datetime.timedelta(milliseconds=self.__metaData__.capture_time) + self.MeasurementFlags = self.__metaData__.measurement_flags + cuvis_il.CUVIS_MESU_FLAG_DARK_INTTIME + #TODO: Flags should be more and better info! + self.Path = self.__metaData__.path + self.Comment = self.__metaData__.comment + self.FactoryCalibration = base_datetime + datetime.timedelta(milliseconds=self.__metaData__.factory_calibration) + self.Assembly = self.__metaData__.assembly + self.Averages = self.__metaData__.averages + self.IntegrationTime = self.__metaData__.integration_time + self.SerialNumber = self.__metaData__.serial_number + self.ProductName = self.__metaData__.product_name + self.ProcessingMode = \ + [key for key, val in ProcessingMode.items() if val == self.__metaData__.processing_mode][0] + self.Name = self.__metaData__.name + # self.Session = SessionData(self.__metaData__.session_info.name, self.__metaData__.session_info.session_no, + # self.__metaData__.session_info.sequence_no) + + pcount = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_get_data_count(self.__handle__, pcount): + raise SDKException() + for ind in range(cuvis_il.p_int_value(pcount)): + pType = cuvis_il.new_p_cuvis_data_type_t() + key = cuvis_il.cuvis_measurement_get_data_info_swig(self.__handle__, pType, ind) + cdtype = cuvis_il.p_cuvis_data_type_t_value(pType) + if cdtype == cuvis_il.data_type_image: + data = cuvis_il.cuvis_imbuffer_t() + cuvis_il.cuvis_measurement_get_data_image(self.__handle__, + key, + data) + t0 = datetime.datetime.now() + self.Data.update({key: ImageData(img_buf=data, dformat=DataFormat[data.format])}) + # print("image loading time: {}".format(datetime.datetime.now() - t0)) + elif cdtype == cuvis_il.data_type_string: + val = cuvis_il.cuvis_measurement_get_data_string_swig(self.__handle__, key) + self.Data.update({key: val}) + elif cdtype == cuvis_il.data_type_gps: + gps = cuvis_il.cuvis_gps_t() + cuvis_il.cuvis_measurement_get_data_gps(self.__handle__, key, gps) + self.Data.update({key: gps}) + elif cdtype == cuvis_il.data_type_sensor_info: + info = cuvis_il.cuvis_sensor_info_t() + cuvis_il.cuvis_measurement_get_data_sensor_info(self.__handle__, key, info) + self.Data.update({key: info}) + else: + self.Data.update({key: "Not Implemented!"}) + + def save(self, saveargs): + ge, sa = saveargs.getInternal() + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_save(self.__handle__, ge.export_dir, sa): + raise SDKException() + pass + + def set_name(self, name): # done + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_set_name(self.__handle__, name): + raise SDKException() + self.Name = name + pass + + def get_thumbnail(self): + thumbnail = [val for key, val in self.Data.items() if "view" in key] + if len(thumbnail) == 0: + print("No thumbnail available. Use cube instead!") + pass + elif len(thumbnail) == 1: + return thumbnail[0] + elif len(thumbnail) > 1: + shapes = [th.array.shape for th in thumbnail] + return thumbnail[shapes.index(min(shapes))] + + def get_data_info(self): + return_dict = {} + for att in self.Data["IMAGE_info"].__dir__(): + if not (att.startswith("__") or att.startswith("this")): + return_dict.update({att: self.Data["IMAGE_info"].__getattribute__(att)}) + try: + return_dict["readout_time"] = str( + base_datetime + datetime.timedelta(milliseconds=return_dict["readout_time"])) + except: + print("No human readable readout_time available!") + return return_dict + + def get_capabilities(self): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_get_capabilities(self.__handle__, _ptr): + raise SDKException() + return __bit_translate__(cuvis_il.p_int_value(_ptr)) + + def set_comment(self, comment): + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_set_comment(self.__handle__, comment): + raise SDKException() + self.Comment = comment + self.__metaData__.comment = comment + pass + + def get_metadata(self): + return_MD = __object_declassifier__(self.__metaData__) + for k, val in return_MD.items(): + if k in ["capture_time", "factory_calibration"]: + return_MD[k] = str(base_datetime + datetime.timedelta(milliseconds=val)) + return_MD.pop("this") + return_MD.pop("thisown") + return return_MD + + def get_data_count(self): # done + out = cuvis_il.new_p_int() + cuvis_il.cuvis_measurement_get_data_count(self.__handle__, out) + return cuvis_il.p_int_value(out) + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_measurement_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) + + cuvis_il.cuvis_mesu_metadata_free(self.__metaData__) + + self.Data = {} + + self.CaptureTime = None + self.MeasurementFlags = None + self.Path = None + self.Comment = None + self.FactoryCalibration = None + self.Assembly = None + self.Averages = None + self.IntegrationTime = None + self.SerialNumber = None + self.ProductName = None + self.ProcessingMode = None + self.Name = None + self.Session = None + pass + + def __deepcopy__(self, memo): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_deep_copy(self.__handle__, _ptr): + raise SDKException() + copy = Measurement(cuvis_il.p_int_value(_ptr)) + return copy + + cls = self.__class__ + res = cls.__new__(cls) + memo[id(self)] = res + for k, v in self.__dict__.items(): + print("copying: {}".format(k)) + try: + setattr(res, k, deepcopy(v, memo)) + except: + print("issues with deep copying {}".format(k)) + if k == "__metaData__": + setattr(res, k, None) + res.__metaData__ = cuvis_il.cuvis_mesu_metadata_t() + res.__metaData__ = cuvis_il.cuvis_mesu_metadata_allocate() + if cuvis_il.status_ok != cuvis_il.cuvis_measurement_get_metadata(res.__handle__, + res.__metaData__): + raise SDKException + else: + print("__metaData__ set!") + + else: + setattr(res, k, v) + return res + + +class ImageData(object): + def __init__(self, img_buf=None, dformat=None): + + if img_buf is None: + + self.width = None + self.height = None + self.channels = None + self.array = None + self.wavelength = None + + elif isinstance(img_buf, cuvis_il.cuvis_imbuffer_t): + + if dformat is None: + raise TypeError("Missing format for reading image buffer") + + if img_buf.format == 1: + self.array = cuvis_il.cuvis_read_imbuf_uint8(img_buf) + elif img_buf.format == 2: + self.array = cuvis_il.cuvis_read_imbuf_uint16(img_buf) + elif img_buf.format == 3: + self.array = cuvis_il.cuvis_read_imbuf_uint32(img_buf) + elif img_buf.format == 4: + self.array = cuvis_il.cuvis_read_imbuf_float32(img_buf) + else: + raise SDKException() + + self.width = img_buf.width + self.height = img_buf.height + self.channels = img_buf.channels + + if img_buf.wavelength is not None: + self.wavelength = [cuvis_il.p_unsigned_int_getitem(img_buf.wavelength, z) for z in + range(self.channels)] + + # print("got image of size {}.".format(self.array.shape)) + + else: + raise TypeError("Wrong data type for image buffer: {}".format(type(img_buf))) diff --git a/Python/src/cuvis/ProcessingContext.py b/Python/src/cuvis/ProcessingContext.py new file mode 100644 index 0000000..52231b2 --- /dev/null +++ b/Python/src/cuvis/ProcessingContext.py @@ -0,0 +1,113 @@ +from . import cuvis_il +from .Calibration import Calibration +from .Measurement import Measurement +from .Session import Session +from .cuvis_aux import SDKException +from .cuvis_types import ReferenceType, ProcessingMode +from .FileWriteSettings import CubertProcessingArgs + + +class ProcessingContext(object): + def __init__(self, base): + self.__handle__ = None + self.__modeArgs__ = cuvis_il.cuvis_proc_args_t() + + if isinstance(base, Calibration): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_create_from_calib(base.__handle__, _ptr): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + elif isinstance(base, Session): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_create_from_session_file(base.__handle__, _ptr): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + elif isinstance(base, Measurement): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_create_from_mesu(base.__handle__, _ptr): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + else: + raise SDKException("could not interpret input of type {}.".format(type(base))) + pass + + def apply(self, mesu): + if isinstance(mesu, Measurement): + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_apply(self.__handle__, mesu.__handle__): + raise SDKException() + mesu.refresh() + return mesu + else: + raise SDKException("Can only apply ProcessingContext to Measurement!") + pass + + def setReference(self, mesu, refType): + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_set_reference(self.__handle__, mesu.__handle__, + ReferenceType[refType]): + raise SDKException() + pass + + def clearReference(self, refType): + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_clear_reference(self.__handle__, ReferenceType[refType]): + raise SDKException() + pass + + def getReference(self, refType): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_get_reference(self.__handle__, _ptr, + ReferenceType[refType]): + raise SDKException() + return Measurement(cuvis_il.p_int_value(_ptr)) + + def hasReference(self, refType): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_has_reference(self.__handle__, ReferenceType[refType], + _ptr): + raise SDKException() + return cuvis_il.p_int_value(_ptr) == 1 + + def setProcessingMode(self, pMode): + self.__modeArgs__.processing_mode = ProcessingMode[pMode] + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_set_args(self.__handle__, self.__modeArgs__): + raise SDKException() + pass + + def getProcessingMode(self): + return [key for key, val in ProcessingMode.items() if val == self.__modeArgs__.processing_mode][0] + + def setProcessingArgs(self, pa): + _, self.__modeArgs__ = pa.getInternal() + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_set_args(self.__handle__, self.__modeArgs__): + raise SDKException() + pass + + def getProcessingArgs(self): + return CubertProcessingArgs(args=self.__modeArgs__) + + def isCapable(self, mesu, pa): + _, args = pa.getInternal() + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_is_capable(self.__handle__, mesu.__handle__, args, _ptr): + raise SDKException() + return cuvis_il.p_int_value(_ptr) == 1 + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_proc_cont_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) + pass + + def calcDistance(self, distMM): + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_calc_distance(self.__handle__, distMM): + raise SDKException() + return True + + def setRecalib(self, val): + self.__modeArgs__.allow_recalib = int(val) + if cuvis_il.status_ok != cuvis_il.cuvis_proc_cont_set_args(self.__handle__, self.__modeArgs__): + raise SDKException() + pass + + def getRecalib(self): + return self.__modeArgs__.allow_recalib != 0 diff --git a/Python/src/cuvis/Session.py b/Python/src/cuvis/Session.py new file mode 100644 index 0000000..a4eb1a3 --- /dev/null +++ b/Python/src/cuvis/Session.py @@ -0,0 +1,67 @@ +import os + +from . import cuvis_il +from .Measurement import Measurement +from .cuvis_aux import SDKException +from .cuvis_types import OperationMode + + +class Session(object): + def __init__(self, base): + self.__handle__ = None + if isinstance(base, str) and os.path.exists(base): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_session_file_load(base, _ptr): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + else: + raise SDKException("Could not open Session File! File not found!") + + pass + + def load(self, file): + self.__init__(file) + pass + + def getSizeNonDropped(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_session_file_get_size_non_dropped(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getMeasurementsNonDropped(self, frameNo): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_session_file_get_mesu_non_dropped(self.__handle__, frameNo, _ptr): + raise SDKException() + return Measurement(cuvis_il.p_int_value(_ptr)) + + def getMeasurement(self, frameNo): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_session_file_get_mesu(self.__handle__, frameNo, _ptr): + raise SDKException() + return Measurement(cuvis_il.p_int_value(_ptr)) + + def getSize(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_session_file_get_size(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getFPS(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_session_file_get_fps(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def getOperationMode(self): + val = cuvis_il.new_p_cuvis_operation_mode_t() + if cuvis_il.status_ok != cuvis_il.cuvis_session_file_get_operation_mode(self.__handle__, val): + raise SDKException() + return [key for key, vald in OperationMode.items() + if vald == cuvis_il.p_cuvis_operation_mode_t_value(val)][0] + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_session_file_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) diff --git a/Python/src/cuvis/Viewer.py b/Python/src/cuvis/Viewer.py new file mode 100644 index 0000000..57104a1 --- /dev/null +++ b/Python/src/cuvis/Viewer.py @@ -0,0 +1,66 @@ +import cuvis.cuvis_il + +from . import cuvis_il +from .Measurement import ImageData +from .cuvis_aux import SDKException +from .cuvis_types import CUVIS_imbuffer_format + + +class Viewer(object): + def __init__(self, settings): + self.__handle__ = None + self.ViewerSettings = settings + + if isinstance(settings, int): + self.__handle__ = settings + if isinstance(self.ViewerSettings, cuvis_il.cuvis_viewer_settings_t): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_viewer_create(_ptr, self.ViewerSettings): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + else: + raise SDKException("Could not open viewer_settings of type {}!".format(type(self.ViewerSettings))) + + pass + + def getDataCount(self, mesu): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_viewer_apply(self.__handle__, mesu.__handle__, _ptr): + raise SDKException() + currentView = cuvis_il.p_int_value(_ptr) + + countHandle = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_view_get_data_count(currentView, countHandle): + raise SDKException() + + return cuvis_il.p_int_value(countHandle) + + def apply(self, mesu): + _ptr = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_viewer_apply(self.__handle__, mesu.__handle__, _ptr): + raise SDKException() + currentView = cuvis_il.p_int_value(_ptr) + + countHandle = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_view_get_data_count(currentView, countHandle): + raise SDKException() + + dataCount = cuvis_il.p_int_value(countHandle) + + for i in range(dataCount): + view_data = cuvis_il.cuvis_view_data_t() + if cuvis_il.status_ok != cuvis_il.cuvis_view_get_data(currentView, i, view_data): + raise SDKException() + + if view_data.data.format == CUVIS_imbuffer_format["imbuffer_format_uint8"]: + return ImageData(img_buf=view_data.data, dformat=view_data.data.format) + else: + raise SDKException("Unsupported viewer bit depth!") + + pass + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_viewer_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) diff --git a/Python/src/cuvis/Worker.py b/Python/src/cuvis/Worker.py new file mode 100644 index 0000000..c99015b --- /dev/null +++ b/Python/src/cuvis/Worker.py @@ -0,0 +1,102 @@ +from . import cuvis_il +from .Measurement import Measurement +from .Viewer import Viewer +from .cuvis_aux import SDKException + + +class Worker(object): + def __init__(self, args): + self.exporterSet = False + self.acquisitionSet = False + self.processingSet = False + self.viewerSet = False + + self.__handle__ = None + _ptr = cuvis_il.new_p_int() + _, settings = args.getInternal() + if cuvis_il.status_ok != cuvis_il.cuvis_worker_create(_ptr, settings): + raise SDKException() + self.__handle__ = cuvis_il.p_int_value(_ptr) + pass + + def setAcquisitionContext(self, base=None): + if base is not None: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_acq_cont(self.__handle__, base.__handle__): + raise SDKException() + else: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_acq_cont(self.__handle__, 0): + raise SDKException() + self.acquisitionSet = True + pass + + def setProcessingContext(self, base=None): + if base is not None: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_proc_cont(self.__handle__, base.__handle__): + raise SDKException() + else: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_proc_cont(self.__handle__, 0): + raise SDKException() + self.processingSet = True + pass + + def setExporter(self, base=None): + if base is not None: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_exporter(self.__handle__, base.__handle__): + raise SDKException() + else: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_exporter(self.__handle__, 0): + raise SDKException() + self.exporterSet = True + pass + + def setViewer(self, base=None): + if base is not None: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_viewer(self.__handle__, base.__handle__): + raise SDKException() + else: + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_viewer(self.__handle__, 0): + raise SDKException() + self.viewerSet = True + pass + + def hasNextResult(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_worker_has_next_result(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) != 0 + + def getNextResult(self): + this_mesu = cuvis_il.new_p_int() + this_viewer = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_worker_get_next_result(self.__handle__, this_mesu, this_viewer): + raise SDKException() + mesu = Measurement(cuvis_il.p_int_value(this_mesu)) + if self.viewerSet: + view = Viewer(cuvis_il.p_int_value(this_viewer)).apply(this_mesu) + else: + view = None + return {"Measurement": mesu, "View": view} + # return mesu + + def getQueueSize(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_worker_get_queue_limit(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def setQueueSize(self, val): + if cuvis_il.status_ok != cuvis_il.cuvis_worker_set_queue_limit(self.__handle__, val): + raise SDKException() + pass + + def getQueueUsed(self): + val = cuvis_il.new_p_int() + if cuvis_il.status_ok != cuvis_il.cuvis_worker_get_queue_used(self.__handle__, val): + raise SDKException() + return cuvis_il.p_int_value(val) + + def __del__(self): + _ptr = cuvis_il.new_p_int() + cuvis_il.p_int_assign(_ptr, self.__handle__) + cuvis_il.cuvis_worker_free(_ptr) + self.__handle__ = cuvis_il.p_int_value(_ptr) diff --git a/Python/src/cuvis/__init__.py b/Python/src/cuvis/__init__.py new file mode 100644 index 0000000..e6e2224 --- /dev/null +++ b/Python/src/cuvis/__init__.py @@ -0,0 +1,25 @@ +import os +import sys +from pathlib import Path + +lib_dir = os.getenv("CUVIS") +os.add_dll_directory(lib_dir) +add_il = Path(lib_dir).parents[0].joinpath("sdk", "cuvis_python") +sys.path.append(str(add_il)) + + +from .AcquisitionContext import AcquisitionContext +from .Calibration import Calibration +from .Export import CubeExporter, EnviExporter, TiffExporter, ViewExporter +from .FileWriteSettings import GeneralExportSettings, CubertSaveArgs, CubertProcessingArgs,\ + EnviExportSettings, TiffExportSettings, ViewExportSettings, CubertWorkerSettings +from .General import General +from .Measurement import Measurement +from .ProcessingContext import ProcessingContext +from .Session import Session +from .Viewer import Viewer +from .Worker import Worker +from . import classificator + + + diff --git a/Python/src/cuvis/classificator/__init__.py b/Python/src/cuvis/classificator/__init__.py new file mode 100644 index 0000000..b34640f --- /dev/null +++ b/Python/src/cuvis/classificator/__init__.py @@ -0,0 +1,6 @@ +from .labelingGUI import LabelingGUI +from .preprocessor import Preprocessor +from .model import Model +from .postprocessor import Postprocessor +from .auxiliary import DataLabel +from .classificator import CuvisClassificator diff --git a/Python/src/cuvis/classificator/auxiliary.py b/Python/src/cuvis/classificator/auxiliary.py new file mode 100644 index 0000000..7ff4f17 --- /dev/null +++ b/Python/src/cuvis/classificator/auxiliary.py @@ -0,0 +1,614 @@ +import os +import pandas as pd +import warnings +import cuvis +import numpy as np +import cv2 as cv +from operator import truediv +import time +import xarray + + + +class DataLabel(object): + """ + a class handling data labels + + Handling a pandas dataframe for conforming with the interface requirements in the classificator module. + Prepares attributes that are relevant for further use. + Provides read and write functionality. + + Attributes + ---------- + file : str + the filename of the interface table to read/write + table : pandas.Dataframe + the contents of the interface table + data_images : list + a list of all the used images + all_labels : list + a list of all the used labels + has_test : bool + a check if the table has a test subset + + Methods + ------- + read() + reads the specified file + write() + writes the specified file + add(list_dict) + adds a dictionary entry to the table + """ + # define minimum table requirements + __min_table_requirements__ = ["File", "Test"] + + # basic attributes + file = None + table = pd.DataFrame() + data_images = [] + all_labels = [] + has_test = False + + def __init__(self, file): + """ + initialization + + Basic initialization with file name. + + Parameters + __________ + file : str, required + path to a specified file + """ + self.file = file + pass + + def read(self): + """ + read specified file + + Fills the class attributes by reading the specified file. + + Raises + ------ + WrongInputException + If read table does not conform minimum requirements. + FileNotFoundError + If file is not found. + """ + # check if file exists and read + if os.path.isfile(self.file): + self.table = pd.read_csv(self.file) + # check if requirements are met + if not self._has_min_requirements_(self.table.columns): + print(self) + raise WrongInputException(self.__min_table_requirements__) + else: + raise FileNotFoundError(self.file) + # extracting attributes + self._extract_info_() + pass + + def write(self, overwrite=False): + """ + writes specified file + + Writes a csv based on the class attributes. + + Parameters + __________ + overwrite : bool, optional + Should a file be overwritten if it already exists? + + Raises + ------ + NoOverwriteException + If file exists and overwrite is not set. + """ + # check if file exists and can be overwritten + if os.path.isfile(self.file): + if overwrite: + self.table.to_csv(self.file, index=False) + else: + raise NoOverwriteException( + "{} cannot be overwritten as overwrite option is not True!".format(self.file)) + else: + self.table.to_csv(self.file, index=False) + pass + + def add(self, line_dict): + """ + adds a dictionary to the table + + Writes a pandas dataframe based on the class attributes. + + Parameters + __________ + line_dict : dictionary, required + This dictionary is added to the table of files and labels + + Raises + ------ + WrongInputException + If dict does not conform minimum requirements. + """ + # check for requirements + if not self._has_min_requirements_(line_dict.keys()): + print(line_dict) + raise WrongInputException(self.__min_table_requirements__) + # make dataframe from dictionary + loc_table = pd.DataFrame.from_dict([line_dict]) + # append dictionary dataframe to table + self.table = pd.concat([self.table, loc_table], ignore_index=True) + # remove duplicates + self.table.drop_duplicates(inplace=True) + # extracting attributes + self._extract_info_() + pass + + def _has_min_requirements_(self, testkeys): + """ + tests a list of keys to conforming to minimum requirements + + All keys in testkeys will be tested against the self.__min_table_requirements__ definition. + + Parameters + __________ + testkeys : list, required + the keys that are tested against minimum requirements + + Returns + ------- + bool + a boolean if minimum requirements are met + """ + contain = all([key in testkeys for key in self.__min_table_requirements__]) + return contain + + def _extract_info_(self): + """ + extracts all attributes + + Extracts class attributes from the read table. + + Raises + ------ + IOError + If Test column is not boolean. + """ + # check if Test column is boolean + test_column = self.table.loc[:, "Test"] + if test_column.dtype.name != 'bool': + raise IOError("Expected Test column to be boolean!") + else: + self.has_test = any(test_column) + # get all labels + self.all_labels = [key for key in self.table.columns if key not in self.__min_table_requirements__] + # get all image files + self.data_images = list(self.table.loc[:, "File"]) + pass + + def __repr__(self): + """ + overwrites standard __repr__ with the representation of the table + """ + return str(self.table) + + +class NoOverwriteException(FileExistsError): + pass + + +class WrongInputException(IOError): + def __init__(self, req): + super(WrongInputException, self).__init__( + "Input needs to meet the availability of the required columns: {}!".format(", ".join(req))) + + pass + + +def cu3s_from_dir(load_path): + files = [] + for file in os.listdir(load_path): + filename = os.fsdecode(file) + if filename.endswith(".cu3"): # or filename.endswith(".cu3s"): + # print("Found " + os.path.join(load_path, filename)) + files.append(os.path.join(load_path, filename)) + continue + else: + continue + if len(files) == 0: + raise IOError("No .cu3s found in : {}".format(load_path)) + return files + + +def data_from_csv(classi_dir): + """ + prepares data based on a LUT of labels + + prepares a pandas.DataFrame from a labels LUT with pixel based cube data, followed by the mask data for the labels + + Parameters + __________ + classi_dir : str, required + classification directory that defines where the cuvis_labels.csv from the labeling GUI is + + Returns + ------- + data + the training data pandas.DataFrame + test_data + the testing data pandas.DataFrame + dlen + the data length (number of columns in the pandas.DataFrame, start) + llen + the label length (number of columns in the pandas.DataFrame, end) + """ + + interface_file = os.path.join(classi_dir, r"labels", r"cuvis_labels.csv") + print("Start configuring from " + interface_file + " ...") + labels = DataLabel(interface_file) + labels.read() + + # initialize returns + data = pd.DataFrame() + test_data = pd.DataFrame() + dlen = 0 + llen = 0 + orig_image_dimensions = [0, 0, 0] + + ##### help functions + + # reshaping an array to pixelorder + def img_reshape(array): + reshaped = np.moveaxis(array, -1, 0).reshape(array.shape[-1], -1) + return reshaped + + # get mask values + def get_masks(row, labels, classi_dir): + mask_dict = {} + for lbl in labels: + mask_data = cv.imread(os.path.join(os.path.join(classi_dir, "labels"), row[lbl]), 0) + mask_data = mask_data.reshape(np.prod(mask_data.shape)) + mask_data = mask_data > 128 + mask_dict.update({lbl: mask_data}) + return mask_dict + + ##### + + # check for test data + if not labels.has_test: + print("Test data not found! No independent analysis of goodness of fit will be available.") + + # else: + # print("Test data found!") + + # set cuvis settings + gen = cuvis.General(r"C:\Program Files\cuvis\user\settings") + print(gen.getVersion()) + + res_test_data = [] + res_data = xarray.Dataset() + + # read cubes + for file in np.unique(labels.data_images): + mesu_path = os.path.join(classi_dir, file) + if os.path.isfile(mesu_path): + # read spectra + mesu_cube = cuvis.Measurement(mesu_path).Data["cube"] + orig_image_dimensions = mesu_cube.array.shape + spectra = img_reshape(mesu_cube.array) + dlen = len(mesu_cube.wavelength) + # read masks + file_rows = labels.table[labels.table["File"] == file] + for rid, f_row in file_rows.iterrows(): + if f_row["Test"]: + # add spectra and masks + mask_dict = get_masks(f_row, labels.all_labels, classi_dir) + llen = len(mask_dict.keys()) + masks = pd.DataFrame(mask_dict).to_xarray() + res_test_data.append({"cube": mesu_cube, "labels": masks, "name": mesu_path}) + else: + # add spectra and masks + mask_dict = get_masks(f_row, labels.all_labels, classi_dir) + llen = len(mask_dict.keys()) + data = pd.DataFrame(spectra.T, columns=["{} nm".format(wl) for wl in mesu_cube.wavelength]) + masks = pd.DataFrame(mask_dict) + data = pd.concat([data, masks], axis=1).to_xarray() + try: + try: + data["index"] = data["index"] + np.max(res_data["index"].values)+1 + except: + 0 + res_data = xarray.concat([res_data, data], dim="index") + except ValueError: + res_data = data + else: + raise IOError("File not found: {}".format(file)) + + if len(test_data.columns): + assert (dlen + llen) == len(res_test_data.columns), "The test dimensions do not fit, something went wrong! " + if len(data.keys()): + assert (dlen + llen) == len(res_data.keys()), "The data dimensions do not fit, something went wrong! " + + label_dict = get_label_dict(list(res_data.keys())[-llen:]) + return res_data, res_test_data, dlen, llen, orig_image_dimensions, label_dict + + +def get_test_cu3s(classi_dir): + interface_file = os.path.join(classi_dir, r"labels", r"cuvis_labels.csv") + labels = DataLabel(interface_file) + labels.read() + files = [] + for file in np.unique(labels.data_images): + mesu_path = os.path.join(classi_dir, file) + if os.path.isfile(mesu_path): + file_rows = labels.table[labels.table["File"] == file] + for rid, f_row in file_rows.iterrows(): + if f_row["Test"]: + files.append(os.path.join(classi_dir, file)) + return files + + +def convert_to_binary(input_image): + """ + converts 3 channel BGR input_image to single channel gray image, where every pixel greater than 0 is converted + to the value of 255 (binarizing) + + Parameters + ---------- + input_image: Mat, required + + Returns + ------- + Mat + + """ + binary = cv.cvtColor(input_image, cv.COLOR_BGR2GRAY) + ret, binary = cv.threshold(binary, 1, 255, cv.THRESH_BINARY) + return binary + + +def check_in_boundary(point, upper_left, lower_right): + """ + + checks if point is in bounds of the rectangle defined by the two points upper_left and lower_right + + Parameters + ---------- + point: tuple(int, int), required + upper_left: tuple(int, int), required + lower_right: tuple(int, int), required + + Returns + ------- + bool + + """ + inside = upper_left[0] < point[0] < lower_right[0] and upper_left[1] < point[1] < lower_right[1] + return inside + + +def find_rgb_idx(mesu): + """ + + finds the indexes of the channels closest to the colors red, green and blue + + Parameters + ---------- + mesu : cuvis_measurement, required + + Returns + ------- + uint8 + + """ + mesu_wl = mesu.Data["cube"].wavelength + mesu_wl = np.asarray(mesu_wl) + + r = (np.abs(mesu_wl - 660)).argmin() # red=630-700 + g = (np.abs(mesu_wl - 520)).argmin() # green=490-560 + b = (np.abs(mesu_wl - 480)).argmin() # blue= 470-490 + return r, g, b + + +def get_rgb_from_cu3(mesu): + """ + + generates a rgb image from a given cube (cu3) + + Generates a rgb image from a given cube (cu3) by selecting 3 channels closest to the desired colors (red, + green, blue), stacking the channels and converting and scaling them to uint8. + + Parameters + ---------- + mesu : cuvis_measurement, required + + Returns + ------- + np.array(x,y,3) + """ + r, g, b = find_rgb_idx(mesu) + cube = mesu.Data["cube"].array + rgb = np.stack((cube[:, :, b], cube[:, :, g], cube[:, :, r]), axis=2) # rgb to bgr + rgb = cv.convertScaleAbs(rgb, alpha=(255.0 / 4096.0)) # convert between 12 bit and 8 bit + + return rgb + + +def convert_labels_binary_to_numeric(labels_binary): + label_no = [] + labels_names = list(labels_binary.variables.keys()) + labels_names.remove("index") + for idx, label in enumerate(labels_names): + label_no.append(idx + 1) + + label_no = np.array(label_no) + summed_labels = np.apply_along_axis(sum, 0, labels_binary.to_array().values) + num_duplicate = np.sum(summed_labels > 1) + num_no_label = np.sum(summed_labels == 0) + + labels_numeric = np.apply_along_axis(lambda x: (label_no * x).sum(), 0, labels_binary.to_array().values) # multiply false,true... + # with numbers from 1 to 8 + labels_numeric[summed_labels != 1] = 0 # set to 0 if no label or multiple + return labels_numeric, num_duplicate, num_no_label + + +def convert_labels_numeric_to_binary(labels_numeric, label_dict): + labels_binary = pd.DataFrame() + for label, item in label_dict.items(): + loc_dict = {label: labels_numeric == item} # array with True/False if condition is true + loc_dict = pd.DataFrame.from_dict(loc_dict) + labels_binary = pd.concat([labels_binary, loc_dict], axis=1) + return labels_binary + + +def get_label_dict(labels_binary): + label_dict = dict() + for idx, label in enumerate(labels_binary): + label_dict.update({label: idx + 1}) + return label_dict + + +def get_new_color(id): + """ + + gives b, g, e values for different colors according to the index given from 0-5 + + Parameters + ---------- + id : int, required + + Returns + ------- + tuple(int) + + """ + + if id < 0 or id > 9: + return (-1, -1, -1) + if id == 0: # red + return (0, 0, 255) + if id == 1: # green + return (0, 255, 0) + if id == 2: # blue + return (255, 0, 0) + if id == 3: # magenta + return (255, 0, 255) + if id == 4: # lightblue + return (255, 255, 0) + if id == 5: # yellow + return (0, 255, 255) + if id == 6: # brown + return (23, 91, 191) + if id == 7: # orange + return (0, 127, 255) + + +# def __split_test_train__(self, lut): +# if lut.has_test: +# print("Test data found!") +# self.train_data = lut.table[np.logical_not(lut.table["Test"])] +# self.test_data = lut.table[lut.table["Test"]] +# else: +# self.train_data = lut.table +# pass## + +# def __gather_data__(self): +# self.train_data = datafromlut(self.train_data) +# self.test_data = datafromlut(self.test_data) + +def goodness_of_fit(test_data, res_labels): + + gofs = [] + + for ind, td in enumerate(test_data): + classes = list(td["labels"].keys()) + + gof = pd.DataFrame(columns=pd.MultiIndex.from_product([["original"], classes]), + index=pd.MultiIndex.from_product([["classification"], list(classes) + ["unlabeled"]])) + + for iind in range(len(classes)): + for jind in range(len(classes)+1): + key1 = classes[iind] + key2 = (list(classes) + ["unlabeled"])[jind] + # print("calculating gof for {} - {}".format(key1, key2)) + orig = td["labels"][key1].to_numpy() + if key2 == "unlabeled": + gen_mask = 0 + for val in res_labels[ind]["labels"].values(): + loc_mask = val["mask"] + gen_mask = loc_mask + gen_mask + trained = np.array(gen_mask).astype(np.bool) + trained = trained.reshape(np.prod(trained.shape)) + gof.loc[("classification", key2), ("original", key1)] = np.sum(np.logical_not(trained)[orig]) + else: + trained = np.array(res_labels[ind]["labels"][key2]["mask"]).astype(np.bool) + trained = trained.reshape(np.prod(trained.shape)) + gof.loc[("classification", key2), ("original", key1)] = np.sum(trained[orig]) + + gofs.append(gof) + + gof = sum(gofs) + + def prec_rec_f1(loc_gof): + tp = np.diag(gof.to_numpy()) + rec = list(map(truediv, tp, np.sum(loc_gof, axis=0))) + prec = list(map(truediv, tp, np.sum(loc_gof, axis=1))) + np.seterr(invalid='ignore') + f1 = list(np.divide(2 * (np.array(prec) * np.array(rec)), (np.array(prec) + np.array(rec)))) + return {"precision": prec, "recall": rec, "f1-score": f1} + + for key, val in prec_rec_f1(gof).items(): + gof[key] = val + [np.nan] + + with pd.option_context('display.max_rows', None, 'display.max_columns', None, "display.precision", 3): + print(gof) + pass + + return gof + + +def get_mesu_dict(file_or_object): + if not isinstance(file_or_object, list): + mesu_list = [file_or_object] + else: + mesu_list = file_or_object + mesu_dict = {} + for el in mesu_list: + t0 = time.time() + name = "" + mesu = None + if isinstance(el, cuvis.Measurement): + name = el.Name + print("Loading Measurement: " + el.Name) + mesu = el + elif isinstance(el, str): + if os.path.isfile(el): + print("Loading Measurement: " + el) + name = el + mesu = cuvis.Measurement(el) + else: + raise NotImplementedError("Can not predict on data with type : {}".format(type(el))) + mesu_dict[name] = mesu + tloading = time.time() + print("Loading in {:.3} s.".format(tloading - t0)) + return mesu_dict + + +if __name__ == "__main__": + dl = DataLabel(r"C:\Users\benjamin.mueller\Documents\dev_test_files\DataLabel.csv") + dl.read() + my_line = { + "File": "anotherfile.cu3", + "Test": False, + "label1": "label1_1.png", + "label3": "label3_1.png", + } + dl.add(my_line) + print(dl) + print(dl.data_images) + print(dl.all_labels) + print(dl.has_test) + # dl.write(overwrite=True) diff --git a/Python/src/cuvis/classificator/classificator.py b/Python/src/cuvis/classificator/classificator.py new file mode 100644 index 0000000..443945c --- /dev/null +++ b/Python/src/cuvis/classificator/classificator.py @@ -0,0 +1,310 @@ +import datetime +import inspect +import warnings +from copy import deepcopy +from pprint import pprint + +import numpy as np +import pandas as pd + +import cuvis +from .preprocessor import Preprocessor as PreProc +from .postprocessor import Postprocessor as PostProc +from .model import Model as Mod +from .auxiliary import data_from_csv, get_mesu_dict, goodness_of_fit +import os +import time +import os.path +import cv2 as cv +import dill +import json +import yaml + + +class CuvisClassificator(object): + _wdir_ = os.getenv("HOME") + _eval_file_ = None + _apply_data_ = None + preprocessor = None + model = None + postprocessor = None + label_dict_numeric = None + data = None + original_data = None + test_data = None + results = None + dimensions = {"num_data_cols": 0, "num_label_cols": 0} + configs = { + "preprocessor": None, + "model": None, + "postprocessor": None} + + def __init__(self, classi_dir=None, **kwargs): + + if classi_dir is not None: + self._wdir_ = classi_dir + self._eval_file_ = os.path.join(self._wdir_, "labels", "evaluation.csv") + data, self.test_data, self.dimensions["num_data_cols"], self.dimensions["num_label_cols"] \ + , orig_image_dimensions, self.label_dict_numeric = data_from_csv(classi_dir) + self.data = {"data": data, + "num_data_cols": self.dimensions["num_data_cols"], + "num_label_cols": self.dimensions["num_label_cols"], + "orig_image_dimensions": orig_image_dimensions, + "label_dict_numeric": self.label_dict_numeric + } + self.original_data = deepcopy(self.data) + + self.configs["preprocessor"] = kwargs.pop("preprocessor_cfg", None) + self.configs["postprocessor"] = kwargs.pop("postprocessor_cfg", None) + self.configs["model"] = kwargs.pop("model_cfg", None) + + if not any([val is None for val in list(self.configs.values())]): + self.build_pipeline() + + pass + + def set_preprocessor(self, preprocessor_dict): + self.configs["preprocessor"] = preprocessor_dict + self.preprocessor = None + + def run_preprocessor(self): + self.preprocessor = PreProc(self.configs["preprocessor"]) + self.preprocessor.fit_and_apply(self.data) + + # subdir = os.path.join(self._wdir_, 'preprocessed') + # if not os.path.isdir(subdir): + # os.mkdir(subdir) + # self.preprocessor.save(os.path.join(subdir,os.path.splitext(os.path.basename(self.__data_definition__))[0])) + self.data = self.preprocessor.get_data() + self.dimensions["num_data_cols"] = self.data["num_data_cols"] + self.dimensions["num_label_cols"] = self.data["num_label_cols"] + + def set_model(self, model_dict): + self.configs["model"] = model_dict + self.model = None + + def set_postprocessor(self, postprocessor_dict): + self.configs["postprocessor"] = postprocessor_dict + self.postprocessor = None + + def build_pipeline(self): + + if self.configs["preprocessor"] is None: + raise NotImplementedError("run 'set_preprocessor' first!") + if self.configs["model"] is None: + raise NotImplementedError("run 'set_model' first!") + if self.configs["postprocessor"] is None: + raise NotImplementedError("run 'set_postprocessor' first!") + + if self.preprocessor is not None: + print("Warning: Overwriting preprocessor!") + if self.model is not None: + print("Warning: Overwriting model!") + if self.postprocessor is not None: + print("Warning: Overwriting postprocessor!") + + self.run_preprocessor() + t0 = time.time() + if len(self.configs["model"]["methods"]) > 1: + raise NotImplementedError("Currently only a single method is supported for models!") + print("Start fitting model '" + str(list(self.configs["model"]["methods"][0].keys())[0]) + "' on train data...") + self.make_model() + self.postprocessor = PostProc(self.configs["postprocessor"]) + tfit = time.time() + print( + "Fitted model '" + str(list(self.configs["model"]["methods"][0].keys())[0]) + "' in {:.3} s.".format( + tfit - t0)) + + def make_model(self): + self.model = Mod(self.configs["model"]) + self.model.set_data(self.data) + self.model.fit() + pass + + def predict(self, file_or_object, post_process=True): + mesu_dict = get_mesu_dict(file_or_object) + self.results = [] + for name in mesu_dict: + t0 = time.time() + print("Start classification on '" + name + "'...") + self._apply_data_ = mesu_dict[name].Data["cube"] + self.result = self.model.predict(self._apply_data_, self.preprocessor) + self.result["image_id"] = name + self.result["orig_shape"] = (self.data["orig_image_dimensions"][0], self.data["orig_image_dimensions"][1]) + self.result["meta"] = {} + self.result["meta"]["preprocessor"] = self.configs["preprocessor"] + self.result["meta"]["model"] = self.configs["model"] + if post_process: + t1 = time.time() + self.result["meta"]["postprocessor"] = self.configs["postprocessor"] + if len(self.configs["postprocessor"]["methods"]) > 1: + raise NotImplementedError("Currently only a single method is supported for postprocessors!") + print("Start postprocessing with '" + + str(list(self.configs["postprocessor"]["methods"][0].keys())[0]) + "' ...") + self.postprocessor.load_result(self.result) + self.postprocessor.apply() + self.result = self.postprocessor.get_final_result() + tpost = time.time() + print("Postprocessed with '" + str(list(self.configs["postprocessor"]["methods"][0].keys())[0]) + + "' in {:.3} s.".format(tpost - t1)) + tclass = time.time() + print("Classification in {:.3} s.".format(tclass - t0)) + self.results.append(self.result) + + # if visualize: + # self._visualize_(results, **kwargs) + + return self.results + + def _predict_test_(self): + self.results = [] + for loc_dict in self.test_data: + t0 = time.time() + print("Start classification on '" + loc_dict["name"] + "'...") + self._apply_data_ = loc_dict["cube"] + self.result = self.model.predict(self._apply_data_, self.preprocessor) + self.result["image_id"] = loc_dict["name"] + self.result["orig_shape"] = (self.data["orig_image_dimensions"][0], self.data["orig_image_dimensions"][1]) + self.result["meta"] = {} + self.result["meta"]["preprocessor"] = self.configs["preprocessor"] + self.result["meta"]["model"] = self.configs["model"] + + t1 = time.time() + self.result["meta"]["postprocessor"] = self.configs["postprocessor"] + if len(self.configs["postprocessor"]["methods"]) > 1: + raise NotImplementedError("Currently only a single method is supported for postprocessors!") + print("Start postprocessing with '" + + str(list(self.configs["postprocessor"]["methods"][0].keys())[0]) + "' ...") + self.postprocessor.load_result(self.result) + self.postprocessor.apply() + self.result = self.postprocessor.get_final_result() + tpost = time.time() + print("Postprocessed with '" + str(list(self.configs["postprocessor"]["methods"][0].keys())[0]) + + "' in {:.3} s.".format(tpost - t1)) + tclass = time.time() + print("Classification in {:.3} s.".format(tclass - t0)) + + self.results.append(self.result) + + return self.results + + def visualize(self, scale=2, alpha=0.25, save_path=None): + for res in self.results: + self.postprocessor.load_result(res) + self.postprocessor.load_measurement(self.postprocessor.image_id) + self.postprocessor.apply() + self.postprocessor.show(scale, alpha, save_path) + cv.waitKey(0) + + def visualizeLive(self, results, mesu, window, scale=2, alpha=0.25, save_path=None): + for res in results: + self.postprocessor.load_result(res) + self.postprocessor.load_measurement(mesu) + self.postprocessor.apply() + self.postprocessor.show(scale, alpha, window, save_path) + + def evaluate(self): + if self.test_data is not None: + test_results = self._predict_test_() + adjusted_results = self.postprocessor.visualize_and_adjust(test_results) + gof = goodness_of_fit(self.test_data, adjusted_results) + with open(self._eval_file_, "a") as f: + line = "Classificator evaluation: \n{}\n\n".format(datetime.datetime.now().astimezone()) + f.write(line) + line = "based on labeling at {}\n\n".format(self._wdir_) + f.write(line) + gof.to_csv(f, mode='a', line_terminator='\n', float_format="%.5f") + line = "\nWith configuration:\n\n" + f.write(line) + yaml.dump([el["meta"] for el in adjusted_results][0], f, sort_keys=False) + f.write("\n{}\n\n".format("".join(["-"] * 25))) + else: + warnings.WarningMessage("No test data found, goodness of fit cannot be calculated. \n Classificator " + "available 'as is'.") + + return + + def save(self, filename): + with open(os.path.join(self._wdir_, filename), 'wb') as handle: + self._wdir_ = None # due to DSGVO + self._apply_data_ = None # due to DSGVO + # clean up configuration dictionary + self.configs = json.loads(json.dumps(self.configs)) + # print("can I pickle? {}".format(dill.pickles(deepcopy(self)))) + # print("------------------------------") + # pd2xarray_walker(self) + # print("------------------------------") + # check_pickle(self) + dill.dump(self, handle, protocol=dill.HIGHEST_PROTOCOL, recurse=True, byref=True) + + def load(self, filename): + print("Loading Classificator state from '" + filename + "'") + with open(filename, 'rb') as handle: + loaded = dill.load(handle) + for attrib in dir(self): + if not attrib.startswith('_') and not callable(getattr(self, attrib)): + self.__setattr__(attrib, getattr(loaded, attrib)) + + if self.model is None: + self.make_model() + if len(self.preprocessor.preprocessor_states) == 0: + self.preprocessor = PreProc(self.configs["preprocessor"]) + self.preprocessor.fit_and_apply(self.original_data) + if self.postprocessor is None: + raise NotImplementedError("No alternative, when postprocessor is lost!") + print("Classificator loaded!") + pass + + +def check_pickle(obj): + if any([isinstance(obj, el) for _, el in inspect.getmembers(cuvis.classificator, inspect.isclass)]) or \ + isinstance(obj, cuvis.ImageData): + for attrib in dir(obj): + if not attrib.startswith('_') and not callable(getattr(obj, attrib)): + print("Checking {}.{}.{}!".format(obj.__class__.__module__, obj.__class__.__name__, attrib)) + try: + check_pickle(getattr(obj, attrib)) + except: + if not dill.pickles(getattr(obj, attrib), exact=True, safe=True): + print("Cannot pickle: {}".format(attrib)) + elif isinstance(obj, list): + for i in obj: + check_pickle(i) + elif isinstance(obj, dict): + for i in obj.values(): + check_pickle(i) + else: + print("Checking {}.{}!".format(obj.__class__.__module__, obj.__class__.__name__)) + if not dill.pickles(obj, exact=True, safe=True): + print("Cannot pickle: {}".format(obj)) + + +def pd2xarray_walker(obj): + if any([isinstance(obj, el) for _, el in inspect.getmembers(cuvis.classificator, inspect.isclass)]) or \ + isinstance(obj, cuvis.ImageData): + for attrib in dir(obj): + if not attrib.startswith('_') and not callable(getattr(obj, attrib)): + try: + print(attrib) + pd2xarray_walker(getattr(obj, attrib)) + except: + print(type(obj)) + if isinstance(obj, pd.DataFrame): + xobj = obj.to_xarray() + print(xobj) + elif isinstance(obj, list): + for i in obj: + pd2xarray_walker(i) + elif isinstance(obj, dict): + for i in obj.values(): + pd2xarray_walker(i) + else: + print(type(obj)) + if isinstance(obj, pd.DataFrame): + xobj = obj.to_xarray() + print(xobj) + pass + + +def xarray2pd_walker(obj): + pass diff --git a/Python/src/cuvis/classificator/indices.py b/Python/src/cuvis/classificator/indices.py new file mode 100644 index 0000000..bc7bd29 --- /dev/null +++ b/Python/src/cuvis/classificator/indices.py @@ -0,0 +1,85 @@ +import numpy as np + + +class base_index(object): + wavelengths = [] + num_wls = 0 + + def __init__(self): + pass + + def get_function(self): + def do_nothing(*args): + pass + + return do_nothing + + def __repr__(self): + return "{} based on wavelengths: {} nm.".format(self.__class__.__name__, self.wavelengths) + + +class simple_difference(base_index): + + def __init__(self): + super().__init__() + self.wavelengths = [2000, 0] + + def get_function(self): + self.num_wls = 2 + + def diff(wls): + return wls[0] - wls[1] + + return diff + + +class NDVI(base_index): + + def __init__(self): + super().__init__() + self.wavelengths = [800, 670] + + def get_function(self): + self.num_wls = 2 + + def ndvi(wls): + return (wls[0] - wls[1]) / (wls[0] + wls[1]) + + return ndvi + + +class hNDVI(base_index): + + def __init__(self): + super().__init__() + self.wavelengths = [827, 668] + + def get_function(self): + self.num_wls = 2 + + def hndvi(wls): + return (wls[0] - wls[1]) / (wls[0] + wls[1]) + + return hndvi + + +class simple_integral(base_index): + + def __init__(self): + super().__init__() + self.wavelengths = [500, 600] + self.resolution = 8 + start = np.min(self.wavelengths) + stop = np.max(self.wavelengths) + self.wavelengths = [start] + while self.wavelengths[-1] < stop: + self.wavelengths.append(self.wavelengths[-1] + self.resolution) + + def get_function(self): + self.num_wls = len(self.wavelengths) + + def integral(wls, res=self.resolution): + subints = np.convolve(wls, np.ones(2) / 2, mode='valid') * res + return np.sum(subints) + + return integral diff --git a/Python/src/cuvis/classificator/labelingGUI.py b/Python/src/cuvis/classificator/labelingGUI.py new file mode 100644 index 0000000..dc5c403 --- /dev/null +++ b/Python/src/cuvis/classificator/labelingGUI.py @@ -0,0 +1,664 @@ +import cuvis + +try: + from . import auxiliary as aux +except: + import auxiliary as aux + +import numpy as np +import cv2 as cv +import os +import pathlib + + +class LabelingGUI(object): + """ + a class allowing a user to generate labels for the cuvis classification workflow + + reads in .cu3 files and a list of labels to be applied + lets the user label the images via a brush or rect drawing gui + exports the labels as .png and generates cuvis_labels.csv + + """ + labels = [] + load_path = "" + label_index = 0 + image_index = 0 + input_images = [] + training_tags = [] + out_dir = "" + drawing = False # true if mouse is pressed + brush = True # if True, draw rectangle + current_label = "No Label" + colors = [] + scale = 2.0 + alpha = 0.3 + minimal_height = 400 + brush_size = 3 + ix, iy = -1, -1 + orig_shape = (0, 0) + border_left = border_top = border_bottom = 20 + border_right = 500 + img_show = None + img_show_bordered = None + layers = [] + current_layer = None + current_layer_bordered = None + dataframe = None + overwrite_enabled = False + show_color = True + + def load_images(self, load_path): + """ + loads images (cubes) from directory + + Looks for .cu3-files in load_path and appends them to the input_images list. Also creates test/training tag. + Exits when no files are found. + + Parameters + ---------- + load_path : string, required + folder path where .cu3-filey are + + Returns + ------- + + """ + print("\nSearching .cu3-files in " + load_path + "...") + self.load_path = load_path + for file in os.listdir(load_path): + filename = os.fsdecode(file) + if filename.endswith(".cu3"): # or filename.endswith(".cu3s"): + print("Found " + os.path.join(load_path, filename)) + self.input_images.append(filename) + self.training_tags.append(True) + continue + else: + continue + if len(self.input_images) == 0: + print("No Files where found. Exiting...") + exit() + pass + + def get_labels(self, labels_string): + """ + makes label list + + Generates a list of labels without spaces from the comma seperated labels_string. + Exits when no labels are present. + + Parameters + ---------- + labels_string : string, required + input string with comma seperated labels + Returns + ------- + + """ + labels_string = labels_string.replace(' ', '') + self.labels = labels_string.split(",") + if len(self.labels) == 0: + print("No labels given. Exiting...") + exit() + if len(self.labels) > 8: + print("Too many labels! Maximum is 8. Exiting...") + exit() + for label in self.labels: + if len(label) > 16: + print("Label '" + label + "' is too long. \n 16 char. max. \n Exiting...") + exit() + print("Following labels can be applied: ") + print(self.labels) + + for label_idx, label in enumerate(self.labels): + self.colors.append(aux.get_new_color(label_idx)) + + def adjust_brush(self, to_add): + """ + in-/decrease the brush size + + In-/Decrease the brush by the amount of to_add. + Lower Limit: 1 + Upper Limit: 15 + + Parameters + ---------- + to_add : int + amount by which the scale shall be increased + Returns + ------- + """ + self.brush_size = self.brush_size + to_add + if self.brush_size > 15: + self.brush_size = 15 + if self.brush_size < 1: + self.brush_size = 1 + + def adjust_scale(self, to_add): + """ + in-/decrease the scale of the image shown + + In-/Decrease the scale of the shown image by the amount of to_add. + Lower Limit: 1.0 + Upper Limit: 3.0 + + Parameters + ---------- + to_add : float + amount by which the scale shall be increased + Returns + ------- + + """ + self.scale = self.scale + to_add + if self.scale > 3.0: + self.scale = 3.0 + if self.scale < 1.0: + self.scale = 1.0 + # print("Scale adjusted: " + str(lg.scale)) + + def adjust_borders(self): + """ + adjusts the border_bottom so that the window shown matches the minimal_height + + Returns + -------+ + + """ + current_total_height = self.current_layer.shape[0] + self.border_bottom + self.border_top + if current_total_height < self.minimal_height: + self.border_bottom = (self.minimal_height - self.current_layer.shape[0] + self.border_top) + elif current_total_height >= self.minimal_height and self.border_bottom > self.border_top: + self.border_bottom = self.minimal_height - self.current_layer.shape[0] - self.border_top + if self.border_bottom < self.border_top: + self.border_bottom = self.border_top + + def adjust_alpha(self, to_add): + """ + + in-/decrease the alpha value of the label layer overlay + + In-/Decrease the alpha value of the label layer overlay by the amount of to_add. + Lower Limit: 0.1 + Upper Limit: 0.9 + + Parameters + ---------- + to_add: float + + Returns + ------- + + """ + self.alpha = self.alpha + to_add + if self.alpha > 0.9: + self.alpha = 0.9 + if self.alpha < 0.1: + self.alpha = 0.1 + # print("Alpha adjusted: " + str(lg.alpha)) + + def store_layer(self, image_index, label_index): + """ + + resets the scale to 1.0 and stores the current_layer at the right place in the layers list + + Parameters + ---------- + image_index : uint8, required + label_index : uint8, required + + Returns + ------- + + """ + + self.scale_images(1.0) + self.layers[image_index][label_index] = self.current_layer.copy() + + def finish(self): + """ + finishes the labeling process and saves the acquired labels accordingly + + Creates the out_dir in the same directory where the cu3-files were loaded. Checks if existing labels should be + overwritten. Saves the label layers as .png. Creates cuvis_labels.csv. + Returns + ------- + + """ + # todo: How to handle if one pixel has multiple labels? + self.out_dir = os.path.join(self.load_path, "labels") + self.dataframe = aux.DataLabel(os.path.join(self.out_dir, "{}_labels.csv".format("cuvis"))) + if not os.path.exists(self.out_dir): + os.mkdir(self.out_dir) + else: + while (1): + user_input = input("\nLabels already exist. Enter 'y' to overwrite labels or 'n' to exit: \n") + if user_input == 'y': + self.overwrite_enabled = True + break + elif user_input == 'n': + print("\nLabels used in " + self.out_dir) + print("\nExiting Labeling GUI...") + raise LabelingDone + + for image_idx, image in enumerate(self.input_images): + image_folder = os.path.join(self.out_dir, image) + if not os.path.exists(image_folder): + os.mkdir(image_folder) + new_Line = { + "File": image, + "Test": not self.training_tags[image_idx] # in the .csv the column is called "Test" + } + sum = 0 + for label_idx, label in enumerate(self.labels): + label_layer = aux.convert_to_binary(self.layers[image_idx][label_idx]) + sum = sum + np.sum(label_layer) + cv.imwrite(os.path.join(image_folder, label) + ".png", label_layer) + new_Line[label] = os.path.join(image, label) + ".png" + if sum == 0: + user_input = input("\n" + image + " has no labels. Will be excluded from further processing. OK? Enter" + " 'y' \n") + if user_input != 'y': + print("\n Continue Labeling. Label Data may be corrupted until saving is completed. ") + return None + else: + self.dataframe.add(new_Line) + + try: + self.dataframe.write(self.overwrite_enabled) + print("\nLabels saved to " + self.out_dir) + print("\nExiting Labeling GUI...") + except: + raise LabelingDone + raise LabelingDone + + def mark_test(self): + """ + + toggles between test/training for the currently shown image + + Returns + ------- + + """ + self.training_tags[self.image_index] = not self.training_tags[self.image_index] + + def undo_layer(self): + """ + + removes the currently shown label layer + + Returns + ------- + + """ + self.current_layer = np.zeros((self.orig_shape[0], self.orig_shape[1], 3), np.uint8) + self.store_layer(self.image_index, self.label_index) + + def handle_hotkeys(self): + """ + + handles the keyboard inputs and executes functions accordingly + + Returns + ------- + int + """ + k = cv.waitKeyEx(1) # & 0xFF + # print(k) + if k == ord('m'): + self.brush = not self.brush + if k == ord('+'): + self.adjust_scale(0.2) + if k == ord('-'): + self.adjust_scale(-0.2) + if k == ord('w'): + self.adjust_alpha(0.1) + if k == ord('q'): + self.adjust_alpha(-0.1) + if k == ord('c'): + self.store_layer(self.image_index, self.label_index) + self.show_color = not self.show_color + return -1 + if k == ord('f'): + self.store_layer(self.image_index, self.label_index) + user_input = input("\n Really Finishing? Enter 'y' \n") + if user_input == 'y': + self.finish() + if k == ord('u'): + self.undo_layer() + if k == ord('t'): + self.mark_test() + if k == ord('a'): + self.adjust_brush(-1) + if k == ord('s'): + self.adjust_brush(1) + if k == 2490368: # up + self.store_layer(self.image_index, self.label_index) + self.label_index = self.label_index + 1 + if self.label_index > (len(self.labels) - 1): + self.label_index = len(self.labels) - 1 + # print("Label Index : " + str(self.label_index)) + return -1 + if k == 2621440: # down + self.store_layer(self.image_index, self.label_index) + self.label_index = self.label_index - 1 + if self.label_index < 0: + self.label_index = 0 + # print("Label Index : " + str(self.label_index)) + return -1 + + if k == 2424832: # left + self.store_layer(self.image_index, self.label_index) + self.image_index = self.image_index - 1 + if self.image_index < 0: + self.image_index = 0 + # print("Image Index : " + str(self.image_index)) + return -1 + if k == 2555904: # right + self.store_layer(self.image_index, self.label_index) + self.image_index = self.image_index + 1 + if self.image_index > (len(self.input_images) - 1): + self.image_index = len(self.input_images) - 1 + # print("Image Index : " + str(self.image_index)) + return -1 + + elif k == 27: # Escape Key + user_input = input("\n Really Exiting? Enter 'y' \n") + if user_input == 'y': + print("Exiting...") + exit() + return -1 + + def next_label(self, index): + """ + + sets the label_index to the index provided + + Parameters + ---------- + index: int, required + + Returns + ------- + int + + """ + self.label_index = index + return self.label_index + + def next_image(self, index): + """ + sets the image_index to the index provided + + Parameters + ---------- + index: int, required + + Returns + ------- + int + """ + self.image_index = index + return self.image_index + + def init_layers(self): + """ + + opens all the .cu3 files in the directory and creates label layers for each image and label, which are appended + to layers (list of lists) + + Returns + ------- + + """ + if len(self.input_images) == 0: + print("Load images first! Exiting...") + exit() + if len(self.labels) == 0: + print("Load labels first! Exiting...") + exit() + for image in self.input_images: + image_path = os.path.join(self.load_path, self.input_images[self.image_index]) + print("Trying to open " + image_path + " ...") + mesu = cuvis.Measurement(image_path) + + img_layers = [] + for label in self.labels: + img_layers.append( + np.zeros((mesu.Data["cube"].array.shape[0], mesu.Data["cube"].array.shape[1], 3), np.uint8)) + self.layers.append(img_layers) + + def run(self): + """ + + this is where the magic happens + + Runs the labeling GUI in an endless loop, receives input from mouse and keyboard and generates visual output. + + Returns + ------- + + """ + self.init_layers() + try: + while (1): + label = self.labels[self.label_index] + image_path = os.path.join(self.load_path, self.input_images[self.image_index]) + # print("Trying to open " + image_path + " ...") + mesu = cuvis.Measurement(image_path) + self.img_show = aux.get_rgb_from_cu3(mesu) + if not self.show_color: + self.img_show = cv.cvtColor(self.img_show, cv.COLOR_BGR2GRAY) + self.img_show = cv.cvtColor(self.img_show, cv.COLOR_GRAY2BGR) + height, width, channels = self.img_show.shape # get shape of original image + self.orig_shape = (height, width) + self.img_show_bordered = cv.copyMakeBorder(self.img_show, self.border_left, self.border_bottom, + self.border_top, + self.border_right, cv.BORDER_CONSTANT, + value=[0, 0, 0]) # make bordered image to get writing space + self.current_layer = self.layers[self.image_index][self.label_index] + + cv.namedWindow('Cuvis Labeling Tool') + cv.setMouseCallback('Cuvis Labeling Tool', self.draw_shape) + while (1): + # cv.imshow('layer', self.current_layer) + self.scale_images(self.scale) + self.adjust_borders() + merged = cv.addWeighted( + self.img_show_bordered[self.border_top:self.border_top + self.current_layer.shape[0], + self.border_left:self.border_left + self.current_layer.shape[1]], (1 - self.alpha), + self.current_layer, self.alpha, + 0) # stack images + + self.img_show_bordered = cv.copyMakeBorder(merged, self.border_left, self.border_bottom, + self.border_top, self.border_right, cv.BORDER_CONSTANT, + value=[0, 0, 0]) # blow up label layer so it can be merged + self.draw_text() + cv.imshow('Cuvis Labeling Tool', self.img_show_bordered) + + if self.handle_hotkeys() == -1: + break; + + cv.destroyAllWindows() + + except LabelingDone: + cv.destroyAllWindows() + pass + + def draw_shape(self, event, x, y, flags, param): + """ + + OpenCV callback function that draws the labels onto the image shown + + The callback function for mouse events checks if the cursor is currently over the image to be labeled and then + draws either circles or rectangles onto the current_layer + + Parameters + ---------- + event: see cv2, required + x: int, required + y: int, required + flags: optional + param: optional + + Returns + ------- + + """ + + label_layer_bordered_height = self.current_layer_bordered.shape[0] + label_layer_bordered_width = self.current_layer_bordered.shape[1] + + if aux.check_in_boundary((x, y), (self.border_left, self.border_top), ( + label_layer_bordered_width - self.border_right, label_layer_bordered_height - self.border_bottom)): + if event == cv.EVENT_LBUTTONDOWN: + self.drawing = True + self.ix, self.iy = x, y + elif event == cv.EVENT_MOUSEMOVE: + if self.drawing == True: + if self.brush == False: + cv.rectangle(self.current_layer, (self.ix - self.border_left, self.iy - self.border_top), + (x - self.border_left, y - self.border_top), self.colors[self.label_index], -1) + else: + cv.circle(self.current_layer, (x - self.border_left, y - self.border_top), + int(self.brush_size * self.scale), self.colors[self.label_index], -1) + elif event == cv.EVENT_LBUTTONUP: + self.drawing = False + if self.brush == False: + + cv.rectangle(self.current_layer, (self.ix - self.border_left, self.iy - self.border_top), + (x - self.border_left, y - self.border_top), self.colors[self.label_index], -1) + else: + cv.circle(self.current_layer, (x - self.border_left, y - self.border_top), + int(self.brush_size * self.scale), self.colors[self.label_index], -1) + + def draw_text(self): + """ + + draws needed information as text onto the img_show_bordered + + Returns + ------- + + """ + label = self.labels[self.label_index] + line_spacing = 35 + column_spacing = 270 + start_y = self.border_top + start_x = self.img_show_bordered.shape[1] - self.border_right + 20 + + self.img_show_bordered = cv.putText(self.img_show_bordered, "Please label the class:", + (start_x, start_y + line_spacing), + cv.FONT_HERSHEY_SIMPLEX, + 0.5, (255, 255, 255), 1, + cv.LINE_AA) + self.img_show_bordered = cv.putText(self.img_show_bordered, label, (start_x, start_y + line_spacing * 3), + cv.FONT_HERSHEY_SIMPLEX, + 1.3, self.colors[self.label_index], 2, + cv.LINE_AA) + + text = "Label " + str(self.label_index + 1) + r"/" + str(len(self.labels)) + self.img_show_bordered = cv.putText(self.img_show_bordered, text, + (start_x, start_y + line_spacing * 4), + cv.FONT_HERSHEY_SIMPLEX, + 0.5, (255, 255, 255), 1, + cv.LINE_AA) + + color = (255, 0, 128) + if self.training_tags[self.image_index] == True: + text = "Marked as Training" + else: + text = "Marked as Test" + color = (128, 0, 255) + self.img_show_bordered = cv.putText(self.img_show_bordered, text, + (start_x + column_spacing, start_y + line_spacing * 2), + cv.FONT_HERSHEY_SIMPLEX, + 0.5, color, 1, + cv.LINE_AA) + + text = self.input_images[self.image_index] + print_length = 30 + if len(text) > print_length: + text = text[-print_length:] + text = ".." + text[-print_length - 2:] + self.img_show_bordered = cv.putText(self.img_show_bordered, text, + (start_x + column_spacing, start_y + line_spacing * 3), + cv.FONT_HERSHEY_SIMPLEX, + 0.4, (255, 255, 255), 1, + cv.LINE_AA) + + text = "Image " + str(self.image_index + 1) + r"/" + str(len(self.input_images)) + self.img_show_bordered = cv.putText(self.img_show_bordered, text, + (start_x + column_spacing, start_y + line_spacing * 4), + cv.FONT_HERSHEY_SIMPLEX, + 0.5, (255, 255, 255), 1, + cv.LINE_AA) + + instructions = [] + instructions.append("Hold the left mouse button down to label with the brush") + instructions.append("Press 'm' to toggle between brush and rect-labeling mode") + instructions.append("Press 'left' and 'right' arrow keys to go through images") + instructions.append("Press 'up' and 'down' arrow keys to go through labels") + instructions.append("Press 't' to mark image either as 'Training' or 'Test'") + instructions.append("Press 'u' to undo a label") + instructions.append("Press '+' and '-' keys to zoom") + instructions.append("Press 'q' and 'w' to adjust the alpha value of the labels (for visibility)") + instructions.append("Press 'a' and 's' to adjust the brush size") + instructions.append("Press 'c' to switch between b/w and color") + instructions.append("Press 'f' to finish the labeling") + instructions.append("Press 'Esc' to exit") + + line_spacing = 15 + start_y = self.img_show_bordered.shape[0] - 190 + + for i, instruction in enumerate(instructions): + self.img_show_bordered = cv.putText(self.img_show_bordered, instruction, + (start_x, start_y + line_spacing * i), + cv.FONT_HERSHEY_SIMPLEX, + 0.4, (255, 255, 255), 1, + cv.LINE_AA) + + def scale_images(self, new_scale): + """ + + scales img_show and current_layer according to the new_scale variable and adds fixed borders to the scaled images + to get the _bordered version of the image + + Parameters + ---------- + new_scale: int, required + + Returns + ------- + + """ + width_scaled = int(self.orig_shape[1] * new_scale) + height_scaled = int(self.orig_shape[0] * new_scale) + + self.img_show = cv.resize(self.img_show, (width_scaled, height_scaled)) + self.img_show_bordered = cv.copyMakeBorder(self.img_show, self.border_left, self.border_bottom, self.border_top, + self.border_right, cv.BORDER_CONSTANT, + value=[0, 0, 0]) # make borderd image to get writing space + self.current_layer = cv.resize(self.current_layer, (width_scaled, height_scaled)) + self.current_layer_bordered = cv.copyMakeBorder(self.current_layer, self.border_left, self.border_bottom, + self.border_top, self.border_right, + cv.BORDER_CONSTANT, + value=[0, 0, 0]) # blow up label layer so it can be merged + + +class LabelingDone(Exception): + pass + + +if __name__ == "__main__": + lg = LabelingGUI() + lg.load_images(input("This is the the Cuvis Labeling Tool. \nTo get started," + "please provide the path to the folder containing .cu3-files you want to label: ")) + # lg.load_images(r"C:\Users\robert.briegel\Documents\Cubert\2022_05_30\session_000") + + labels_string = input("\nPlease provide a comma seperated list of all labels you want to use." + "Example: 'background, apple, orange, pineapple' \nYour lables: ") + # labels_string = r"Fruits,Background, Wood, Plastic, Paper, Metal" + lg.get_labels(labels_string) + lg.run() diff --git a/Python/src/cuvis/classificator/model.py b/Python/src/cuvis/classificator/model.py new file mode 100644 index 0000000..8eb9ec9 --- /dev/null +++ b/Python/src/cuvis/classificator/model.py @@ -0,0 +1,62 @@ +import importlib +import os.path +import numpy as np +import pandas as pd +from sklearn.neighbors import KNeighborsClassifier, RadiusNeighborsClassifier +from copy import deepcopy +import time + +try: + from . import auxiliary as aux +except: + import auxiliary as aux + + +class Model(object): + settings = None + basic_data = None + model = None + method = None + + def __init__(self, settings): + self.settings = settings + pass + + def set_data(self, ppData): + if isinstance(ppData, dict): + self.basic_data = ppData # todo check all internals ("data", "num_label_cols", etc) + else: + raise NotImplementedError("Cannot interpret the given model data {}!".format(type(ppData))) + + def fit(self): + if len(self.settings["methods"]) > 1: + raise NotImplementedError("Currently only a single method is supported for models!") + meth = list(self.settings["methods"][0].keys()) + if len(meth) != 1: + raise NotImplementedError("fit only works with one single fit method, currently.") + self.method = meth[0] + + try: + mm_class = getattr(importlib.import_module('.modelclasses', package="cuvis.classificator"), self.method) + except: + raise NotImplementedError("Cannot interpret the given method {}!".format(self.method)) + + self.model = mm_class(self.settings["methods"][0][self.method]) + self.model.set_data(self.basic_data) + + def get_model(self): + return self.model + + def predict(self, data, preproc=None): + + if preproc is not None: + preproc.apply(data) + preprocessed = preproc.get_data() + t0 = time.time() + labeled_img = self.model.predict(preprocessed) + else: + t0 = time.time() + labeled_img = self.model.predict(data) + predtime = time.time() + print("Predicted with '" + self.method + "' in {:.3} s.".format(predtime - t0)) + return labeled_img diff --git a/Python/src/cuvis/classificator/modelclasses.py b/Python/src/cuvis/classificator/modelclasses.py new file mode 100644 index 0000000..701072a --- /dev/null +++ b/Python/src/cuvis/classificator/modelclasses.py @@ -0,0 +1,257 @@ +import numpy as np +from .auxiliary import convert_labels_binary_to_numeric +from sklearn.neighbors import KNeighborsClassifier +from sklearn.ensemble import RandomForestClassifier +import pandas as pd +import xarray +# from pandarallel import pandarallel +# from collections import OrderedDict +from copy import deepcopy + +from pprint import pprint + + +class BaseMethod(object): + settings = None + data = {} + __min_dict_requirements__ = [] + model = None + application_data = {} + + def __init__(self, settings=None): + if settings is None: + self.settings = {} + else: + self.settings = settings + assert self.__has_min_requirements__(list(settings.keys())), \ + "Some of the keys '{}' are missing.".format(", ".join(self.__min_dict_requirements__)) + + def __repr__(self): + return "{} called with {}".format(self.__class__.__name__, str(self.settings)) + + def __make_model__(self): + self.model = None + pass + + def predict(self, data): + return {"data": data} + + def set_data(self, data): + """ + makes data available to the model maker + + Parameters + __________ + data : pandas.DataFrame, required + the dataframe containing pixelwise data and label information. + """ + + self.data = data + self.__make_model__() + pass + + def __has_min_requirements__(self, testkeys): + """ + tests a list of keys to conforming to minimum requirements + + All keys in testkeys will be tested against the self.__min_dict_requirements__ definition. + + Parameters + __________ + testkeys : list, required + the keys that are tested against minimum requirements + + Returns + ------- + bool + a boolean if minimum requirements are met + """ + contain = all([key in testkeys for key in self.__min_dict_requirements__]) + return contain + + +class DIST(BaseMethod): + __min_dict_requirements__ = ["from"] + + def __make_model__(self): + data_obj = self.data["data"] + var_names = list(self.data["data"].variables.keys()) + var_names.remove("index") + labels_names = var_names[-self.data["num_label_cols"]:] + labels = self.data["data"][labels_names] + + subsets = {} + if self.settings["from"] == "mean": + for i, key in enumerate(labels): + subset = data_obj.sel(index=data_obj[key].values) + sub_mean = subset.mean() + subsets["{}".format(key)] = sub_mean.get(list(sub_mean.keys())[:self.data["num_data_cols"]]) + elif self.settings["from"] == "median": + for i, key in enumerate(labels): + subset = data_obj.sel(index=data_obj[key].values) + sub_median = subset.median() + subsets["{}".format(key)] = sub_median.get(list(sub_median.keys())[:self.data["num_data_cols"]]) + + else: + raise NotImplementedError("Cannot interpret the given method {}!".format(self.settings.keys())) + + label_functions = {} + + for key in labels: + def loc_fun(v1, val=subsets[key]): + return np.linalg.norm(v1.T - val.to_array().values, axis=1) + + label_functions[key] = loc_fun + + self.model = label_functions + + def predict(self, data): + application_data = data["data"] + #if data["num_label_cols"]: + # test_labels = data["data"].iloc[:, -data["num_label_cols"]:] + + res_labels = pd.DataFrame() + # pandarallel.initialize() + for key, val in self.model.items(): + intermediate = application_data.get(list(application_data.keys())[:data["num_data_cols"]]) + res_labels[key] = val(intermediate.to_array().values) + + + def min_max_scaling(array_like): + loc_data = np.asarray(array_like) + return 1 - (loc_data - np.nanmin(loc_data)) / (np.nanmax(loc_data) - np.nanmin(loc_data)) + + def binary(array_like): + loc_data = np.asarray(array_like) + return (loc_data == np.nanmax(loc_data)).astype(np.float) + + res_table = np.apply_along_axis(binary, 1, min_max_scaling(res_labels)) * min_max_scaling(res_labels) + + res_labels = pd.DataFrame(res_table, columns=res_labels.columns) + + labeled_img = {"labels": {}} + + for col in res_labels.columns: + labeled_img["labels"][col] = dict() + labeled_img["labels"][col]["probabilities"] = res_labels.loc[:, col].to_numpy() + + return labeled_img + + +class KNN(BaseMethod): + __min_dict_requirements__ = ["k", "weights", "algorithm", "n_jobs"] + + def __make_model__(self): + var_names = list(self.data["data"].variables.keys()) + var_names.remove("index") + labels_names = var_names[-self.data["num_label_cols"]:] + labels = self.data["data"][labels_names] + # label_dict = self.data["label_dict_numeric"] + labels_numeric, num_duplicate, num_no_label = convert_labels_binary_to_numeric(labels) + if num_duplicate > 0: + print(str(num_duplicate) + " pixels had more than one label assigned. Those are ignored.") + + data_names = var_names[:self.data["num_data_cols"]] + datapoints = self.data["data"][data_names] + + datapoints = datapoints.sel(index=datapoints["index"][labels_numeric != 0]) + + labels_numeric = labels_numeric[labels_numeric != 0] + k = self.settings["k"] + algo = self.settings["algorithm"] + j = self.settings["n_jobs"] + if self.settings["weights"] != "uniform" and self.settings["weights"] != "distance": + try: + knn = KNeighborsClassifier(n_neighbors=k, + weights=eval(self.settings["weights"]), + algorithm=algo, + n_jobs=j) + except: + raise IOError("Cannot interpret the given attribute {}!".format(self.settings["weights"])) + else: + knn = KNeighborsClassifier(n_neighbors=k, + weights=self.settings["weights"], + algorithm=algo, + n_jobs=j) + + # first is data, second is labels + knn.fit(datapoints.to_array().values.T.tolist(), labels_numeric.tolist()) + + self.model = knn + + def predict(self, data): + var_names = list(data["data"].variables.keys()) + var_names.remove("index") + data_names = var_names[:data["num_data_cols"]] + datapoints = data["data"][data_names] + knn = self.model + probs = knn.predict_proba(datapoints.to_array().values.T.tolist()) + # print(probs) + # print(probs.shape) + # labels=knn.predict(datapoints.values.tolist()) + + # labels_binary=aux.convert_labels_numeric_to_binary(labels,decData["label_dict_numeric"]) + labels_prob = deepcopy(data["label_dict_numeric"]) + for label, idx in labels_prob.items(): + labels_prob[label] = probs[:, idx - 1] + + labeled_img = {"labels": {}} + + for label, array in labels_prob.items(): + labeled_img["labels"][label] = dict() + labeled_img["labels"][label]["probabilities"] = array + + return labeled_img + + +class RndForrest(BaseMethod): + __min_dict_requirements__ = ["max_depth", "random_state", "n_jobs"] + + def __make_model__(self): + var_names = list(self.data["data"].variables.keys()) + var_names.remove("index") + labels_names = var_names[-self.data["num_label_cols"]:] + labels = self.data["data"][labels_names] + + label_dict = self.data["label_dict_numeric"] + labels_numeric, num_duplicate, num_no_label = convert_labels_binary_to_numeric(labels) + if num_duplicate > 0: + print(str(num_duplicate) + " pixels had more than one label assigned. Those are ignored.") + + data_names = var_names[:self.data["num_data_cols"]] + datapoints = self.data["data"][data_names] + datapoints = datapoints.sel(index=datapoints["index"][labels_numeric != 0]) + labels_numeric = labels_numeric[labels_numeric != 0] + maximum_depth = self.settings["max_depth"] + rnd_state = self.settings["random_state"] + j = self.settings["n_jobs"] + + clf = RandomForestClassifier(max_depth=maximum_depth, random_state=rnd_state, n_jobs=j) + # first is data, second is labels + clf.fit(datapoints.to_array().values.T.tolist(), labels_numeric.tolist()) + + self.model = clf + + def predict(self, data): + var_names = list(data["data"].variables.keys()) + var_names.remove("index") + data_names = var_names[:data["num_data_cols"]] + datapoints = data["data"][data_names] + clf = self.model + probs = clf.predict_proba(datapoints.to_array().values.T.tolist()) + # print(probs) + # print(probs.shape) + # labels=knn.predict(datapoints.values.tolist()) + + # labels_binary=aux.convert_labels_numeric_to_binary(labels,decData["label_dict_numeric"]) + labels_prob = deepcopy(data["label_dict_numeric"]) + for label, idx in labels_prob.items(): + labels_prob[label] = probs[:, idx - 1] + + labeled_img = {"labels": {}} + + for label, array in labels_prob.items(): + labeled_img["labels"][label] = dict() + labeled_img["labels"][label]["probabilities"] = array + + return labeled_img diff --git a/Python/src/cuvis/classificator/postprocessor.py b/Python/src/cuvis/classificator/postprocessor.py new file mode 100644 index 0000000..5fb838f --- /dev/null +++ b/Python/src/cuvis/classificator/postprocessor.py @@ -0,0 +1,559 @@ +import cuvis + +try: + from . import auxiliary as aux +except: + import auxiliary as aux + +import numpy as np +import cv2 as cv +import os +import pprint +import time +from copy import deepcopy + + +class Postprocessor(object): + img_raw = None + img_show = None + img_bordered = None + image_id = "No ID!" + methods = None + labels = dict() + meta = dict() + definity_default = 0.1 + definity = definity_default + threshold_default = 0.8 + threshold = threshold_default + + dilate_size_default = 0 + dilate_size = dilate_size_default + dilate_size_max = 21 + dilate_it_default = 1 + dilate_it = dilate_it_default + dilate_it_max = 5 + + erode_size_default1 = 0 + erode_size1 = erode_size_default1 + erode_size_max1 = 21 + erode_it_default1 = 1 + erode_it1 = erode_it_default1 + erode_it_max1 = 5 + + erode_size_default2 = 0 + erode_size2 = erode_size_default2 + erode_size_max2 = 21 + erode_it_default2 = 1 + erode_it2 = erode_it_default2 + erode_it_max2 = 5 + + scale = 2.0 + alpha = 0.3 + minimal_height = 550 + orig_shape = (0, 0) + border_left = border_top = border_bottom = 20 + border_right = 500 + show_color = True + + def __init__(self, specification_dict): + + self.methods = deepcopy(specification_dict).pop("methods", None) + if self.methods is None: + raise IOError("No methods defined in specification keys:\n{}".format(specification_dict.keys())) + if len(self.methods) > 1: + raise NotImplementedError("Currently only only a single method is supported for postprocessors!") + if "Base" not in self.methods[0].keys(): + raise NotImplementedError("Currently only 'Base' method is supported!") + + for key in specification_dict["methods"][0]["Base"].keys(): + if key == "alpha": + self.alpha = specification_dict["methods"][0]["Base"][key] + elif key == "threshold": + self.threshold = specification_dict["methods"][0]["Base"][key] + elif key == "definity": + self.definity = specification_dict["methods"][0]["Base"][key] + elif key == "erode1": + self.erode_size1 = specification_dict["methods"][0]["Base"][key] + elif key == "dilate": + self.dilate_size = specification_dict["methods"][0]["Base"][key] + elif key == "erode2": + self.erode_size2 = specification_dict["methods"][0]["Base"][key] + else: + print("Postprocessor could not set '" + str(key) + "'. Ignored.") + + def create_window(self): + cv.namedWindow('Classification Results') + cv.createTrackbar("Alpha ", 'Classification Results', int(self.alpha * 100), 100, self.handle_alpha_trackbar) + cv.createTrackbar("Thresh ", 'Classification Results', int(self.threshold * 100), 100, + self.handle_thresh_trackbar) + cv.createTrackbar("Definity ", 'Classification Results', int(self.definity * 100), 100, + self.handle_definity_trackbar) + cv.createTrackbar("Erode 1", 'Classification Results', self.erode_size1, self.erode_size_max1, + self.handle_erode_size1_trackbar) + cv.createTrackbar("Dilate ", 'Classification Results', self.dilate_size, self.dilate_size_max, + self.handle_dilate_size_trackbar) + cv.createTrackbar("Erode 2", 'Classification Results', self.erode_size2, self.erode_size_max2, + self.handle_erode_size2_trackbar) + + def create_window_stripped(self): + if cv.getWindowProperty('Classification Results', cv.WND_PROP_VISIBLE) > 0: + cv.destroyAllWindows() + cv.namedWindow('Classification Results') + + def draw_text(self): + """ + + draws needed information as text onto the img_show_bordered + + Returns + ------- + + """ + start_x = self.img_bordered.shape[1] - self.border_right + 20 + start_y = self.border_top + 20 + + self.img_bordered = cv.putText(self.img_bordered, "Measurement: ", + (start_x, start_y), + cv.FONT_HERSHEY_SIMPLEX, + 0.6, (255, 255, 255), 1, + cv.LINE_AA) + + print_name = self.image_id + print_length = 30 + if len(print_name) > print_length: + print_name = print_name[-print_length:] + print_name = ".." + print_name[-print_length - 2:] + self.img_bordered = cv.putText(self.img_bordered, print_name, + (start_x, start_y + 30), + cv.FONT_HERSHEY_SIMPLEX, + 0.8, (255, 255, 255), 2, + cv.LINE_AA) + + start_y = start_y + 80 + + for idx, key in enumerate(self.labels.keys()): + start_labels_y = start_y + idx * 40 + start_labels_x = start_x + if idx > 3: + start_labels_y = start_y + (idx - 4) * 40 + start_labels_x = start_x + 240 + self.img_bordered = cv.putText(self.img_bordered, key, + (start_labels_x, start_labels_y), + cv.FONT_HERSHEY_SIMPLEX, + 0.8, aux.get_new_color(idx), 2, + cv.LINE_AA) + + start_y = self.img_bordered.shape[0] - 200 + + instructions = [] + instructions.append("Adjust sliders for best outcome:") + instructions.append(" ") + instructions.append("Alpha: Alpha value of the overlay") + instructions.append("Thresh: Threshold of minimum probability value") + instructions.append("Definity: Threshold of minimum distance to another label") + instructions.append("Erosion, then Dilation -> Opening. Reduces noise") + instructions.append("Dilation, then Erosion -> Closing. Fills holes") + instructions.append("Press '+' and '-' keys to zoom") + instructions.append("Press 'c' to switch between b/w and color") + instructions.append("Press 'm' to print meta data into console") + instructions.append("Press '<-' and '->' to go through images") + instructions.append("Press 'f' to save current state.") + instructions.append("Press 'Esc' or click top right 'X' exit.") + # todo: add number of visualizable files + + line_spacing = 15 + + for i, instruction in enumerate(instructions): + self.img_bordered = cv.putText(self.img_bordered, instruction, + (start_x, start_y + line_spacing * i), + cv.FONT_HERSHEY_SIMPLEX, + 0.4, (255, 255, 255), 1, + cv.LINE_AA) + + def show(self, scale=2, alpha=0.25,window=None, save_path=None): + + if window is None: + cv.destroyAllWindows() + window=self.image_id[-80:] + elif cv.getWindowProperty(window, cv.WND_PROP_VISIBLE) < 1: + cv.namedWindow(window) + self.scale = scale + self.alpha = alpha + # self.create_window_stripped() + self.make_img_show() + self.scale_img_show() + cv.imshow(window, self.img_show) + cv.waitKey(1) + if save_path is not None: + cv.imwrite(os.path.join(save_path, self.image_id[-20:]) + "_classify.png", self.img_show) + pass + + def visualize_and_adjust(self, results): + + idx = 0 + size = len(results) + + self.load_result(results[idx]) + self.load_measurement(self.image_id) + if self.img_raw is None: + raise IOError("Load measurement first!") + self.create_window() + while 1: + self.apply() + self.make_img_show() + self.scale_and_border() + self.draw_text() + cv.imshow('Classification Results', self.img_bordered) + ret = self.handle_hotkeys(30) + if ret == 3: # finalize + cv.destroyAllWindows() + adjusted_results = [] + for res in results: + self.load_result(res) + self.apply() + adjusted = self.get_final_result() + adjusted_results.append(adjusted) + return adjusted_results + if ret == -1: # abort + cv.destroyAllWindows() + print("Abort. Nothing is going to be saved/returned.") + return None + if ret == 1: # right arrow + idx = idx + 1 + if idx == size: + idx = size - 1 + self.load_result(results[idx]) + self.load_measurement(self.image_id) + self.create_window() + if ret == 2: # left arrow + idx = idx - 1 + if idx == -1: + idx = 0 + self.load_result(results[idx]) + self.load_measurement(self.image_id) + self.create_window() + + def make_img_show(self): + + self.img_show = self.img_raw.copy() + if not self.show_color: + self.img_show = cv.cvtColor(self.img_show, cv.COLOR_BGR2GRAY) + self.img_show = cv.cvtColor(self.img_show, cv.COLOR_GRAY2BGR) + merged_color_labels = np.zeros((self.img_show.shape[0], self.img_show.shape[1], 3), np.uint8) + equal_fraction = 1.0 / len(self.labels.keys()) + for idx, key in enumerate(self.labels.keys()): + color_label = cv.cvtColor(self.labels[key]["mask"], cv.COLOR_GRAY2BGR) + color_label[np.where((color_label > [0, 0, 0]).all(axis=2))] = [aux.get_new_color(idx)] + # color_label=color_label.astype(np.float32) + # merged_color_labels= merged_color_labels + color_label #* equal_fraction* + merged_color_labels = cv.addWeighted(merged_color_labels, 1, color_label, 1, 0) + merged_color_labels = merged_color_labels.astype(np.uint8) + # merged_color_labels = cv.normalize(merged_color_labels, merged_color_labels, 0, 255, cv.NORM_MINMAX) + self.img_show = cv.addWeighted(self.img_show, (1 - self.alpha), merged_color_labels, self.alpha, 0) + + def apply(self): + + # 255 is unspecified + # 0 is label 0, 1 is label 1 and so on + highest_probability_labels_arr = 255 * np.ones(self.orig_shape, np.uint8) + # array where every value is the threshold + highest_probability_arr = self.threshold * np.ones(self.orig_shape, np.float32) + for idx, key in enumerate(self.labels.keys()): + morphed_probs = self.labels[key]["probabilities"] + morphed_probs = self.apply_erosion(key, morphed_probs, 1) + morphed_probs = self.apply_dilation(key, morphed_probs) + morphed_probs = self.apply_erosion(key, morphed_probs, 2) + + diff = morphed_probs - highest_probability_arr + # everything is true that is bigger + mask_better = diff > 0 + # everything is true that is different enough + mask_definity = np.absolute(diff) > self.definity + + # remove the previous values that very the highest and replace them + highest_probability_arr = highest_probability_arr - (highest_probability_arr * mask_better) + ( + morphed_probs * mask_better) + + # remove the current labels with the highes probs and replace them + highest_probability_labels_arr = highest_probability_labels_arr - ( + highest_probability_labels_arr * mask_better * mask_definity) + ( + idx * mask_better * mask_definity) + + # remove labels where previous label was not much different to better label + highest_probability_labels_arr = highest_probability_labels_arr - ( + highest_probability_labels_arr * np.invert(mask_definity)) + (255 * np.invert(mask_definity)) + + for idx, key in enumerate(self.labels.keys()): + is_key_mask = highest_probability_labels_arr == idx + binary = np.ones(self.orig_shape, np.uint8) + binary = binary * is_key_mask + # cv.imshow(str(label),binary) + self.labels[key]["mask"] = binary + # self.apply_dilation(key) + # self.apply_erosion(key) + + pass + + def get_final_result(self): + + final_result = { + "image_id": self.image_id, + "labels": self.labels, + "orig_shape": self.orig_shape, + "meta": self.meta + } + final_result["meta"]["postprocessor"] = {"methods": {"Base": {"alpha": self.alpha, + "threshold": self.threshold, + "definity": self.definity, + "erode1": self.erode_size1, + "dilate": self.dilate_size, + "erode2": self.erode_size2, + }}} + + return final_result + + def handle_thresh_trackbar(self, val): + self.threshold = val * 0.01 + pass + + def handle_definity_trackbar(self, val): + self.definity = val * 0.01 + + pass + + def handle_alpha_trackbar(self, val): + self.alpha = val * 0.01 + pass + + def handle_erode_size1_trackbar(self, val): + self.erode_size1 = val + pass + + def handle_erode_size2_trackbar(self, val): + self.erode_size2 = val + + pass + + def handle_dilate_size_trackbar(self, val): + self.dilate_size = val + + pass + + def adjust_scale(self, to_add): + """ + in-/decrease the scale of the image shown + + In-/Decrease the scale of the shown image by the amount of to_add. + Lower Limit: 1.0 + Upper Limit: 3.0 + + Parameters + ---------- + to_add : float + amount by which the scale shall be increased + Returns + ------- + + """ + self.scale = self.scale + to_add + if self.scale > 3.0: + self.scale = 3.0 + if self.scale < 1.0: + self.scale = 1.0 + # print("Scale adjusted: " + str(lg.scale)) + + def scale_and_border(self): + """ + + scales img_show according to the scale variable and adds fixed borders to the scaled image + to get the _bordered version of the image + + Returns + ------- + + """ + + self.scale_img_show() + self.adjust_borders() + self.img_bordered = cv.copyMakeBorder(self.img_show, self.border_left, self.border_bottom, + self.border_top, self.border_right, cv.BORDER_CONSTANT, + value=[0, 0, 0]) # blow up label layer so it can be merged + + def scale_img_show(self): + + width_scaled = int(self.img_raw.shape[1] * self.scale) + height_scaled = int(self.img_raw.shape[0] * self.scale) + self.img_show = cv.resize(self.img_show, (width_scaled, height_scaled)) + + def adjust_borders(self): + """ + adjusts the border_bottom so that the window shown matches the minimal_height + + Returns + ------- + + """ + current_total_height = self.img_show.shape[0] + self.border_bottom + self.border_top + if current_total_height < self.minimal_height: + self.border_bottom = (self.minimal_height - self.img_show.shape[0] + self.border_top) + elif current_total_height >= self.minimal_height and self.border_bottom > self.border_top: + self.border_bottom = self.minimal_height - self.img_show.shape[0] - self.border_top + if self.border_bottom < self.border_top: + self.border_bottom = self.border_top + + def handle_hotkeys(self, wait_time=0): + """ + + handles the keyboard inputs and executes functions accordingly + + Returns + ------- + int + """ + k = cv.waitKeyEx(wait_time) # & 0xFF + #print(k) + if k == 27: # Escape Key + # user_input = input("\n Really Exiting? Enter 'y' \n") + # if user_input == 'y': + # print("Exiting...") + # exit() + return -1 + if k == ord('c'): + self.show_color = not self.show_color + return 0 + if k == ord('+'): + self.adjust_scale(0.2) # + return 0 + if k == ord('m'): + printer = pprint.PrettyPrinter(depth=24) + print("\n Meta data for classification results with ID '" + self.image_id + "' :") + printer.pprint(self.meta) + return 0 + if k == ord('-'): + self.adjust_scale(-0.2) + return 0 + if k == 2424832: # left + return 2 + if k == 2555904: # right + return 1 + if k == ord('f'): + return 3 + if cv.getWindowProperty('Classification Results', cv.WND_PROP_VISIBLE) < 1: + self.create_window() + return -1 + else: + return 0 + + def apply_dilation(self, label, input_img): + if self.dilate_size < 3: + return input_img + kernel = np.ones((self.dilate_size, self.dilate_size), np.uint8) + return cv.dilate(input_img, kernel, iterations=self.dilate_it) + + def apply_erosion(self, label, input_img, nr=1): + if nr == 1: + if self.erode_size1 < 3: + return input_img + else: + kernel = np.ones((self.erode_size1, + self.erode_size1), np.uint8) + return cv.erode(input_img, kernel, iterations=self.erode_it1) + if nr == 2: + if self.erode_size2 < 3: + return input_img + else: + kernel = np.ones((self.erode_size2, + self.erode_size2), np.uint8) + return cv.erode(input_img, kernel, iterations=self.erode_it2) + + def load_measurement(self, mesu): + measurement = None + if isinstance(mesu, cuvis.Measurement): + measurement = mesu + elif isinstance(mesu, str): + if os.path.isfile(mesu): + measurement = cuvis.Measurement(mesu) + else: + raise IOError("load_measurement: unknown type") + self.img_raw = aux.get_rgb_from_cu3(measurement) + + def load_result(self, classification_result): + if cv.getWindowProperty('Classification Results', cv.WND_PROP_VISIBLE) > 0: + cv.destroyAllWindows() + self.labels = {} + self.image_id = classification_result["image_id"] + + self.orig_shape = classification_result["orig_shape"] + + try: + self.meta = classification_result["meta"] + except: + self.meta = {} + for key in classification_result["labels"].keys(): + self.labels[key] = {} + self.labels[key]["probabilities"] = classification_result["labels"][key]["probabilities"].reshape( + self.orig_shape) + self.labels[key]["mask"] = np.zeros((self.orig_shape[0], self.orig_shape[1], 3), np.uint8) + + +if __name__ == "__main__": + + binarized = [] + binarized.append(cv.imread(r"C:\Users\robert.briegel\Documents\Cubert\2022_06_29\session_000\labels" + r"\session_000_015_snapshot.cu3\Fruits.png")) + binarized.append(cv.imread(r"C:\Users\robert.briegel\Documents\Cubert\2022_06_29\session_000\labels" + r"\session_000_015_snapshot.cu3\Background.png")) + binarized.append(cv.imread(r"C:\Users\robert.briegel\Documents\Cubert\2022_06_29\session_000\labels" + r"\session_000_015_snapshot.cu3\Wood.png")) + binarized.append(cv.imread(r"C:\Users\robert.briegel\Documents\Cubert\2022_06_29\session_000\labels" + r"\session_000_015_snapshot.cu3\Plastic.png")) + binarized.append(cv.imread(r"C:\Users\robert.briegel\Documents\Cubert\2022_06_29\session_000\labels" + r"\session_000_015_snapshot.cu3\Paper.png")) + binarized.append(cv.imread(r"C:\Users\robert.briegel\Documents\Cubert\2022_06_29\session_000\labels" + r"\session_000_015_snapshot.cu3\Metal.png")) + + pseudo_labels = { + "Fruits": {"probabilities": binarized[0]}, + "Background": {"probabilities": binarized[1]}, + "Wood": {"probabilities": binarized[2]}, + "Plastic": {"probabilities": binarized[3]}, + "Paper": {"probabilities": binarized[4]}, + "Metal": {"probabilities": binarized[5]} + } + + for key in pseudo_labels.keys(): + pseudo_labels[key]["probabilities"] = pseudo_labels[key]["probabilities"].astype(np.float32) + # scale it so it will 1.0 + pseudo_labels[key]["probabilities"] /= 255. + pseudo_labels[key]["probabilities"] = cv.cvtColor(pseudo_labels[key]["probabilities"], cv.COLOR_BGR2GRAY) + + labeled_img_data = { + "image_id": r"C:\Users\robert.briegel\Documents\Cubert\2022_06_29\session_000\session_000_015_snapshot.cu3", + "labels": pseudo_labels, + "meta": { + "preproc_config": { + "methods": { + "SUBSET": { + "wavelengths": [450, 531, 623, 751, 834, 1011], + "choice": "closest" + }, + "PCA": { + "explained_variance": 0.9995 + }, + }, + }, + } + } + + pp = Postprocessor() + + while (1): + t1 = time.time() + pp.load_result(labeled_img_data) + pp.load_measurement_from_file(pp.image_id) + pp.make_img_show(30) + final_result = pp.get_final_result() + # print(final_result) + t2 = time.time() + + # print(t2-t1) diff --git a/Python/src/cuvis/classificator/preprocclasses.py b/Python/src/cuvis/classificator/preprocclasses.py new file mode 100644 index 0000000..11cb36e --- /dev/null +++ b/Python/src/cuvis/classificator/preprocclasses.py @@ -0,0 +1,265 @@ +import importlib + +import numpy as np +import xarray +from sklearn.decomposition import PCA as PCA_skl +from sklearn.preprocessing import MinMaxScaler +from cv2 import PCACompute2 as PCA_cv +# from tensorflow_transform import pca as PCA_tf + +from pprint import pprint + + +# todo add some kind of "prototype extractor" e.g. via K-means +# https://docs.rapidminer.com/latest/studio/operators/modeling/segmentation/extract_prototypes.html +# with this we should have multiple prototypes per class to check e.g. knn against +# this should be faster, because it has less neighbours to compare to, but better than "distance" +# because we dont just take the median. + +class BaseMethod(object): + settings = None + data = xarray.Dataset() + masks = xarray.Dataset() + __min_dict_requirements__ = [] + internal_state = None + + def __init__(self, settings=None): + if settings is None: + self.settings = {} + else: + self.settings = settings + assert self.__has_min_requirements__(list(settings.keys())), \ + "Some of the keys '{}' are missing.".format(", ".join(self.__min_dict_requirements__)) + + def __repr__(self): + return "{} called with {}".format(self.__class__.__name__, str(self.settings)) + + def set_data(self, data, num_data_cols=None): + """ + makes data available to the preprocessor + + Splits data into actual data and mask data based on num_data_cols (number of actual data columns). + + Parameters + __________ + data : pandas.DataFrame, required + the dataframe containing pixelwise data and label information. + num_data_cols : int, optional + the number of columns at the beginning of the data frame to cut data with. + If None, all provided data is assumed to be actual data. + """ + if num_data_cols is not None: + keys = list(data.keys()) + data_keys = keys[:num_data_cols] + mask_keys = keys[num_data_cols:] + self.data = data[data_keys] + self.masks = data[mask_keys] + else: + self.data = data + self.masks = xarray.Dataset() + pass + + def fit(self): + self.internal_state = "do nothing" + pass + + def set_state(self, state): + self.internal_state = state + pass + + def apply(self): + return xarray.merge([self.data, self.masks], compat='no_conflicts'), len(self.data.variables) - 1 + + def __has_min_requirements__(self, testkeys): + """ + tests a list of keys to conforming to minimum requirements + + All keys in testkeys will be tested against the self.__min_dict_requirements__ definition. + + Parameters + __________ + testkeys : list, required + the keys that are tested against minimum requirements + + Returns + ------- + bool + a boolean if minimum requirements are met + """ + contain = all([key in testkeys for key in self.__min_dict_requirements__]) + return contain + + +class PCA(BaseMethod): + __min_dict_requirements__ = ["number_of_componenents"] + + def __init__(self, settings=None): + super().__init__(settings) + + def fit(self): + num_comp = self.settings["number_of_componenents"] + this_pca = PCA_skl(n_components=num_comp, svd_solver="full") + this_pca.fit(self.data.to_array().to_numpy().T) + print("Using {} components with an explained variance of ~{:.5f}.".format( + num_comp, np.cumsum(this_pca.explained_variance_ratio_)[num_comp - 1])) + self.internal_state = this_pca + + def apply(self): + if self.internal_state is None: + raise Exception("PCA not configured for application.") + components = self.internal_state.transform(self.data.to_array().to_numpy().T) + num_comp = self.settings["number_of_componenents"] + self.data = self.data.to_array()[:num_comp, :].copy(data=components.T).to_dataset(dim="variable") + renamed = {} + [renamed.update({key: "loading_PC{}".format(num)}) for key, num in zip(self.data.keys(), range(num_comp))] + self.data = self.data.rename(renamed) + return xarray.merge([self.data, self.masks], compat='no_conflicts'), len(self.data.variables) - 1 + + +class NORM(BaseMethod): + __min_dict_requirements__ = ["direction"] + + def __init__(self, settings=None): + super().__init__(settings) + + def apply(self): + # print(self.data.loc[[2]]) #this prints the unnormed data + if self.settings["direction"] == "Channel": + data_arr = self.data.to_array().to_numpy() # returns a numpy array + min_max_scaler = MinMaxScaler() + x_scaled = min_max_scaler.fit_transform(data_arr) + self.data = self.data.to_array().copy(data=x_scaled).to_dataset(dim="variable") + elif self.settings["direction"] == "Brightness": + data_arr = self.data.to_array().to_numpy() # returns a numpy array + min_max_scaler = MinMaxScaler() + x_scaled = min_max_scaler.fit_transform(data_arr.T) + self.data = self.data.to_array().copy(data=x_scaled.T).to_dataset(dim="variable") + else: + raise NotImplementedError("Direction {} not defined!".format(self.settings["direction"])) + # print(self.data.loc[[2]]) #this prints the normed data + return xarray.merge([self.data, self.masks], compat='no_conflicts'), len(self.data.variables) - 1 + + +def closest_hlp(mywl, wl_list): + diff = [np.abs(mywl - wl_el) for wl_el in wl_list] + myind = diff.index(np.min(diff)) + return wl_list[myind] + + +def closest_hlp_old(mywl, wl_list): + diff = [np.abs(mywl - wl_el) for wl_el in wl_list] + check = [False] * len(wl_list) + myind = diff.index(np.min(diff)) + check[myind] = True + return check + + +def exact_hlp(mywl, wl_list): + if mywl in wl_list: + return mywl + else: + return None + + +def exact_hlp_old(mywl, wl_list): + check = [mywl == wl_el for wl_el in wl_list] + return check + + +class SUBSET(BaseMethod): + __min_dict_requirements__ = ["wavelengths", "choice"] + + def __init__(self, settings=None): + super().__init__(settings) + + def fit(self): + self.internal_state = self.settings + pass + + def apply(self): + data_wls = list(self.data.variables.keys()) + data_wls.remove("index") + data_wls_int = [int(el.strip("nm")) for el in data_wls] + + settings_ch = self.internal_state["choice"] + + subset_cases = {"closest": closest_hlp, + "exact": exact_hlp} + + try: + subset_fun = subset_cases[settings_ch] + except: + raise NotImplementedError("subset choice '{}' not defined.".format(settings_ch)) + + list_of_used_wls = [] + for wl in self.internal_state["wavelengths"]: + list_of_used_wls.append(subset_fun(wl, data_wls_int)) + + variable_name_subset = [] + for ind, el in enumerate(data_wls): + if data_wls_int[ind] in list_of_used_wls: + variable_name_subset.append(el) + + if len(variable_name_subset) != len(self.internal_state["wavelengths"]): + print("Not all wavelengths could be found. Used '{}' only.".format(", ".join(variable_name_subset))) + else: + print("Used wavelengths: {}.".format(", ".join(variable_name_subset))) + + self.data = self.data[variable_name_subset] + + return xarray.merge([self.data, self.masks], compat='no_conflicts'), len(self.data.variables) - 1 + + +class INDICES(BaseMethod): + __min_dict_requirements__ = ["indices", "choice"] + + def __init__(self, settings=None): + super().__init__(settings) + + def fit(self): + self.internal_state = self.settings + pass + + def apply(self): + + indices = [] + + for ind in self.internal_state["indices"]: + index_def = getattr(importlib.import_module('.indices', package="cuvis.classificator"), ind)() + print("Using index: {}".format(index_def)) + + data_wls = list(self.data.variables.keys()) + data_wls.remove("index") + data_wls_int = [int(el.strip("nm")) for el in data_wls] + + settings_ch = self.internal_state["choice"] + + subset_cases = {"closest": closest_hlp, + "exact": exact_hlp} + + try: + subset_fun = subset_cases[settings_ch] + except: + raise NotImplementedError("subset choice '{}' not defined.".format(settings_ch)) + + list_of_used_wls = [] + for wl in index_def.wavelengths: + list_of_used_wls.append("{} nm".format(subset_fun(wl, data_wls_int))) + + if len(list_of_used_wls) != len(index_def.wavelengths) or "None nm" in list_of_used_wls: + raise IOError("Not all wavelengths could be found.") + else: + print("Used wavelengths: {}.".format(", ".join(np.unique(list_of_used_wls)))) + + subset = self.data[list_of_used_wls].astype(float) + subset = subset.to_array().values + index = np.apply_along_axis(index_def.get_function(), 0, subset) + + indices.append(index) + indices = np.array(indices) + self.data = self.data.to_array()[:len(indices), :].copy(data=indices).to_dataset(dim="variable") + renamed = {} + [renamed.update({key: self.settings["indices"][num]}) for key, num in zip(self.data.keys(), range(len(indices)))] + self.data = self.data.rename(renamed) + + return xarray.merge([self.data, self.masks], compat='no_conflicts'), len(self.data.variables) - 1 diff --git a/Python/src/cuvis/classificator/preprocessor.py b/Python/src/cuvis/classificator/preprocessor.py new file mode 100644 index 0000000..a2e6625 --- /dev/null +++ b/Python/src/cuvis/classificator/preprocessor.py @@ -0,0 +1,175 @@ +import importlib +import os.path + +import xarray + +import cuvis + +import pandas as pd +from .auxiliary import DataLabel, data_from_csv +from copy import deepcopy +import numpy as np +import time + + +class Preprocessor(object): + """ + the preprocessor class of the classificator module + + The Preprocessor class is initialized with a stp by step definition of the used preprocessors. + The Preprocessor class can apply the defined preprocessors to the available data + + Attributes + ---------- + methods : dict + the dictionary the preprocessor is initialized with + method_names : list + the names of the methods defined in the dict + num_data_cols : int + the number of columns that are designated for data + num_label_cols : int + the number of columns that are designated for masks + data : pandas.DataFrame + the data frame designated for training/inference + + + Methods + ------- + apply(interface_file) + applies the defined preprocessors based on the interface file (from auxiliary.DataLabel) + save(base_filename) + saves a csv for the applied data (pandas.DataFrame) + """ + methods = {} + method_names = [] + num_data_cols = 0 + num_label_cols = 0 + orig_image_dimensions = [0, 0, 0] + data = xarray.Dataset() + preprocessor_states = [] + label_dict_numeric = {} + + # todo: Should we make labels unique? i.e. can a pixel have multiple labels? + + def __init__(self, specification_dict): + """ + initialization + + Basic initialization with specification dictionary. + + Parameters + __________ + specification_dict : dict, required + dictionary containing the preprocessor options (see preprocclasses.py) + """ + self.methods = deepcopy(specification_dict).pop("methods", None) + + if self.methods is None: + raise IOError("No methods defined in specification keys:\n{}".format(specification_dict.keys())) + else: + self.method_names = [list(dct.keys())[0] for dct in self.methods] + pass + + def fit_and_apply(self, data): + """ + applies the defined preprocessors based on the interface file (from auxiliary.DataLabel) + + Basic initialization with file name. + + Parameters + __________ + interface_file : str, required + file specification for a DataLabel readable file that defines the interface from the labeling GUI + + Returns + ------- + dictionary of data and test_data + """ + + self.data = data["data"] + self.num_data_cols = data["num_data_cols"] + self.num_label_cols = data["num_label_cols"] + self.orig_image_dimensions = data["orig_image_dimensions"] + self.label_dict_numeric = data["label_dict_numeric"] + self._apply_preprocessors_() + return + + def apply(self, data): + """ + applies the defined preprocessors based on the interface file (from auxiliary.DataLabel) + + Basic initialization with file name. + + Parameters + __________ + interface_file : str, required + file specification for a DataLabel readable file that defines the interface from the labeling GUI + + Returns + ------- + dictionary of data and test_data + """ + + wls = ["{} nm".format(dwl) for dwl in data.wavelength] + data = np.reshape(data.array, (np.prod(data.array.shape[:-1]), data.array.shape[-1])) + data = pd.DataFrame(data, columns=wls).to_xarray() + self.data = data + self._apply_preprocessors_(refit=False) + return + + def _apply_preprocessors_(self, refit=True): + """ + applies the defined preprocessors in order of the specification + + Wrapper function for the different preprocessors. + Changes the data and testing_data in place. + """ + + for ind, meth in enumerate(self.method_names): + t0 = time.time() + pp_class = getattr(importlib.import_module('.preprocclasses', package="cuvis.classificator"), meth) + loc_pp = pp_class(self.methods[ind][meth]) + loc_pp.set_data(self.data, num_data_cols=self.num_data_cols) + if refit: + print("Start fitting preprocessing step '" + pp_class.__name__ + "' on train data...") + loc_pp.fit() + self.preprocessor_states.append(loc_pp.internal_state) + else: + loc_pp.set_state(self.preprocessor_states[ind]) + loc_pp.set_data(self.data) + print("Start preprocessing step '" + pp_class.__name__ + "' ...") + self.data, num_data_cols = loc_pp.apply() + #if len(self.test_data.columns): + # loc_pp.set_data(self.test_data, num_data_cols=self.num_data_cols) + # print("Start preprocessing step '" + pp_class.__name__ + "' on test data...") + # self.test_data, num_data_cols_test = loc_pp.apply() + + # # check data length + # assert num_data_cols == num_data_cols_test, "Something went wrong, test_data and data are of different " \ + # "column length. " + pp_time = time.time() + print("Preprocessed with '" + pp_class.__name__ + "' in {:.3} s.".format(pp_time - t0)) + self.num_data_cols = num_data_cols + pass + + def save(self, base_filename): + """ + saves a csv for the applied data (pandas.DataFrame) + + Basic initialization with file name. + + Parameters + __________ + base_filename : str, required + file specification for a file to be read by the classification algorithm (simple pandas.Dataframe by pixel) + """ + self.data.to_csv(base_filename + "_data.csv") + pass + + def get_data(self): + return {"data": self.data, + "num_data_cols": self.num_data_cols, + "num_label_cols": self.num_label_cols, + "orig_image_dimensions": self.orig_image_dimensions, + "label_dict_numeric": self.label_dict_numeric + } # dimensions of the orig input image eg. (275x290) diff --git a/Python/src/cuvis/cuvis_aux.py b/Python/src/cuvis/cuvis_aux.py new file mode 100644 index 0000000..6ec8f9c --- /dev/null +++ b/Python/src/cuvis/cuvis_aux.py @@ -0,0 +1,61 @@ +import inspect +import logging + +from . import cuvis_il +from .cuvis_types import CUVIS_capabilities + + +def __fn_bits__(n): + flaglist = [] + while n: + b = n & (~n + 1) + flaglist.append(b) + n ^= b + return flaglist + + +def __bit_translate__(n): + flags = __fn_bits__(n) + return [key for key, vald in CUVIS_capabilities.items() + if vald in flags] + + +def __object_declassifier__(obj): + res = dict() + all_att = inspect.getmembers(obj, lambda att: not (inspect.isroutine(att))) + [res.update({val[0]: val[1]}) for val in all_att if + not (val[0].startswith('__') and val[0].endswith('__'))] + return res + + +class SDKException(Exception): + + def __init__(self, *args): + if len(args) == 0: + message = cuvis_il.cuvis_get_last_error_msg() + else: + message = args + logging.exception(message) + pass + + +class SessionData(object): + def __init__(self, name, sessionNumber, sequenceNumber): + self.Name = name + self.SessionNumber = sessionNumber + self.SequenceNumber = sequenceNumber + + def __repr__(self): + return "'Session: {}; no. {}, seq. {}'".format(self.Name, self.SessionNumber, self.SequenceNumber) + + +class GPSData(object): + def __init__(self): + self.longitude = None + self.latitude = None + self.altitude = None + self.time = None + + def __repr__(self): + return "'GPS: lon./lat.: {} / {}; alt. {}, time {}'".format(self.longitude, self.latitude, self.altitude, + self.time) diff --git a/Python/src/cuvis/cuvis_il.py b/Python/src/cuvis/cuvis_il.py new file mode 100644 index 0000000..e24bb2f --- /dev/null +++ b/Python/src/cuvis/cuvis_il.py @@ -0,0 +1,1095 @@ +# This file was automatically generated by SWIG (http://www.swig.org). +# Version 4.0.2 +# +# Do not make changes to this file unless you know what you are doing--modify +# the SWIG interface file instead. + +from sys import version_info as _swig_python_version_info +if _swig_python_version_info < (2, 7, 0): + raise RuntimeError("Python 2.7 or later required") + +# Import the low-level C/C++ module +if __package__ or "." in __name__: + from . import _cuvis_pyil +else: + import _cuvis_pyil + +try: + import builtins as __builtin__ +except ImportError: + import __builtin__ + +def _swig_repr(self): + try: + strthis = "proxy of " + self.this.__repr__() + except __builtin__.Exception: + strthis = "" + return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) + + +def _swig_setattr_nondynamic_instance_variable(set): + def set_instance_attr(self, name, value): + if name == "thisown": + self.this.own(value) + elif name == "this": + set(self, name, value) + elif hasattr(self, name) and isinstance(getattr(type(self), name), property): + set(self, name, value) + else: + raise AttributeError("You cannot add instance attributes to %s" % self) + return set_instance_attr + + +def _swig_setattr_nondynamic_class_variable(set): + def set_class_attr(cls, name, value): + if hasattr(cls, name) and not isinstance(getattr(cls, name), property): + set(cls, name, value) + else: + raise AttributeError("You cannot add class attributes to %s" % cls) + return set_class_attr + + +def _swig_add_metaclass(metaclass): + """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" + def wrapper(cls): + return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) + return wrapper + + +class _SwigNonDynamicMeta(type): + """Meta class to enforce nondynamic attributes (no new attributes) for a class""" + __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) + + + +def cuvis_version_swig(): + return _cuvis_pyil.cuvis_version_swig() + +def cuvis_measurement_get_data_info_swig(i_mesu, o_pType, i_id): + return _cuvis_pyil.cuvis_measurement_get_data_info_swig(i_mesu, o_pType, i_id) + +def cuvis_measurement_get_data_string_swig(i_mesu, i_key): + return _cuvis_pyil.cuvis_measurement_get_data_string_swig(i_mesu, i_key) + +def new_p_int(): + return _cuvis_pyil.new_p_int() + +def copy_p_int(value): + return _cuvis_pyil.copy_p_int(value) + +def delete_p_int(obj): + return _cuvis_pyil.delete_p_int(obj) + +def p_int_assign(obj, value): + return _cuvis_pyil.p_int_assign(obj, value) + +def p_int_value(obj): + return _cuvis_pyil.p_int_value(obj) + +def new_p_double(): + return _cuvis_pyil.new_p_double() + +def copy_p_double(value): + return _cuvis_pyil.copy_p_double(value) + +def delete_p_double(obj): + return _cuvis_pyil.delete_p_double(obj) + +def p_double_assign(obj, value): + return _cuvis_pyil.p_double_assign(obj, value) + +def p_double_value(obj): + return _cuvis_pyil.p_double_value(obj) + +def new_p_unsigned_char(nelements): + return _cuvis_pyil.new_p_unsigned_char(nelements) + +def delete_p_unsigned_char(ary): + return _cuvis_pyil.delete_p_unsigned_char(ary) + +def p_unsigned_char_getitem(ary, index): + return _cuvis_pyil.p_unsigned_char_getitem(ary, index) + +def p_unsigned_char_setitem(ary, index, value): + return _cuvis_pyil.p_unsigned_char_setitem(ary, index, value) + +def new_p_unsigned_int(nelements): + return _cuvis_pyil.new_p_unsigned_int(nelements) + +def delete_p_unsigned_int(ary): + return _cuvis_pyil.delete_p_unsigned_int(ary) + +def p_unsigned_int_getitem(ary, index): + return _cuvis_pyil.p_unsigned_int_getitem(ary, index) + +def p_unsigned_int_setitem(ary, index, value): + return _cuvis_pyil.p_unsigned_int_setitem(ary, index, value) + +def cuvis_read_imbuf_uint8(imbuf): + return _cuvis_pyil.cuvis_read_imbuf_uint8(imbuf) + +def cuvis_read_imbuf_uint16(imbuf): + return _cuvis_pyil.cuvis_read_imbuf_uint16(imbuf) + +def cuvis_read_imbuf_uint32(imbuf): + return _cuvis_pyil.cuvis_read_imbuf_uint32(imbuf) + +def cuvis_read_imbuf_float32(imbuf): + return _cuvis_pyil.cuvis_read_imbuf_float32(imbuf) +CUVIS_MAXBUF = _cuvis_pyil.CUVIS_MAXBUF +CUVIS_MODE_CAPABILITY_ACQUISITION_CAPTURE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_CAPTURE +CUVIS_MODE_CAPABILITY_ACQUISITION_TIMELAPSE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_TIMELAPSE +CUVIS_MODE_CAPABILITY_ACQUISITION_CONTINUOUS = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_CONTINUOUS +CUVIS_MODE_CAPABILITY_ACQUISITION_SNAPSHOT = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_SNAPSHOT +CUVIS_MODE_CAPABILITY_ACQUISITION_SETINTEGRATIONTIME = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_SETINTEGRATIONTIME +CUVIS_MODE_CAPABILITY_ACQUISITION_SETGAIN = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_SETGAIN +CUVIS_MODE_CAPABILITY_ACQUISITION_AVERAGING = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_AVERAGING +CUVIS_MODE_CAPABILITY_PROCESSING_SENSOR_RAW = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SENSOR_RAW +CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_RAW = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_RAW +CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_REF = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_REF +CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_DARKSUBTRACT = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_DARKSUBTRACT +CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_FLATFIELDING = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_FLATFIELDING +CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_SPECTRALRADIANCE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_SPECTRALRADIANCE +CUVIS_MODE_CAPABILITY_PROCESSING_SAVE_FILE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SAVE_FILE +CUVIS_MODE_CAPABILITY_PROCESSING_CLEAR_RAW = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CLEAR_RAW +CUVIS_MODE_CAPABILITY_PROCESSING_CALC_LIVE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CALC_LIVE +CUVIS_MODE_CAPABILITY_PROCESSING_AUTOEXPOSURE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_AUTOEXPOSURE +CUVIS_MODE_CAPABILITY_PROCESSING_ORIENTATION = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_ORIENTATION +CUVIS_MODE_CAPABILITY_PROCESSING_SET_WHITE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_WHITE +CUVIS_MODE_CAPABILITY_PROCESSING_SET_DARK = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DARK +CUVIS_MODE_CAPABILITY_PROCESSING_SET_SPRADCALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_SPRADCALIB +CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCECALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCECALIB +CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCE_VALUE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCE_VALUE +CUVIS_MODE_CAPABILITY_PROCESSING_USE_DARK_SPRADCALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_USE_DARK_SPRADCALIB +CUVIS_MODE_CAPABILITY_PROCESSING_USE_WHITE_SPRADCALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_USE_WHITE_SPRADCALIB +CUVIS_MODE_CAPABILITY_PROCESSING_REQUIRE_WHITEDARK_REFLECTANCE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_REQUIRE_WHITEDARK_REFLECTANCE +AcquisitionCapture = _cuvis_pyil.AcquisitionCapture +AcquisitionTimelapse = _cuvis_pyil.AcquisitionTimelapse +AcquisitionContinuous = _cuvis_pyil.AcquisitionContinuous +AcquisitionSnapshot = _cuvis_pyil.AcquisitionSnapshot +AcquisitionSetIntegrationtime = _cuvis_pyil.AcquisitionSetIntegrationtime +AcquisitionSetGain = _cuvis_pyil.AcquisitionSetGain +AcquisitionAveraging = _cuvis_pyil.AcquisitionAveraging +ProcessingSensorRaw = _cuvis_pyil.ProcessingSensorRaw +ProcessingCubeRaw = _cuvis_pyil.ProcessingCubeRaw +ProcessingCubeRef = _cuvis_pyil.ProcessingCubeRef +ProcessingCubeDarkSubtract = _cuvis_pyil.ProcessingCubeDarkSubtract +ProcessingCubeFlatFielding = _cuvis_pyil.ProcessingCubeFlatFielding +ProcessingCubeSpectralRadiance = _cuvis_pyil.ProcessingCubeSpectralRadiance +ProcessingSaveFile = _cuvis_pyil.ProcessingSaveFile +ProcessingClearRaw = _cuvis_pyil.ProcessingClearRaw +ProcessingCalcLive = _cuvis_pyil.ProcessingCalcLive +ProcessingAutoExposure = _cuvis_pyil.ProcessingAutoExposure +ProcessingOrientation = _cuvis_pyil.ProcessingOrientation +ProcessingSetWhite = _cuvis_pyil.ProcessingSetWhite +ProcessingSetDark = _cuvis_pyil.ProcessingSetDark +ProcessingSetSprad = _cuvis_pyil.ProcessingSetSprad +ProcessingSetDistanceCalib = _cuvis_pyil.ProcessingSetDistanceCalib +ProcessingSetDistanceValue = _cuvis_pyil.ProcessingSetDistanceValue +ProcessingUseDarkSpradcalib = _cuvis_pyil.ProcessingUseDarkSpradcalib +ProcessingUseWhiteSpradCalib = _cuvis_pyil.ProcessingUseWhiteSpradCalib +ProcessingRequireWhiteDarkReflectance = _cuvis_pyil.ProcessingRequireWhiteDarkReflectance +CUVIS_MESU_FLAG_OVERILLUMINATED = _cuvis_pyil.CUVIS_MESU_FLAG_OVERILLUMINATED +CUVIS_MESU_FLAG_POOR_REFERENCE = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_REFERENCE +CUVIS_MESU_FLAG_POOR_WHITE_BALANCING = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_WHITE_BALANCING +CUVIS_MESU_FLAG_DARK_INTTIME = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_INTTIME +CUVIS_MESU_FLAG_DARK_TEMP = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_TEMP +CUVIS_MESU_FLAG_WHITE_INTTIME = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_INTTIME +CUVIS_MESU_FLAG_WHITE_TEMP = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_TEMP +CUVIS_MESU_FLAG_WHITEDARK_INTTIME = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_INTTIME +CUVIS_MESU_FLAG_WHITEDARK_TEMP = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_TEMP +CUVIS_MESU_CUBE_KEY = _cuvis_pyil.CUVIS_MESU_CUBE_KEY +CUVIS_MESU_PAN_KEY = _cuvis_pyil.CUVIS_MESU_PAN_KEY +CUVIS_MESU_GPS_KEY = _cuvis_pyil.CUVIS_MESU_GPS_KEY +CUVIS_MESU_PREVIEW_KEY = _cuvis_pyil.CUVIS_MESU_PREVIEW_KEY +CUVIS_MESU_DARKREF_KEY = _cuvis_pyil.CUVIS_MESU_DARKREF_KEY +CUVIS_MESU_WHITEREF_KEY = _cuvis_pyil.CUVIS_MESU_WHITEREF_KEY +CUVIS_MESU_WHITEDARKREF_KEY = _cuvis_pyil.CUVIS_MESU_WHITEDARKREF_KEY +CUVIS_MESU_FLAG_OVERILLUMINATED_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_OVERILLUMINATED_KEY +CUVIS_MESU_FLAG_POOR_REFERENCE_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_REFERENCE_KEY +CUVIS_MESU_FLAG_POOR_WHITE_BALANCING_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_WHITE_BALANCING_KEY +CUVIS_MESU_FLAG_DARK_INTTIME_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_INTTIME_KEY +CUVIS_MESU_FLAG_DARK_TEMP_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_TEMP_KEY +CUVIS_MESU_FLAG_WHITE_INTTIME_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_INTTIME_KEY +CUVIS_MESU_FLAG_WHITE_TEMP_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_TEMP_KEY +CUVIS_MESU_FLAG_WHITEDARK_INTTIME_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_INTTIME_KEY +CUVIS_MESU_FLAG_WHITEDARK_TEMP_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_TEMP_KEY +CUVIS_MESU_CUBE_INFO_KEY = _cuvis_pyil.CUVIS_MESU_CUBE_INFO_KEY +CUVIS_MESU_PAN_INFO_KEY = _cuvis_pyil.CUVIS_MESU_PAN_INFO_KEY +CUVIS_MESU_INFO_OK = _cuvis_pyil.CUVIS_MESU_INFO_OK +CUVIS_MESU_INFO_OVERILLUMINATED = _cuvis_pyil.CUVIS_MESU_INFO_OVERILLUMINATED +CUVIS_MESU_INFO_BAD_PIXEL = _cuvis_pyil.CUVIS_MESU_INFO_BAD_PIXEL +CUVIS_MESU_INFO_OVERILLUMINATED_REFERENCE = _cuvis_pyil.CUVIS_MESU_INFO_OVERILLUMINATED_REFERENCE +CUVIS_MESU_INFO_UNDERFLOW_MEASUREMENT_MIN_DARK = _cuvis_pyil.CUVIS_MESU_INFO_UNDERFLOW_MEASUREMENT_MIN_DARK +CUVIS_MESU_INFO_UNDERFLOW_WHITE_MIN_DARK = _cuvis_pyil.CUVIS_MESU_INFO_UNDERFLOW_WHITE_MIN_DARK +CUVIS_MESU_INFO_REFERENCE_CALC_OVERFLOW = _cuvis_pyil.CUVIS_MESU_INFO_REFERENCE_CALC_OVERFLOW +CUVIS_MESU_INFO_INCOMPLETE = _cuvis_pyil.CUVIS_MESU_INFO_INCOMPLETE +status_ok = _cuvis_pyil.status_ok +status_error = _cuvis_pyil.status_error +status_deferred = _cuvis_pyil.status_deferred +status_overwritten = _cuvis_pyil.status_overwritten +status_timeout = _cuvis_pyil.status_timeout +status_no_measurement = _cuvis_pyil.status_no_measurement +status_not_available = _cuvis_pyil.status_not_available +status_not_processed = _cuvis_pyil.status_not_processed +status_not_stored = _cuvis_pyil.status_not_stored +status_no_view = _cuvis_pyil.status_no_view +hardware_state_offline = _cuvis_pyil.hardware_state_offline +hardware_state_partially_online = _cuvis_pyil.hardware_state_partially_online +hardware_state_online = _cuvis_pyil.hardware_state_online +loglevel_fatal = _cuvis_pyil.loglevel_fatal +loglevel_error = _cuvis_pyil.loglevel_error +loglevel_warning = _cuvis_pyil.loglevel_warning +loglevel_info = _cuvis_pyil.loglevel_info +loglevel_debug = _cuvis_pyil.loglevel_debug +imbuffer_format_uint8 = _cuvis_pyil.imbuffer_format_uint8 +imbuffer_format_uint16 = _cuvis_pyil.imbuffer_format_uint16 +imbuffer_format_uint32 = _cuvis_pyil.imbuffer_format_uint32 +imbuffer_format_float = _cuvis_pyil.imbuffer_format_float +data_type_unsupported = _cuvis_pyil.data_type_unsupported +data_type_image = _cuvis_pyil.data_type_image +data_type_gps = _cuvis_pyil.data_type_gps +data_type_string = _cuvis_pyil.data_type_string +data_type_sensor_info = _cuvis_pyil.data_type_sensor_info +Cube_Raw = _cuvis_pyil.Cube_Raw +Cube_DarkSubtract = _cuvis_pyil.Cube_DarkSubtract +Cube_Reflectance = _cuvis_pyil.Cube_Reflectance +Cube_SpectralRadiance = _cuvis_pyil.Cube_SpectralRadiance +Preview = _cuvis_pyil.Preview +Reference_Dark = _cuvis_pyil.Reference_Dark +Reference_White = _cuvis_pyil.Reference_White +Reference_WhiteDark = _cuvis_pyil.Reference_WhiteDark +Reference_SpRad = _cuvis_pyil.Reference_SpRad +Reference_Distance = _cuvis_pyil.Reference_Distance +OperationMode_Software = _cuvis_pyil.OperationMode_Software +OperationMode_Internal = _cuvis_pyil.OperationMode_Internal +OperationMode_External = _cuvis_pyil.OperationMode_External +OperationMode_Undefined = _cuvis_pyil.OperationMode_Undefined +pan_sharpening_interpolation_type_NearestNeighbor = _cuvis_pyil.pan_sharpening_interpolation_type_NearestNeighbor +pan_sharpening_interpolation_type_Linear = _cuvis_pyil.pan_sharpening_interpolation_type_Linear +pan_sharpening_interpolation_type_Cubic = _cuvis_pyil.pan_sharpening_interpolation_type_Cubic +pan_sharpening_interpolation_type_Lanczos = _cuvis_pyil.pan_sharpening_interpolation_type_Lanczos +pan_sharpening_algorithm_Noop = _cuvis_pyil.pan_sharpening_algorithm_Noop +pan_sharpening_algorithm_CubertMacroPixel = _cuvis_pyil.pan_sharpening_algorithm_CubertMacroPixel +pan_sharpening_algorithm_CubertPanRatio = _cuvis_pyil.pan_sharpening_algorithm_CubertPanRatio +tiff_compression_mode_None = _cuvis_pyil.tiff_compression_mode_None +tiff_compression_mode_LZW = _cuvis_pyil.tiff_compression_mode_LZW +tiff_format_Single = _cuvis_pyil.tiff_format_Single +tiff_format_MultiChannel = _cuvis_pyil.tiff_format_MultiChannel +tiff_format_MultiPage = _cuvis_pyil.tiff_format_MultiPage +view_category_image = _cuvis_pyil.view_category_image +view_category_data = _cuvis_pyil.view_category_data +component_type_image_sensor = _cuvis_pyil.component_type_image_sensor +component_type_misc_sensor = _cuvis_pyil.component_type_misc_sensor +class cuvis_imbuffer_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + raw = property(_cuvis_pyil.cuvis_imbuffer_t_raw_get, _cuvis_pyil.cuvis_imbuffer_t_raw_set) + bytes = property(_cuvis_pyil.cuvis_imbuffer_t_bytes_get, _cuvis_pyil.cuvis_imbuffer_t_bytes_set) + length = property(_cuvis_pyil.cuvis_imbuffer_t_length_get, _cuvis_pyil.cuvis_imbuffer_t_length_set) + width = property(_cuvis_pyil.cuvis_imbuffer_t_width_get, _cuvis_pyil.cuvis_imbuffer_t_width_set) + height = property(_cuvis_pyil.cuvis_imbuffer_t_height_get, _cuvis_pyil.cuvis_imbuffer_t_height_set) + channels = property(_cuvis_pyil.cuvis_imbuffer_t_channels_get, _cuvis_pyil.cuvis_imbuffer_t_channels_set) + format = property(_cuvis_pyil.cuvis_imbuffer_t_format_get, _cuvis_pyil.cuvis_imbuffer_t_format_set) + wavelength = property(_cuvis_pyil.cuvis_imbuffer_t_wavelength_get, _cuvis_pyil.cuvis_imbuffer_t_wavelength_set) + + def __init__(self): + _cuvis_pyil.cuvis_imbuffer_t_swiginit(self, _cuvis_pyil.new_cuvis_imbuffer_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_imbuffer_t + +# Register cuvis_imbuffer_t in _cuvis_pyil: +_cuvis_pyil.cuvis_imbuffer_t_swigregister(cuvis_imbuffer_t) + +class cuvis_sensor_info_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + averages = property(_cuvis_pyil.cuvis_sensor_info_t_averages_get, _cuvis_pyil.cuvis_sensor_info_t_averages_set) + temperature = property(_cuvis_pyil.cuvis_sensor_info_t_temperature_get, _cuvis_pyil.cuvis_sensor_info_t_temperature_set) + gain = property(_cuvis_pyil.cuvis_sensor_info_t_gain_get, _cuvis_pyil.cuvis_sensor_info_t_gain_set) + readout_time = property(_cuvis_pyil.cuvis_sensor_info_t_readout_time_get, _cuvis_pyil.cuvis_sensor_info_t_readout_time_set) + + def __init__(self): + _cuvis_pyil.cuvis_sensor_info_t_swiginit(self, _cuvis_pyil.new_cuvis_sensor_info_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_sensor_info_t + +# Register cuvis_sensor_info_t in _cuvis_pyil: +_cuvis_pyil.cuvis_sensor_info_t_swigregister(cuvis_sensor_info_t) + +class cuvis_gps_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + longitude = property(_cuvis_pyil.cuvis_gps_t_longitude_get, _cuvis_pyil.cuvis_gps_t_longitude_set) + latitude = property(_cuvis_pyil.cuvis_gps_t_latitude_get, _cuvis_pyil.cuvis_gps_t_latitude_set) + altitude = property(_cuvis_pyil.cuvis_gps_t_altitude_get, _cuvis_pyil.cuvis_gps_t_altitude_set) + time = property(_cuvis_pyil.cuvis_gps_t_time_get, _cuvis_pyil.cuvis_gps_t_time_set) + + def __init__(self): + _cuvis_pyil.cuvis_gps_t_swiginit(self, _cuvis_pyil.new_cuvis_gps_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_gps_t + +# Register cuvis_gps_t in _cuvis_pyil: +_cuvis_pyil.cuvis_gps_t_swigregister(cuvis_gps_t) + +class cuvis_session_info_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + name = property(_cuvis_pyil.cuvis_session_info_t_name_get, _cuvis_pyil.cuvis_session_info_t_name_set) + session_no = property(_cuvis_pyil.cuvis_session_info_t_session_no_get, _cuvis_pyil.cuvis_session_info_t_session_no_set) + sequence_no = property(_cuvis_pyil.cuvis_session_info_t_sequence_no_get, _cuvis_pyil.cuvis_session_info_t_sequence_no_set) + + def __init__(self): + _cuvis_pyil.cuvis_session_info_t_swiginit(self, _cuvis_pyil.new_cuvis_session_info_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_session_info_t + +# Register cuvis_session_info_t in _cuvis_pyil: +_cuvis_pyil.cuvis_session_info_t_swigregister(cuvis_session_info_t) + +class cuvis_mesu_metadata_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + name = property(_cuvis_pyil.cuvis_mesu_metadata_t_name_get, _cuvis_pyil.cuvis_mesu_metadata_t_name_set) + path = property(_cuvis_pyil.cuvis_mesu_metadata_t_path_get, _cuvis_pyil.cuvis_mesu_metadata_t_path_set) + comment = property(_cuvis_pyil.cuvis_mesu_metadata_t_comment_get, _cuvis_pyil.cuvis_mesu_metadata_t_comment_set) + capture_time = property(_cuvis_pyil.cuvis_mesu_metadata_t_capture_time_get, _cuvis_pyil.cuvis_mesu_metadata_t_capture_time_set) + factory_calibration = property(_cuvis_pyil.cuvis_mesu_metadata_t_factory_calibration_get, _cuvis_pyil.cuvis_mesu_metadata_t_factory_calibration_set) + product_name = property(_cuvis_pyil.cuvis_mesu_metadata_t_product_name_get, _cuvis_pyil.cuvis_mesu_metadata_t_product_name_set) + serial_number = property(_cuvis_pyil.cuvis_mesu_metadata_t_serial_number_get, _cuvis_pyil.cuvis_mesu_metadata_t_serial_number_set) + assembly = property(_cuvis_pyil.cuvis_mesu_metadata_t_assembly_get, _cuvis_pyil.cuvis_mesu_metadata_t_assembly_set) + integration_time = property(_cuvis_pyil.cuvis_mesu_metadata_t_integration_time_get, _cuvis_pyil.cuvis_mesu_metadata_t_integration_time_set) + averages = property(_cuvis_pyil.cuvis_mesu_metadata_t_averages_get, _cuvis_pyil.cuvis_mesu_metadata_t_averages_set) + session_info_name = property(_cuvis_pyil.cuvis_mesu_metadata_t_session_info_name_get, _cuvis_pyil.cuvis_mesu_metadata_t_session_info_name_set) + session_info_session_no = property(_cuvis_pyil.cuvis_mesu_metadata_t_session_info_session_no_get, _cuvis_pyil.cuvis_mesu_metadata_t_session_info_session_no_set) + session_info_sequence_no = property(_cuvis_pyil.cuvis_mesu_metadata_t_session_info_sequence_no_get, _cuvis_pyil.cuvis_mesu_metadata_t_session_info_sequence_no_set) + processing_mode = property(_cuvis_pyil.cuvis_mesu_metadata_t_processing_mode_get, _cuvis_pyil.cuvis_mesu_metadata_t_processing_mode_set) + measurement_flags = property(_cuvis_pyil.cuvis_mesu_metadata_t_measurement_flags_get, _cuvis_pyil.cuvis_mesu_metadata_t_measurement_flags_set) + + def __init__(self): + _cuvis_pyil.cuvis_mesu_metadata_t_swiginit(self, _cuvis_pyil.new_cuvis_mesu_metadata_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_mesu_metadata_t + +# Register cuvis_mesu_metadata_t in _cuvis_pyil: +_cuvis_pyil.cuvis_mesu_metadata_t_swigregister(cuvis_mesu_metadata_t) + +class cuvis_save_args_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + allow_fragmentation = property(_cuvis_pyil.cuvis_save_args_t_allow_fragmentation_get, _cuvis_pyil.cuvis_save_args_t_allow_fragmentation_set) + allow_overwrite = property(_cuvis_pyil.cuvis_save_args_t_allow_overwrite_get, _cuvis_pyil.cuvis_save_args_t_allow_overwrite_set) + allow_drop = property(_cuvis_pyil.cuvis_save_args_t_allow_drop_get, _cuvis_pyil.cuvis_save_args_t_allow_drop_set) + allow_session_file = property(_cuvis_pyil.cuvis_save_args_t_allow_session_file_get, _cuvis_pyil.cuvis_save_args_t_allow_session_file_set) + allow_info_file = property(_cuvis_pyil.cuvis_save_args_t_allow_info_file_get, _cuvis_pyil.cuvis_save_args_t_allow_info_file_set) + operation_mode = property(_cuvis_pyil.cuvis_save_args_t_operation_mode_get, _cuvis_pyil.cuvis_save_args_t_operation_mode_set) + fps = property(_cuvis_pyil.cuvis_save_args_t_fps_get, _cuvis_pyil.cuvis_save_args_t_fps_set) + soft_limit = property(_cuvis_pyil.cuvis_save_args_t_soft_limit_get, _cuvis_pyil.cuvis_save_args_t_soft_limit_set) + hard_limit = property(_cuvis_pyil.cuvis_save_args_t_hard_limit_get, _cuvis_pyil.cuvis_save_args_t_hard_limit_set) + max_buftime = property(_cuvis_pyil.cuvis_save_args_t_max_buftime_get, _cuvis_pyil.cuvis_save_args_t_max_buftime_set) + + def __init__(self): + _cuvis_pyil.cuvis_save_args_t_swiginit(self, _cuvis_pyil.new_cuvis_save_args_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_save_args_t + +# Register cuvis_save_args_t in _cuvis_pyil: +_cuvis_pyil.cuvis_save_args_t_swigregister(cuvis_save_args_t) + +class cuvis_proc_args_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + processing_mode = property(_cuvis_pyil.cuvis_proc_args_t_processing_mode_get, _cuvis_pyil.cuvis_proc_args_t_processing_mode_set) + allow_recalib = property(_cuvis_pyil.cuvis_proc_args_t_allow_recalib_get, _cuvis_pyil.cuvis_proc_args_t_allow_recalib_set) + + def __init__(self): + _cuvis_pyil.cuvis_proc_args_t_swiginit(self, _cuvis_pyil.new_cuvis_proc_args_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_proc_args_t + +# Register cuvis_proc_args_t in _cuvis_pyil: +_cuvis_pyil.cuvis_proc_args_t_swigregister(cuvis_proc_args_t) + +class cuvis_export_general_settings_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + export_dir = property(_cuvis_pyil.cuvis_export_general_settings_t_export_dir_get, _cuvis_pyil.cuvis_export_general_settings_t_export_dir_set) + channel_selection = property(_cuvis_pyil.cuvis_export_general_settings_t_channel_selection_get, _cuvis_pyil.cuvis_export_general_settings_t_channel_selection_set) + spectra_multiplier = property(_cuvis_pyil.cuvis_export_general_settings_t_spectra_multiplier_get, _cuvis_pyil.cuvis_export_general_settings_t_spectra_multiplier_set) + pan_scale = property(_cuvis_pyil.cuvis_export_general_settings_t_pan_scale_get, _cuvis_pyil.cuvis_export_general_settings_t_pan_scale_set) + pan_interpolation_type = property(_cuvis_pyil.cuvis_export_general_settings_t_pan_interpolation_type_get, _cuvis_pyil.cuvis_export_general_settings_t_pan_interpolation_type_set) + pan_algorithm = property(_cuvis_pyil.cuvis_export_general_settings_t_pan_algorithm_get, _cuvis_pyil.cuvis_export_general_settings_t_pan_algorithm_set) + add_pan = property(_cuvis_pyil.cuvis_export_general_settings_t_add_pan_get, _cuvis_pyil.cuvis_export_general_settings_t_add_pan_set) + add_fullscale_pan = property(_cuvis_pyil.cuvis_export_general_settings_t_add_fullscale_pan_get, _cuvis_pyil.cuvis_export_general_settings_t_add_fullscale_pan_set) + permissive = property(_cuvis_pyil.cuvis_export_general_settings_t_permissive_get, _cuvis_pyil.cuvis_export_general_settings_t_permissive_set) + + def __init__(self): + _cuvis_pyil.cuvis_export_general_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_export_general_settings_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_export_general_settings_t + +# Register cuvis_export_general_settings_t in _cuvis_pyil: +_cuvis_pyil.cuvis_export_general_settings_t_swigregister(cuvis_export_general_settings_t) + +class cuvis_export_view_settings_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + userplugin = property(_cuvis_pyil.cuvis_export_view_settings_t_userplugin_get, _cuvis_pyil.cuvis_export_view_settings_t_userplugin_set) + + def __init__(self): + _cuvis_pyil.cuvis_export_view_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_export_view_settings_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_export_view_settings_t + +# Register cuvis_export_view_settings_t in _cuvis_pyil: +_cuvis_pyil.cuvis_export_view_settings_t_swigregister(cuvis_export_view_settings_t) + +class cuvis_export_tiff_settings_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + compression_mode = property(_cuvis_pyil.cuvis_export_tiff_settings_t_compression_mode_get, _cuvis_pyil.cuvis_export_tiff_settings_t_compression_mode_set) + format = property(_cuvis_pyil.cuvis_export_tiff_settings_t_format_get, _cuvis_pyil.cuvis_export_tiff_settings_t_format_set) + + def __init__(self): + _cuvis_pyil.cuvis_export_tiff_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_export_tiff_settings_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_export_tiff_settings_t + +# Register cuvis_export_tiff_settings_t in _cuvis_pyil: +_cuvis_pyil.cuvis_export_tiff_settings_t_swigregister(cuvis_export_tiff_settings_t) + +class cuvis_viewer_settings_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + userplugin = property(_cuvis_pyil.cuvis_viewer_settings_t_userplugin_get, _cuvis_pyil.cuvis_viewer_settings_t_userplugin_set) + pan_scale = property(_cuvis_pyil.cuvis_viewer_settings_t_pan_scale_get, _cuvis_pyil.cuvis_viewer_settings_t_pan_scale_set) + pan_interpolation_type = property(_cuvis_pyil.cuvis_viewer_settings_t_pan_interpolation_type_get, _cuvis_pyil.cuvis_viewer_settings_t_pan_interpolation_type_set) + pan_algorithm = property(_cuvis_pyil.cuvis_viewer_settings_t_pan_algorithm_get, _cuvis_pyil.cuvis_viewer_settings_t_pan_algorithm_set) + complete = property(_cuvis_pyil.cuvis_viewer_settings_t_complete_get, _cuvis_pyil.cuvis_viewer_settings_t_complete_set) + + def __init__(self): + _cuvis_pyil.cuvis_viewer_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_viewer_settings_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_viewer_settings_t + +# Register cuvis_viewer_settings_t in _cuvis_pyil: +_cuvis_pyil.cuvis_viewer_settings_t_swigregister(cuvis_viewer_settings_t) + +class cuvis_view_data_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + id = property(_cuvis_pyil.cuvis_view_data_t_id_get, _cuvis_pyil.cuvis_view_data_t_id_set) + category = property(_cuvis_pyil.cuvis_view_data_t_category_get, _cuvis_pyil.cuvis_view_data_t_category_set) + data = property(_cuvis_pyil.cuvis_view_data_t_data_get, _cuvis_pyil.cuvis_view_data_t_data_set) + show = property(_cuvis_pyil.cuvis_view_data_t_show_get, _cuvis_pyil.cuvis_view_data_t_show_set) + + def __init__(self): + _cuvis_pyil.cuvis_view_data_t_swiginit(self, _cuvis_pyil.new_cuvis_view_data_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_view_data_t + +# Register cuvis_view_data_t in _cuvis_pyil: +_cuvis_pyil.cuvis_view_data_t_swigregister(cuvis_view_data_t) + +class cuvis_component_info_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + type = property(_cuvis_pyil.cuvis_component_info_t_type_get, _cuvis_pyil.cuvis_component_info_t_type_set) + displayname = property(_cuvis_pyil.cuvis_component_info_t_displayname_get, _cuvis_pyil.cuvis_component_info_t_displayname_set) + sensorinfo = property(_cuvis_pyil.cuvis_component_info_t_sensorinfo_get, _cuvis_pyil.cuvis_component_info_t_sensorinfo_set) + userfield = property(_cuvis_pyil.cuvis_component_info_t_userfield_get, _cuvis_pyil.cuvis_component_info_t_userfield_set) + pixelformat = property(_cuvis_pyil.cuvis_component_info_t_pixelformat_get, _cuvis_pyil.cuvis_component_info_t_pixelformat_set) + + def __init__(self): + _cuvis_pyil.cuvis_component_info_t_swiginit(self, _cuvis_pyil.new_cuvis_component_info_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_component_info_t + +# Register cuvis_component_info_t in _cuvis_pyil: +_cuvis_pyil.cuvis_component_info_t_swigregister(cuvis_component_info_t) + +class cuvis_event_base_data_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + event_id = property(_cuvis_pyil.cuvis_event_base_data_t_event_id_get, _cuvis_pyil.cuvis_event_base_data_t_event_id_set) + + def __init__(self): + _cuvis_pyil.cuvis_event_base_data_t_swiginit(self, _cuvis_pyil.new_cuvis_event_base_data_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_base_data_t + +# Register cuvis_event_base_data_t in _cuvis_pyil: +_cuvis_pyil.cuvis_event_base_data_t_swigregister(cuvis_event_base_data_t) + +class cuvis_event_acquisition_data_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + source = property(_cuvis_pyil.cuvis_event_acquisition_data_t_source_get, _cuvis_pyil.cuvis_event_acquisition_data_t_source_set) + + def __init__(self): + _cuvis_pyil.cuvis_event_acquisition_data_t_swiginit(self, _cuvis_pyil.new_cuvis_event_acquisition_data_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_acquisition_data_t + +# Register cuvis_event_acquisition_data_t in _cuvis_pyil: +_cuvis_pyil.cuvis_event_acquisition_data_t_swigregister(cuvis_event_acquisition_data_t) + +class cuvis_event_processing_event_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + source = property(_cuvis_pyil.cuvis_event_processing_event_t_source_get, _cuvis_pyil.cuvis_event_processing_event_t_source_set) + + def __init__(self): + _cuvis_pyil.cuvis_event_processing_event_t_swiginit(self, _cuvis_pyil.new_cuvis_event_processing_event_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_processing_event_t + +# Register cuvis_event_processing_event_t in _cuvis_pyil: +_cuvis_pyil.cuvis_event_processing_event_t_swigregister(cuvis_event_processing_event_t) + +class cuvis_event_qualitiy_event_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + source = property(_cuvis_pyil.cuvis_event_qualitiy_event_t_source_get, _cuvis_pyil.cuvis_event_qualitiy_event_t_source_set) + + def __init__(self): + _cuvis_pyil.cuvis_event_qualitiy_event_t_swiginit(self, _cuvis_pyil.new_cuvis_event_qualitiy_event_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_qualitiy_event_t + +# Register cuvis_event_qualitiy_event_t in _cuvis_pyil: +_cuvis_pyil.cuvis_event_qualitiy_event_t_swigregister(cuvis_event_qualitiy_event_t) + +class cuvis_event_component_data_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + compent_id = property(_cuvis_pyil.cuvis_event_component_data_t_compent_id_get, _cuvis_pyil.cuvis_event_component_data_t_compent_id_set) + + def __init__(self): + _cuvis_pyil.cuvis_event_component_data_t_swiginit(self, _cuvis_pyil.new_cuvis_event_component_data_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_component_data_t + +# Register cuvis_event_component_data_t in _cuvis_pyil: +_cuvis_pyil.cuvis_event_component_data_t_swigregister(cuvis_event_component_data_t) + +class cuvis_worker_settings_t(object): + thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") + __repr__ = _swig_repr + worker_count = property(_cuvis_pyil.cuvis_worker_settings_t_worker_count_get, _cuvis_pyil.cuvis_worker_settings_t_worker_count_set) + poll_interval = property(_cuvis_pyil.cuvis_worker_settings_t_poll_interval_get, _cuvis_pyil.cuvis_worker_settings_t_poll_interval_set) + keep_out_of_sequence = property(_cuvis_pyil.cuvis_worker_settings_t_keep_out_of_sequence_get, _cuvis_pyil.cuvis_worker_settings_t_keep_out_of_sequence_set) + worker_queue_size = property(_cuvis_pyil.cuvis_worker_settings_t_worker_queue_size_get, _cuvis_pyil.cuvis_worker_settings_t_worker_queue_size_set) + + def __init__(self): + _cuvis_pyil.cuvis_worker_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_worker_settings_t()) + __swig_destroy__ = _cuvis_pyil.delete_cuvis_worker_settings_t + +# Register cuvis_worker_settings_t in _cuvis_pyil: +_cuvis_pyil.cuvis_worker_settings_t_swigregister(cuvis_worker_settings_t) + +CUVIS_EVENT_PROCESSING = _cuvis_pyil.CUVIS_EVENT_PROCESSING +CUVIS_EVENT_ACQUISTION = _cuvis_pyil.CUVIS_EVENT_ACQUISTION +CUVIS_EVENT_COMPONENT = _cuvis_pyil.CUVIS_EVENT_COMPONENT +CUVIS_EVENT_TRIGGER_SKIPPED = _cuvis_pyil.CUVIS_EVENT_TRIGGER_SKIPPED + +def cuvis_event_get_acquisition_data(i_event, o_p_acquisition_data): + return _cuvis_pyil.cuvis_event_get_acquisition_data(i_event, o_p_acquisition_data) + +def cuvis_register_external_event_callback(i_callback, i_type, o_p_handler_id): + return _cuvis_pyil.cuvis_register_external_event_callback(i_callback, i_type, o_p_handler_id) + +def cuvis_unregister_event_callback(i_handler_id): + return _cuvis_pyil.cuvis_unregister_event_callback(i_handler_id) + +def cuvis_get_last_error_msg(): + return _cuvis_pyil.cuvis_get_last_error_msg() + +def cuvis_set_last_error_locale(id): + return _cuvis_pyil.cuvis_set_last_error_locale(id) + +def cuvis_get_last_error_msg_localized(): + return _cuvis_pyil.cuvis_get_last_error_msg_localized() + +def cuvis_set_log_level(level): + return _cuvis_pyil.cuvis_set_log_level(level) + +def cuvis_register_log_callback(i_callback, i_min_level): + return _cuvis_pyil.cuvis_register_log_callback(i_callback, i_min_level) + +def cuvis_reset_log_callback(): + return _cuvis_pyil.cuvis_reset_log_callback() + +def cuvis_register_log_callback_localized(i_callback_localized, i_min_level, i_locale_id): + return _cuvis_pyil.cuvis_register_log_callback_localized(i_callback_localized, i_min_level, i_locale_id) + +def cuvis_reset_log_callback_localized(): + return _cuvis_pyil.cuvis_reset_log_callback_localized() + +def cuvis_init(i_settings_path): + return _cuvis_pyil.cuvis_init(i_settings_path) + +def cuvis_async_call_get(io_pAsyncResult, timeout_ms): + return _cuvis_pyil.cuvis_async_call_get(io_pAsyncResult, timeout_ms) + +def cuvis_async_capture_free(io_pAsyncResult): + return _cuvis_pyil.cuvis_async_capture_free(io_pAsyncResult) + +def cuvis_async_call_free(io_pAsyncResult): + return _cuvis_pyil.cuvis_async_call_free(io_pAsyncResult) + +def cuvis_acq_cont_capture(i_acqCont, o_pMesu, timeout_ms): + return _cuvis_pyil.cuvis_acq_cont_capture(i_acqCont, o_pMesu, timeout_ms) + +def cuvis_acq_cont_capture_async(i_acqCont, o_pAsyncResult): + return _cuvis_pyil.cuvis_acq_cont_capture_async(i_acqCont, o_pAsyncResult) + +def cuvis_async_capture_get(io_pAsyncResult, timeout_ms, o_pMesu): + return _cuvis_pyil.cuvis_async_capture_get(io_pAsyncResult, timeout_ms, o_pMesu) + +def cuvis_measurement_load(i_path, o_pMesu): + return _cuvis_pyil.cuvis_measurement_load(i_path, o_pMesu) + +def cuvis_measurement_deep_copy(i_mesu, o_pMesu): + return _cuvis_pyil.cuvis_measurement_deep_copy(i_mesu, o_pMesu) + +def cuvis_session_file_load(i_path, o_pSess): + return _cuvis_pyil.cuvis_session_file_load(i_path, o_pSess) + +def cuvis_session_file_free(o_pSess): + return _cuvis_pyil.cuvis_session_file_free(o_pSess) + +def cuvis_session_file_get_mesu(i_sess, i_frameNo, o_pMesu): + return _cuvis_pyil.cuvis_session_file_get_mesu(i_sess, i_frameNo, o_pMesu) + +def cuvis_session_file_get_size(i_sess, o_pSize): + return _cuvis_pyil.cuvis_session_file_get_size(i_sess, o_pSize) + +def cuvis_session_file_get_size_non_dropped(i_sess, o_pSize): + return _cuvis_pyil.cuvis_session_file_get_size_non_dropped(i_sess, o_pSize) + +def cuvis_session_file_get_mesu_non_dropped(i_sess, i_frameNo, o_pMesu): + return _cuvis_pyil.cuvis_session_file_get_mesu_non_dropped(i_sess, i_frameNo, o_pMesu) + +def cuvis_session_file_get_fps(i_sess, o_pFps): + return _cuvis_pyil.cuvis_session_file_get_fps(i_sess, o_pFps) + +def cuvis_session_file_get_operation_mode(i_sess, o_pMode): + return _cuvis_pyil.cuvis_session_file_get_operation_mode(i_sess, o_pMode) + +def cuvis_acq_cont_get_next_measurement(i_acqCont, o_pMesu, timeout_ms): + return _cuvis_pyil.cuvis_acq_cont_get_next_measurement(i_acqCont, o_pMesu, timeout_ms) + +def cuvis_acq_cont_has_next_measurement(i_acqCont, o_pHasNext): + return _cuvis_pyil.cuvis_acq_cont_has_next_measurement(i_acqCont, o_pHasNext) + +def cuvis_measurement_save(i_mesu, i_path, args): + return _cuvis_pyil.cuvis_measurement_save(i_mesu, i_path, args) + +def cuvis_measurement_set_name(i_mesu, i_name): + return _cuvis_pyil.cuvis_measurement_set_name(i_mesu, i_name) + +def cuvis_measurement_set_comment(i_mesu, i_comment): + return _cuvis_pyil.cuvis_measurement_set_comment(i_mesu, i_comment) + +def cuvis_measurement_free(io_pMesu): + return _cuvis_pyil.cuvis_measurement_free(io_pMesu) + +def cuvis_measurement_get_metadata(i_mesu, o_pMetaData): + return _cuvis_pyil.cuvis_measurement_get_metadata(i_mesu, o_pMetaData) + +def cuvis_measurement_get_data_image(i_mesu, i_key, o_pBuf): + return _cuvis_pyil.cuvis_measurement_get_data_image(i_mesu, i_key, o_pBuf) + +def cuvis_measurement_get_data_sensor_info(i_mesu, i_key, o_pValue): + return _cuvis_pyil.cuvis_measurement_get_data_sensor_info(i_mesu, i_key, o_pValue) + +def cuvis_measurement_get_data_gps(i_mesu, i_key, o_pGps): + return _cuvis_pyil.cuvis_measurement_get_data_gps(i_mesu, i_key, o_pGps) + +def cuvis_measurement_get_data_count(i_mesu, o_pCount): + return _cuvis_pyil.cuvis_measurement_get_data_count(i_mesu, o_pCount) + +def cuvis_calib_create_from_path(i_factoryDir, o_pCalibration): + return _cuvis_pyil.cuvis_calib_create_from_path(i_factoryDir, o_pCalibration) + +def cuvis_calib_free(io_pCalibration): + return _cuvis_pyil.cuvis_calib_free(io_pCalibration) + +def cuvis_acq_cont_create_from_calib(i_calib, o_pAcqCont): + return _cuvis_pyil.cuvis_acq_cont_create_from_calib(i_calib, o_pAcqCont) + +def cuvis_acq_cont_get_state(i_acqCont, o_pState): + return _cuvis_pyil.cuvis_acq_cont_get_state(i_acqCont, o_pState) + +def cuvis_acq_cont_get_session_info(i_acqCont, o_pSessionInfo): + return _cuvis_pyil.cuvis_acq_cont_get_session_info(i_acqCont, o_pSessionInfo) + +def cuvis_acq_cont_set_session_info(i_acqCont, i_pSessionInfo): + return _cuvis_pyil.cuvis_acq_cont_set_session_info(i_acqCont, i_pSessionInfo) + +def cuvis_acq_cont_queue_size_set(i_acqCont, i_size): + return _cuvis_pyil.cuvis_acq_cont_queue_size_set(i_acqCont, i_size) + +def cuvis_acq_cont_free(io_pAcqCont): + return _cuvis_pyil.cuvis_acq_cont_free(io_pAcqCont) + +def cuvis_acq_cont_get_component_info(i_acqCont, i_id, o_pCompInfo): + return _cuvis_pyil.cuvis_acq_cont_get_component_info(i_acqCont, i_id, o_pCompInfo) + +def cuvis_acq_cont_get_component_count(i_acqCont, o_pCount): + return _cuvis_pyil.cuvis_acq_cont_get_component_count(i_acqCont, o_pCount) + +def cuvis_proc_cont_create_from_calib(i_calib, o_pProcCont): + return _cuvis_pyil.cuvis_proc_cont_create_from_calib(i_calib, o_pProcCont) + +def cuvis_proc_cont_create_from_mesu(i_mesu, o_pProcCont): + return _cuvis_pyil.cuvis_proc_cont_create_from_mesu(i_mesu, o_pProcCont) + +def cuvis_proc_cont_create_from_session_file(i_sess, o_pProcCont): + return _cuvis_pyil.cuvis_proc_cont_create_from_session_file(i_sess, o_pProcCont) + +def cuvis_proc_cont_get_reference(i_procCont, o_pMesu, i_type): + return _cuvis_pyil.cuvis_proc_cont_get_reference(i_procCont, o_pMesu, i_type) + +def cuvis_proc_cont_set_reference(i_procCont, i_mesu, i_type): + return _cuvis_pyil.cuvis_proc_cont_set_reference(i_procCont, i_mesu, i_type) + +def cuvis_proc_cont_clear_reference(i_procCont, i_type): + return _cuvis_pyil.cuvis_proc_cont_clear_reference(i_procCont, i_type) + +def cuvis_proc_cont_calc_distance(i_procCont, i_distanceMM): + return _cuvis_pyil.cuvis_proc_cont_calc_distance(i_procCont, i_distanceMM) + +def cuvis_proc_cont_has_reference(i_procCont, i_type, o_pHasReference): + return _cuvis_pyil.cuvis_proc_cont_has_reference(i_procCont, i_type, o_pHasReference) + +def cuvis_proc_cont_is_capable(i_procCont, i_mesu, args, o_pIsCapable): + return _cuvis_pyil.cuvis_proc_cont_is_capable(i_procCont, i_mesu, args, o_pIsCapable) + +def cuvis_proc_cont_apply(i_procCont, i_mesu): + return _cuvis_pyil.cuvis_proc_cont_apply(i_procCont, i_mesu) + +def cuvis_proc_cont_set_args(i_procCont, i_args): + return _cuvis_pyil.cuvis_proc_cont_set_args(i_procCont, i_args) + +def cuvis_proc_cont_free(io_pProcCont): + return _cuvis_pyil.cuvis_proc_cont_free(io_pProcCont) + +def cuvis_exporter_create_cube(o_pExporter, generalSettings, formatSettings): + return _cuvis_pyil.cuvis_exporter_create_cube(o_pExporter, generalSettings, formatSettings) + +def cuvis_exporter_create_tiff(o_pExporter, generalSettings, formatSettings): + return _cuvis_pyil.cuvis_exporter_create_tiff(o_pExporter, generalSettings, formatSettings) + +def cuvis_exporter_create_envi(o_pExporter, generalSettings): + return _cuvis_pyil.cuvis_exporter_create_envi(o_pExporter, generalSettings) + +def cuvis_exporter_create_view(o_pExporter, generalSettings, formatSettings): + return _cuvis_pyil.cuvis_exporter_create_view(o_pExporter, generalSettings, formatSettings) + +def cuvis_exporter_apply(i_exporter, i_mesu): + return _cuvis_pyil.cuvis_exporter_apply(i_exporter, i_mesu) + +def cuvis_exporter_get_queue_used(i_exporter, o_pQueueUsed): + return _cuvis_pyil.cuvis_exporter_get_queue_used(i_exporter, o_pQueueUsed) + +def cuvis_exporter_free(io_pExporter): + return _cuvis_pyil.cuvis_exporter_free(io_pExporter) + +def cuvis_viewer_create(o_pViewer, viewerSettings): + return _cuvis_pyil.cuvis_viewer_create(o_pViewer, viewerSettings) + +def cuvis_viewer_apply(i_viewer, i_mesu, o_pView): + return _cuvis_pyil.cuvis_viewer_apply(i_viewer, i_mesu, o_pView) + +def cuvis_viewer_free(io_pViewer): + return _cuvis_pyil.cuvis_viewer_free(io_pViewer) + +def cuvis_view_get_data_count(i_view, o_pCount): + return _cuvis_pyil.cuvis_view_get_data_count(i_view, o_pCount) + +def cuvis_view_get_data(i_view, i_index, o_pData): + return _cuvis_pyil.cuvis_view_get_data(i_view, i_index, o_pData) + +def cuvis_view_free(io_pView): + return _cuvis_pyil.cuvis_view_free(io_pView) + +def cuvis_calib_get_capabilities(i_calibration, i_mode, o_pCapabilities): + return _cuvis_pyil.cuvis_calib_get_capabilities(i_calibration, i_mode, o_pCapabilities) + +def cuvis_measurement_get_capabilities(i_mesu, o_pCapabilities): + return _cuvis_pyil.cuvis_measurement_get_capabilities(i_mesu, o_pCapabilities) + +def cuvis_measurement_get_calib_id(i_mesu, o_pCalibId): + return _cuvis_pyil.cuvis_measurement_get_calib_id(i_mesu, o_pCalibId) + +def cuvis_calib_get_id(i_calib, o_pCalibId): + return _cuvis_pyil.cuvis_calib_get_id(i_calib, o_pCalibId) + +def cuvis_proc_cont_get_calib_id(i_procCont, o_pCalibId): + return _cuvis_pyil.cuvis_proc_cont_get_calib_id(i_procCont, o_pCalibId) + +def cuvis_worker_create(o_pWorker, worker_settings): + return _cuvis_pyil.cuvis_worker_create(o_pWorker, worker_settings) + +def cuvis_worker_free(io_pWorker): + return _cuvis_pyil.cuvis_worker_free(io_pWorker) + +def cuvis_worker_set_acq_cont(i_worker, i_acq_cont): + return _cuvis_pyil.cuvis_worker_set_acq_cont(i_worker, i_acq_cont) + +def cuvis_worker_set_proc_cont(i_worker, i_proc_cont): + return _cuvis_pyil.cuvis_worker_set_proc_cont(i_worker, i_proc_cont) + +def cuvis_worker_set_exporter(i_worker, i_exporter): + return _cuvis_pyil.cuvis_worker_set_exporter(i_worker, i_exporter) + +def cuvis_worker_set_viewer(i_worker, i_viewer): + return _cuvis_pyil.cuvis_worker_set_viewer(i_worker, i_viewer) + +def cuvis_worker_get_next_result(i_worker, o_pMesu, o_pView): + return _cuvis_pyil.cuvis_worker_get_next_result(i_worker, o_pMesu, o_pView) + +def cuvis_worker_has_next_result(i_worker, o_pHasNext): + return _cuvis_pyil.cuvis_worker_has_next_result(i_worker, o_pHasNext) + +def cuvis_worker_get_queue_limit(i_worker, o_pQueueLimit): + return _cuvis_pyil.cuvis_worker_get_queue_limit(i_worker, o_pQueueLimit) + +def cuvis_worker_get_queue_used(i_worker, o_pQueueUsed): + return _cuvis_pyil.cuvis_worker_get_queue_used(i_worker, o_pQueueUsed) + +def cuvis_worker_set_queue_limit(i_worker, i_QueueLimit): + return _cuvis_pyil.cuvis_worker_set_queue_limit(i_worker, i_QueueLimit) + +def cuvis_set_special(arg1): + return _cuvis_pyil.cuvis_set_special(arg1) + +def cuvis_imbuffer_allocate(): + return _cuvis_pyil.cuvis_imbuffer_allocate() + +def cuvis_imbuffer_free(ptr): + return _cuvis_pyil.cuvis_imbuffer_free(ptr) + +def cuvis_gps_allocate(): + return _cuvis_pyil.cuvis_gps_allocate() + +def cuvis_gps_free(ptr): + return _cuvis_pyil.cuvis_gps_free(ptr) + +def cuvis_sensor_info_allocate(): + return _cuvis_pyil.cuvis_sensor_info_allocate() + +def cuvis_sensor_info_free(ptr): + return _cuvis_pyil.cuvis_sensor_info_free(ptr) + +def cuvis_session_info_allocate(): + return _cuvis_pyil.cuvis_session_info_allocate() + +def cuvis_session_info_free(ptr): + return _cuvis_pyil.cuvis_session_info_free(ptr) + +def cuvis_mesu_metadata_allocate(): + return _cuvis_pyil.cuvis_mesu_metadata_allocate() + +def cuvis_mesu_metadata_free(ptr): + return _cuvis_pyil.cuvis_mesu_metadata_free(ptr) + +def cuvis_save_args_allocate(): + return _cuvis_pyil.cuvis_save_args_allocate() + +def cuvis_save_args_free(ptr): + return _cuvis_pyil.cuvis_save_args_free(ptr) + +def cuvis_proc_args_allocate(): + return _cuvis_pyil.cuvis_proc_args_allocate() + +def cuvis_proc_args_free(ptr): + return _cuvis_pyil.cuvis_proc_args_free(ptr) + +def cuvis_export_general_settings_allocate(): + return _cuvis_pyil.cuvis_export_general_settings_allocate() + +def cuvis_export_general_settings_free(ptr): + return _cuvis_pyil.cuvis_export_general_settings_free(ptr) + +def cuvis_export_cube_settings_allocate(): + return _cuvis_pyil.cuvis_export_cube_settings_allocate() + +def cuvis_export_cube_settings_free(ptr): + return _cuvis_pyil.cuvis_export_cube_settings_free(ptr) + +def cuvis_export_view_settings_allocate(): + return _cuvis_pyil.cuvis_export_view_settings_allocate() + +def cuvis_export_view_settings_free(ptr): + return _cuvis_pyil.cuvis_export_view_settings_free(ptr) + +def cuvis_export_tiff_settings_allocate(): + return _cuvis_pyil.cuvis_export_tiff_settings_allocate() + +def cuvis_export_tiff_settings_free(ptr): + return _cuvis_pyil.cuvis_export_tiff_settings_free(ptr) + +def cuvis_viewer_settings_allocate(): + return _cuvis_pyil.cuvis_viewer_settings_allocate() + +def cuvis_viewer_settings_free(ptr): + return _cuvis_pyil.cuvis_viewer_settings_free(ptr) + +def cuvis_view_data_allocate(): + return _cuvis_pyil.cuvis_view_data_allocate() + +def cuvis_view_data_free(ptr): + return _cuvis_pyil.cuvis_view_data_free(ptr) + +def cuvis_cuvis_component_info_allocate(): + return _cuvis_pyil.cuvis_cuvis_component_info_allocate() + +def cuvis_cuvis_component_info_free(ptr): + return _cuvis_pyil.cuvis_cuvis_component_info_free(ptr) + +def cuvis_worker_settings_allocate(): + return _cuvis_pyil.cuvis_worker_settings_allocate() + +def cuvis_worker_settings_free(ptr): + return _cuvis_pyil.cuvis_worker_settings_free(ptr) + +def cuvis_acq_cont_fps_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_fps_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_fps_set(i_acqCont, value): + return _cuvis_pyil.cuvis_acq_cont_fps_set(i_acqCont, value) + +def cuvis_acq_cont_fps_set_async(i_acqCont, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_acq_cont_fps_set_async(i_acqCont, o_pAsyncResult, value) + +def cuvis_acq_cont_average_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_average_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_average_set(i_acqCont, value): + return _cuvis_pyil.cuvis_acq_cont_average_set(i_acqCont, value) + +def cuvis_acq_cont_average_set_async(i_acqCont, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_acq_cont_average_set_async(i_acqCont, o_pAsyncResult, value) + +def cuvis_acq_cont_integration_time_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_integration_time_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_integration_time_set(i_acqCont, value): + return _cuvis_pyil.cuvis_acq_cont_integration_time_set(i_acqCont, value) + +def cuvis_acq_cont_integration_time_set_async(i_acqCont, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_acq_cont_integration_time_set_async(i_acqCont, o_pAsyncResult, value) + +def cuvis_acq_cont_auto_exp_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_auto_exp_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_auto_exp_set(i_acqCont, value): + return _cuvis_pyil.cuvis_acq_cont_auto_exp_set(i_acqCont, value) + +def cuvis_acq_cont_auto_exp_set_async(i_acqCont, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_acq_cont_auto_exp_set_async(i_acqCont, o_pAsyncResult, value) + +def cuvis_acq_cont_preview_mode_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_preview_mode_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_preview_mode_set(i_acqCont, value): + return _cuvis_pyil.cuvis_acq_cont_preview_mode_set(i_acqCont, value) + +def cuvis_acq_cont_preview_mode_set_async(i_acqCont, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_acq_cont_preview_mode_set_async(i_acqCont, o_pAsyncResult, value) + +def cuvis_acq_cont_operation_mode_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_operation_mode_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_operation_mode_set(i_acqCont, value): + return _cuvis_pyil.cuvis_acq_cont_operation_mode_set(i_acqCont, value) + +def cuvis_acq_cont_operation_mode_set_async(i_acqCont, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_acq_cont_operation_mode_set_async(i_acqCont, o_pAsyncResult, value) + +def cuvis_acq_cont_continuous_set(i_acqCont, value): + return _cuvis_pyil.cuvis_acq_cont_continuous_set(i_acqCont, value) + +def cuvis_acq_cont_continuous_set_async(i_acqCont, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_acq_cont_continuous_set_async(i_acqCont, o_pAsyncResult, value) + +def cuvis_acq_cont_bandwidth_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_bandwidth_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_queue_size_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_queue_size_get(i_acqCont, o_pvalue) + +def cuvis_acq_cont_queue_used_get(i_acqCont, o_pvalue): + return _cuvis_pyil.cuvis_acq_cont_queue_used_get(i_acqCont, o_pvalue) + +def cuvis_comp_online_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_online_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_temperature_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_temperature_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_bandwidth_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_bandwidth_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_driver_queue_size_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_driver_queue_size_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_driver_queue_used_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_driver_queue_used_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_hardware_queue_size_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_hardware_queue_size_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_hardware_queue_used_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_hardware_queue_used_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_gain_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_gain_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_gain_set(i_acqCont, i_id, value): + return _cuvis_pyil.cuvis_comp_gain_set(i_acqCont, i_id, value) + +def cuvis_comp_gain_set_async(i_acqCont, i_id, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_comp_gain_set_async(i_acqCont, i_id, o_pAsyncResult, value) + +def cuvis_comp_integration_time_factor_get(i_acqCont, i_id, o_pvalue): + return _cuvis_pyil.cuvis_comp_integration_time_factor_get(i_acqCont, i_id, o_pvalue) + +def cuvis_comp_integration_time_factor_set(i_acqCont, i_id, value): + return _cuvis_pyil.cuvis_comp_integration_time_factor_set(i_acqCont, i_id, value) + +def cuvis_comp_integration_time_factor_set_async(i_acqCont, i_id, o_pAsyncResult, value): + return _cuvis_pyil.cuvis_comp_integration_time_factor_set_async(i_acqCont, i_id, o_pAsyncResult, value) + +def new_p_cuvis_data_type_t(): + return _cuvis_pyil.new_p_cuvis_data_type_t() + +def copy_p_cuvis_data_type_t(value): + return _cuvis_pyil.copy_p_cuvis_data_type_t(value) + +def delete_p_cuvis_data_type_t(obj): + return _cuvis_pyil.delete_p_cuvis_data_type_t(obj) + +def p_cuvis_data_type_t_assign(obj, value): + return _cuvis_pyil.p_cuvis_data_type_t_assign(obj, value) + +def p_cuvis_data_type_t_value(obj): + return _cuvis_pyil.p_cuvis_data_type_t_value(obj) + +def new_p_cuvis_operation_mode_t(): + return _cuvis_pyil.new_p_cuvis_operation_mode_t() + +def copy_p_cuvis_operation_mode_t(value): + return _cuvis_pyil.copy_p_cuvis_operation_mode_t(value) + +def delete_p_cuvis_operation_mode_t(obj): + return _cuvis_pyil.delete_p_cuvis_operation_mode_t(obj) + +def p_cuvis_operation_mode_t_assign(obj, value): + return _cuvis_pyil.p_cuvis_operation_mode_t_assign(obj, value) + +def p_cuvis_operation_mode_t_value(obj): + return _cuvis_pyil.p_cuvis_operation_mode_t_value(obj) + +def new_p_cuvis_hardware_state_t(): + return _cuvis_pyil.new_p_cuvis_hardware_state_t() + +def copy_p_cuvis_hardware_state_t(value): + return _cuvis_pyil.copy_p_cuvis_hardware_state_t(value) + +def delete_p_cuvis_hardware_state_t(obj): + return _cuvis_pyil.delete_p_cuvis_hardware_state_t(obj) + +def p_cuvis_hardware_state_t_assign(obj, value): + return _cuvis_pyil.p_cuvis_hardware_state_t_assign(obj, value) + +def p_cuvis_hardware_state_t_value(obj): + return _cuvis_pyil.p_cuvis_hardware_state_t_value(obj) + + diff --git a/Python/src/cuvis/cuvis_types.py b/Python/src/cuvis/cuvis_types.py new file mode 100644 index 0000000..4346576 --- /dev/null +++ b/Python/src/cuvis/cuvis_types.py @@ -0,0 +1,161 @@ +import numpy as np + +from . import cuvis_il + +MeasurementFlag = dict({ + ("POOR_REFERENCE", cuvis_il.CUVIS_MESU_FLAG_POOR_REFERENCE_KEY), + ("OVERILLUMINATED", cuvis_il.CUVIS_MESU_FLAG_OVERILLUMINATED_KEY), + ("POOR_WHITE_BALANCING", cuvis_il.CUVIS_MESU_FLAG_POOR_WHITE_BALANCING_KEY), + ("DARK_INTTIME", cuvis_il.CUVIS_MESU_FLAG_POOR_WHITE_BALANCING_KEY), + ("DARK_TEMP", cuvis_il.CUVIS_MESU_FLAG_DARK_TEMP_KEY), + ("WHITE_INTTIME", cuvis_il.CUVIS_MESU_FLAG_WHITE_INTTIME_KEY), + ("WHITE_TEMP", cuvis_il.CUVIS_MESU_FLAG_WHITE_TEMP_KEY), + ("WHITEDARK_INTTIME", cuvis_il.CUVIS_MESU_FLAG_WHITEDARK_INTTIME_KEY), + ("WHITEDARK_TEMP", cuvis_il.CUVIS_MESU_FLAG_WHITEDARK_TEMP_KEY), +}) + +__CuvisProcessingMode__ = dict({ + ("Preview", cuvis_il.Preview), + ("Cube_Raw", cuvis_il.Cube_Raw), + ("Cube_DarkSubtract", cuvis_il.Cube_DarkSubtract), + ("Cube_Reflectance", cuvis_il.Cube_Reflectance), + ("Cube_SpectralRadiance", cuvis_il.Cube_SpectralRadiance) +}) + +__CuvisDataType__ = dict({ + ("data_type_unsupported", cuvis_il.data_type_unsupported), + ("data_type_image", cuvis_il.data_type_image), + ("data_type_gps", cuvis_il.data_type_gps), + ("data_type_string", cuvis_il.data_type_string), + ("data_type_sensor_info", cuvis_il.data_type_sensor_info), +}) + +__CuvisReferenceType__ = dict({ + ("Reference_Dark", cuvis_il.Reference_Dark), + ("Reference_White", cuvis_il.Reference_White), + ("Reference_WhiteDark", cuvis_il.Reference_WhiteDark), + ("Reference_SpRad", cuvis_il.Reference_SpRad), + ("Reference_Distance", cuvis_il.Reference_Distance), +}) + +DataFormat = dict({ + (1, np.uint8), + (2, np.uint16), + (3, np.uint32), + (4, np.float32) +}) + +PanSharpeningInterpolationType = dict({ + ("NearestNeighbour", cuvis_il.pan_sharpening_interpolation_type_NearestNeighbor), + ("Linear", cuvis_il.pan_sharpening_interpolation_type_Linear), + ("Cubic", cuvis_il.pan_sharpening_interpolation_type_Cubic), + ("Lanczos", cuvis_il.pan_sharpening_interpolation_type_Lanczos), +}) + +PanSharpeningAlgorithm = dict({ + ("Noop", cuvis_il.pan_sharpening_algorithm_Noop), + ("CubertMacroPixel", cuvis_il.pan_sharpening_algorithm_CubertMacroPixel), +}) + +ProcessingMode = dict({ + ("Preview", __CuvisProcessingMode__["Preview"]), + ("Raw", __CuvisProcessingMode__["Cube_Raw"]), + ("DarkSubtract", __CuvisProcessingMode__["Cube_DarkSubtract"]), + ("Reflectance", __CuvisProcessingMode__["Cube_Reflectance"]), + ("SpectralRadiance", __CuvisProcessingMode__["Cube_SpectralRadiance"]) +}) + +ReferenceType = dict({ + ("White", __CuvisReferenceType__["Reference_White"]), + ("Dark", __CuvisReferenceType__["Reference_Dark"]), + ("WhiteDark", __CuvisReferenceType__["Reference_WhiteDark"]), + ("SpRad", __CuvisReferenceType__["Reference_SpRad"]), + ("Distance", __CuvisReferenceType__["Reference_Distance"]), +}) + +DataType = dict({ + ("unsupported", __CuvisDataType__["data_type_unsupported"]), + ("image", __CuvisDataType__["data_type_image"]), + ("gps", __CuvisDataType__["data_type_gps"]), + ("string", __CuvisDataType__["data_type_string"]), + ("sensor_info", __CuvisDataType__["data_type_sensor_info"]), +}) + +TiffCompressionMode = dict({ + ("None", cuvis_il.tiff_compression_mode_None), + ("LZW", cuvis_il.tiff_compression_mode_LZW), +}) + +TiffFormat = dict({ + ("Single", cuvis_il.tiff_format_Single), + ("MultiChannel", cuvis_il.tiff_format_MultiChannel), + ("MultiPage", cuvis_il.tiff_format_MultiPage), +}) + +HardwareState = dict({ + ("Online", cuvis_il.hardware_state_online), + ("PartiallyOnline", cuvis_il.hardware_state_partially_online), + ("Offline", cuvis_il.hardware_state_offline), +}) + +OperationMode = dict({ + ("External", cuvis_il.OperationMode_External), + ("Internal", cuvis_il.OperationMode_Internal), + ("Software", cuvis_il.OperationMode_Software), + ("UNDEFINED", cuvis_il.OperationMode_Undefined), +}) + +ComponentType = dict({ + ("ImageSensor", cuvis_il.component_type_image_sensor), + ("MiscSensor", cuvis_il.component_type_misc_sensor), +}) + +AsyncResult = dict({ + ("overwritten", 2), + ("timeout", 1), + ("done", 0), + ("deferred", 3), +}) + +CUVIS_imbuffer_format = dict({ + ("imbuffer_format_uint8", cuvis_il.imbuffer_format_uint8), + ("imbuffer_format_uint16", cuvis_il.imbuffer_format_uint16), + ("imbuffer_format_uint32", cuvis_il.imbuffer_format_uint32), + ("imbuffer_format_float", cuvis_il.imbuffer_format_float), +}) + +CUVIS_capabilities = dict({ + ("AcquisitionCapture", cuvis_il.CUVIS_MODE_CAPABILITY_ACQUISITION_CAPTURE), + ("AcquisitionTimelapse", cuvis_il.CUVIS_MODE_CAPABILITY_ACQUISITION_TIMELAPSE), + ("AcquisitionContinuous", cuvis_il.CUVIS_MODE_CAPABILITY_ACQUISITION_CONTINUOUS), + ("AcquisitionSnapshot", cuvis_il.CUVIS_MODE_CAPABILITY_ACQUISITION_SNAPSHOT), + ("AcquisitionSetIntegrationtime", cuvis_il.CUVIS_MODE_CAPABILITY_ACQUISITION_SETINTEGRATIONTIME), + ("AcquisitionSetGain", cuvis_il.CUVIS_MODE_CAPABILITY_ACQUISITION_SETGAIN), + ("AcquisitionAveraging", cuvis_il.CUVIS_MODE_CAPABILITY_ACQUISITION_AVERAGING), + ("ProcessingSensorRaw", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_SENSOR_RAW), + ("ProcessingCubeRaw", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_RAW), + ("ProcessingCubeRef", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_REF), + ("ProcessingCubeDarkSubtract", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_DARKSUBTRACT), + ("ProcessingCubeFlatFielding", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_FLATFIELDING), + ("ProcessingCubeSpectralRadiance", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_SPECTRALRADIANCE), + ("ProcessingSaveFile", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_SAVE_FILE), + ("ProcessingClearRaw", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_CLEAR_RAW), + ("ProcessingCalcLive", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_CALC_LIVE), + ("ProcessingAutoExposure", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_AUTOEXPOSURE), + ("ProcessingOrientation", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_ORIENTATION), + ("ProcessingSetWhite", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_SET_WHITE), + ("ProcessingSetDark", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DARK), + ("ProcessingSetSprad", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_SET_SPRADCALIB), + ("ProcessingSetDistanceCalib", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCECALIB), + ("ProcessingSetDistanceValue", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCE_VALUE), + ("ProcessingUseDarkSpradcalib", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_USE_DARK_SPRADCALIB), + ("ProcessingUseWhiteSpradCalib", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_USE_WHITE_SPRADCALIB), + ("ProcessingRequireWhiteDarkReflectance", cuvis_il.CUVIS_MODE_CAPABILITY_PROCESSING_REQUIRE_WHITEDARK_REFLECTANCE), + ("UNDEFINED", 2**26), + +}) + + + + + diff --git a/Python/src/cuvis/examples/EX01_loadMeasurement.py b/Python/src/cuvis/examples/EX01_loadMeasurement.py new file mode 100644 index 0000000..ff82d0a --- /dev/null +++ b/Python/src/cuvis/examples/EX01_loadMeasurement.py @@ -0,0 +1,80 @@ +import os +import cuvis +import matplotlib.pyplot as plt +import numpy as np + +lib_dir = os.getenv("CUVIS") +data_dir = os.path.normpath(os.path.join(lib_dir, os.path.pardir, "sdk", "sample_data", "set1")) + + +def run_example_loadMeasurement(userSettingsDir=os.path.join(data_dir, "settings"), + measurementLoc=os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3")): + + print("loading user settings...") + settings = cuvis.General(userSettingsDir) + settings.setLogLevel("info") + + print("loading measurement file...") + mesu = cuvis.Measurement(measurementLoc) + print("Data 1 {} t={}ms mode={}".format(mesu.Name, + mesu.IntegrationTime, + mesu.ProcessingMode, + )) + + # TODO: use correct flags when Measurement provides them + if not isinstance(mesu.MeasurementFlags, list): + mesu.MeasurementFlags = [mesu.MeasurementFlags] + + if len(mesu.MeasurementFlags) > 0: + print("Flags") + for flag in mesu.MeasurementFlags: + print(" - {} ({})".format(flag, flag)) # TODO: just 0/1?! + + assert mesu.ProcessingMode == "Raw", \ + "This example requires Raw mode!" + + cube = mesu.Data.pop("cube", None) + if cube is None: + raise Exception("Cube not found") + + x = 120 + y = 200 + + assert x < cube.width, "x index exceeds cube width!" + assert y < cube.height, "y index exceeds cube height!" + + lambda_wl = [] + raw_counts = [] + for chn in np.arange(cube.channels): + lambda_wl.append(cube.wavelength[chn]) + raw_counts.append(cube.array[x, y, chn]) + + plt.plot(lambda_wl, raw_counts) + plt.xlabel("lambda [nm]") + plt.ylabel("raw counts [au]") + plt.title("Spectrum of {} for x={}, y={}".format(mesu.Name, x, y)) + plt.show() + + print("finished.") + pass + + +if __name__ == "__main__": + + print("Example 01: Load Measurement. Please provide:") + + def_input = os.path.join(data_dir, "settings") + userSettingsDir = input("User settings directory (default: {}): ".format(def_input)) + if userSettingsDir.strip().lower() in ["", "default"]: + userSettingsDir = def_input + + def_input = os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3") + measurementLoc = input("Measurement file (.cu3) (default: {}): ".format(def_input)) + if measurementLoc.strip().lower() in ["", "default"]: + measurementLoc = def_input + + run_example_loadMeasurement(userSettingsDir, measurementLoc) diff --git a/Python/src/cuvis/examples/EX02_reprocessMeasurement.py b/Python/src/cuvis/examples/EX02_reprocessMeasurement.py new file mode 100644 index 0000000..77b0331 --- /dev/null +++ b/Python/src/cuvis/examples/EX02_reprocessMeasurement.py @@ -0,0 +1,135 @@ +import os +import cuvis + + +lib_dir = os.getenv("CUVIS") +data_dir = os.path.normpath(os.path.join(lib_dir, os.path.pardir, "sdk", "sample_data", "set1")) + + +def run_example_reprocessMeasurement(userSettingsDir=os.path.join(data_dir, "settings"), + measurementLoc=os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3"), + darkLoc=os.path.join(data_dir, + "dark_000", + "dark_000_000_snapshot.cu3"), + whiteLoc=os.path.join(data_dir, + "white_000", + "white_000_000_snapshot.cu3"), + distanceLoc=os.path.join(data_dir, + "Calibration", + "distanceCalib__outside_000_002_snapshot16201220972486840.cu3"), + factoryDir=os.path.join(data_dir, "factory"), + outDir=os.path.join(os.getcwd(), "EX02")): + + print("loading user settings...") + settings = cuvis.General(userSettingsDir) + settings.setLogLevel("info") + + print("loading measurement file...") + mesu = cuvis.Measurement(measurementLoc) + + print("loading dark...") + dark = cuvis.Measurement(darkLoc) + print("loading white...") + white = cuvis.Measurement(whiteLoc) + print("loading dark...") + distance = cuvis.Measurement(distanceLoc) + + print("Data 1 {} t={}ms mode={}".format(mesu.Name, + mesu.IntegrationTime, + mesu.ProcessingMode, + )) + + print("loading calibration and processing context (factory)...") + calibration = cuvis.Calibration(calibdir=factoryDir) + processingContext = cuvis.ProcessingContext(calibration) + + print("set references...") + processingContext.setReference(dark, "Dark") + processingContext.setReference(white, "White") + processingContext.setReference(distance, "Distance") + + modes = ["Raw", + "DarkSubtract", + "Reflectance", + "SpectralRadiance" + ] + + procArgs = cuvis.CubertProcessingArgs() + saveArgs = cuvis.CubertSaveArgs(AllowOverwrite=True) + + for mode in modes: + + procArgs.ProcessingMode = mode + isCapable = processingContext.isCapable(mesu, procArgs) + + if isCapable: + print("processing to mode {}...".format(mode)) + processingContext.setProcessingArgs(procArgs) + mesu = processingContext.apply(mesu) + saveArgs.ExportDir = os.path.join(outDir, mode) + mesu.save(saveArgs) + + else: + print("Cannot process to {} mode!".format(mode)) + + print("finished.") + + pass + + +if __name__ == "__main__": + + print("Example 02: Reprocess Measurement. Please provide:") + + def_input = os.path.join(data_dir, "settings") + userSettingsDir = input("User settings directory (default: {}): ".format(def_input)) + if userSettingsDir.strip().lower() in ["", "default"]: + userSettingsDir = def_input + + def_input = os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3") + measurementLoc = input("Measurement file (.cu3) (default: {}): ".format(def_input)) + if measurementLoc.strip().lower() in ["", "default"]: + measurementLoc = def_input + + def_input = os.path.join(data_dir, + "dark_000", + "dark_000_000_snapshot.cu3") + darkLoc = input("Dark file (.cu3) (default: {}): ".format(def_input)) + if darkLoc.strip().lower() in ["", "default"]: + darkLoc = def_input + + def_input = os.path.join(data_dir, + "white_000", + "white_000_000_snapshot.cu3") + whiteLoc = input("White file (.cu3) (default: {}): ".format(def_input)) + if whiteLoc.strip().lower() in ["", "default"]: + whiteLoc = def_input + + def_input = os.path.join(data_dir, + "Calibration", + "distanceCalib__outside_000_002_snapshot16201220972486840.cu3") + distanceLoc = input("Distance file (.cu3) (default: {}): ".format(def_input)) + if distanceLoc.strip().lower() in ["", "default"]: + distanceLoc = def_input + + def_input = os.path.join(data_dir, "factory") + factoryDir = input("Factory directory (default: {}): ".format(def_input)) + if factoryDir.strip().lower() in ["", "default"]: + factoryDir = def_input + + def_input = os.path.join(os.getcwd(), "EX02") + outDir = input("Name of output directory (default: {}): ".format(def_input)) + if outDir.strip().lower() in ["", "default"]: + outDir = def_input + + run_example_reprocessMeasurement(userSettingsDir, + measurementLoc, + darkLoc, + whiteLoc, + distanceLoc, + factoryDir, + outDir) diff --git a/Python/src/cuvis/examples/EX03_exportMeasurement.py b/Python/src/cuvis/examples/EX03_exportMeasurement.py new file mode 100644 index 0000000..bc137ad --- /dev/null +++ b/Python/src/cuvis/examples/EX03_exportMeasurement.py @@ -0,0 +1,81 @@ +import os +import cuvis + +lib_dir = os.getenv("CUVIS") +data_dir = os.path.normpath(os.path.join(lib_dir, os.path.pardir, "sdk", "sample_data", "set1")) +plugin_dir = os.path.normpath(os.path.join(lib_dir, os.path.pardir, "sdk", "sample_data", "userplugin")) + + +def run_example_exportMeasurement(userSettingsDir=os.path.join(data_dir, "settings"), + measurementLoc=os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3"), + pluginLoc=os.path.join(plugin_dir, "cai.xml"), + exportDir=os.path.join(os.getcwd(), "EX03")): + + print("loading user settings...") + settings = cuvis.General(userSettingsDir) + settings.setLogLevel("info") + + print("loading measurement file...") + mesu = cuvis.Measurement(measurementLoc) + + assert mesu.ProcessingMode != "Preview", "Wrong processing mode: {}".format(mesu.ProcessingMode) + + print("Export to Envi...") + envi_settings = cuvis.EnviExportSettings(ExportDir=os.path.join(exportDir, "envi")) + enviExporter = cuvis.EnviExporter(envi_settings) + enviExporter.apply(mesu) + + print("Export to Multi-Channel Tiff...") + multi_tiff_settings = cuvis.TiffExportSettings(ExportDir=os.path.join(exportDir, "multi"), Format="MultiChannel") + multiTiffExporter = cuvis.TiffExporter(multi_tiff_settings) + multiTiffExporter.apply(mesu) + + print("Export to separate Tiffs...") + single_tiff_settings = cuvis.TiffExportSettings(ExportDir=os.path.join(exportDir, "single"), Format="Single") + singleTiffExporter = cuvis.TiffExporter(single_tiff_settings) + singleTiffExporter.apply(mesu) + + print("Export View to file...") + + with open(pluginLoc) as f: + userpluginCai = f.readlines() + userpluginCai = "".join(userpluginCai) + + view_export_settings = cuvis.ViewExportSettings(ExportDir=os.path.join(exportDir, "view"), Userplugin=userpluginCai) + # also view_export_settings = cuvis.ViewExportSettings(ExportDir=os.path.join(exportDir, "view"), + # Userplugin=pluginLoc) works! + viewExporter = cuvis.ViewExporter(view_export_settings) + viewExporter.apply(mesu) + + pass + + +if __name__ == "__main__": + + print("Example 03: Export Measurement. Please provide:") + + def_input = os.path.join(data_dir, "settings") + userSettingsDir = input("User settings directory (default: {}): ".format(def_input)) + if userSettingsDir.strip().lower() in ["", "default"]: + userSettingsDir = def_input + + def_input = os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3") + measurementLoc = input("Measurement file (.cu3) (default: {}): ".format(def_input)) + if measurementLoc.strip().lower() in ["", "default"]: + measurementLoc = def_input + + def_input = os.path.join(plugin_dir, "cai.xml") + pluginLoc = input("User plugin file (.xml) (default: {}): ".format(def_input)) + if pluginLoc.strip().lower() in ["", "default"]: + pluginLoc = def_input + + def_input = os.path.join(os.getcwd(), "EX03") + exportDir = input("Name of export directory (default: {}): ".format(def_input)) + if exportDir.strip().lower() in ["", "default"]: + exportDir = def_input + + run_example_exportMeasurement(userSettingsDir, measurementLoc, pluginLoc, exportDir) diff --git a/Python/src/cuvis/examples/EX04_changeDistance.py b/Python/src/cuvis/examples/EX04_changeDistance.py new file mode 100644 index 0000000..5d23b75 --- /dev/null +++ b/Python/src/cuvis/examples/EX04_changeDistance.py @@ -0,0 +1,82 @@ +import os +import cuvis + +lib_dir = os.getenv("CUVIS") +data_dir = os.path.normpath(os.path.join(lib_dir, os.path.pardir, "sdk", "sample_data", "set1")) + + +def run_example_changeDistance(userSettingsDir=os.path.join(data_dir, "settings"), + measurementLoc=os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3"), + factoryDir=os.path.join(data_dir, "factory"), + distance=1000, + exportDir=os.path.join(os.getcwd(), "EX04")): + + print("loading user settings...") + settings = cuvis.General(userSettingsDir) + settings.setLogLevel("info") + + print("loading measurement file...") + mesu = cuvis.Measurement(measurementLoc) + + print("Data 1 {} t={}ms mode={}".format(mesu.Name, + mesu.IntegrationTime, + mesu.ProcessingMode, + )) + + print("loading calibration and processing context (factory)...") + calibration = cuvis.Calibration(calibdir=factoryDir) + processingContext = cuvis.ProcessingContext(calibration) + + print("setting distance...") + processingContext.calcDistance(1000) + + processingContext.setProcessingMode("Raw") + + saveArgs = cuvis.CubertSaveArgs(ExportDir=exportDir, AllowOverwrite=True) + + assert processingContext.isCapable(mesu, processingContext.getProcessingArgs()) + + print("changing distance...") + processingContext.apply(mesu) + print("saving...") + mesu.save(saveArgs) + print("finished.") + + pass + + +if __name__ == "__main__": + + print("Example 04: Change distance. Please provide:") + + def_input = os.path.join(data_dir, "settings") + userSettingsDir = input("User settings directory (default: {}): ".format(def_input)) + if userSettingsDir.strip().lower() in ["", "default"]: + userSettingsDir = def_input + + def_input = os.path.join(data_dir, + "vegetation_000", + "vegetation_000_000_snapshot.cu3") + measurementLoc = input("Measurement file (.cu3) (default: {}): ".format(def_input)) + if measurementLoc.strip().lower() in ["", "default"]: + measurementLoc = def_input + + def_input = os.path.join(data_dir, "factory") + factoryDir = input("Factory directory (default: {}): ".format(def_input)) + if factoryDir.strip().lower() in ["", "default"]: + factoryDir = def_input + + def_input = 1000 + distance = input("New distance [mm] (default: {}): ".format(def_input)) + if distance.strip().lower() in ["", "default"]: + distance = def_input + distance = float(distance) + + def_input = os.path.join(os.getcwd(), "EX04") + exportDir = input("Name of export directory (default: {}): ".format(def_input)) + if exportDir.strip().lower() in ["", "default"]: + exportDir = def_input + + run_example_changeDistance(userSettingsDir, measurementLoc, factoryDir, distance, exportDir) diff --git a/Python/src/cuvis/examples/EX05_recordSingleImage.py b/Python/src/cuvis/examples/EX05_recordSingleImage.py new file mode 100644 index 0000000..7089023 --- /dev/null +++ b/Python/src/cuvis/examples/EX05_recordSingleImage.py @@ -0,0 +1,98 @@ +import cuvis +import time +import os +from datetime import timedelta +import sys + +lib_dir = os.getenv("CUVIS") +data_dir = os.path.normpath(os.path.join(lib_dir, os.path.pardir, "sdk", "sample_data", "set1")) + + +def run_example_recordSingleImage(userSettingsDir=os.path.join(data_dir, "settings"), + factoryDir=os.path.join(data_dir, "factory"), + recDir=os.path.join(os.getcwd(), "EX05"), + exposure=100, + nrImgs=10): + + print("loading user settings...") + settings = cuvis.General(userSettingsDir) + settings.setLogLevel("info") + + print("loading calibration, processing and acquisition context (factory)...") + calibration = cuvis.Calibration(calibdir=factoryDir) + processingContext = cuvis.ProcessingContext(calibration) + acquisitionContext = cuvis.AcquisitionContext(calibration) + + saveArgs = cuvis.CubertSaveArgs(ExportDir=recDir, AllowOverwrite=True, AllowSessionFile=False) + cubeExporter = cuvis.CubeExporter(saveArgs) + + while acquisitionContext.getState() == "Offline": + print(".", end="") + time.sleep(1) + print("\n") + + print("Camera is online") + acquisitionContext.setOperationMode("Software") + acquisitionContext.setIntegrationTime(exposure) + + print("Start recoding now") + for i in range(nrImgs): + print("Record image #{}/{} ... (async)".format(i + 1, nrImgs)) + am = acquisitionContext.capture() + res = am.get(timedelta(milliseconds=500)) + if res["Measurement"] is not None: + mesu = res["Measurement"] + + processingContext.apply(mesu) + cubeExporter.apply(mesu) + + print("done") + + del mesu + del am + else: + print("failed") + + del processingContext + del acquisitionContext + del cubeExporter + + print("finished.") + + pass + + +if __name__ == "__main__": + print("Example 05: Record single image. Please provide:") + + def_input = os.path.join(data_dir, "settings") + userSettingsDir = input("User settings directory (default: {}): ".format(def_input)) + if userSettingsDir.strip().lower() in ["", "default"]: + userSettingsDir = def_input + + def_input = os.path.join(data_dir, "factory") + factoryDir = input("Factory directory (default: {}): ".format(def_input)) + if factoryDir.strip().lower() in ["", "default"]: + factoryDir = def_input + + def_input = os.path.join(os.getcwd(), "EX05") + recDir = input("Name of recording directory (default: {}): ".format(def_input)) + if recDir.strip().lower() in ["", "default"]: + recDir = def_input + + def_input = 100 + exposure = input("Exposure/Integration time [ms] (default: {}): ".format(def_input)) + if exposure.strip().lower() in ["", "default"]: + exposure = def_input + exposure = int(exposure) + + def_input = 10 + nrImgs = input("Number of Images (default: {}): ".format(def_input)) + if nrImgs.strip().lower() in ["", "default"]: + nrImgs = def_input + nrImgs = int(nrImgs) + + run_example_recordSingleImage(userSettingsDir, factoryDir, recDir, exposure, nrImgs) + + while 1: + sys.exit(0) diff --git a/Python/src/cuvis/examples/EX06_recordVideo.py b/Python/src/cuvis/examples/EX06_recordVideo.py new file mode 100644 index 0000000..9c405da --- /dev/null +++ b/Python/src/cuvis/examples/EX06_recordVideo.py @@ -0,0 +1,143 @@ +import cuvis +import time +import os +from datetime import datetime, timedelta +import sys + +lib_dir = os.getenv("CUVIS") +data_dir = os.path.normpath(os.path.join(lib_dir, os.path.pardir, "sdk", "sample_data", "set1")) + + +def run_example_recordVideo(userSettingsDir=os.path.join(data_dir, "settings"), + factoryDir=os.path.join(data_dir, "factory"), + recDir=os.path.join(os.getcwd(), "EX06"), + exposure=100, + autoExp=False, + fps=2): + print("loading user settings...") + settings = cuvis.General(userSettingsDir) + settings.setLogLevel("info") + + print("loading calibration (factory)...") + calibration = cuvis.Calibration(calibdir=factoryDir) + + print("loading acquisition context...") + acquisitionContext = cuvis.AcquisitionContext(calibration) + session_info = {"Name": "video", "SequenceNumber": 0, "SessionNumber": 0} + acquisitionContext.setSessionInfo(session_info) + + print("prepare saving of measurements...") + saveArgs = cuvis.CubertSaveArgs(ExportDir=recDir, + AllowOverwrite=True, + AllowSessionFile=True, + FPS=fps, + OperationMode="Software") + + print("writing files to: {}".format(recDir)) + cubeExporter = cuvis.CubeExporter(saveArgs) + + print("prepare processing of measurements...") + processingContext = cuvis.ProcessingContext(calibration) + processingContext.setProcessingMode("Raw") + + print("Waiting for camera to come online...") + + while acquisitionContext.getState() == "Offline": + print(".", end="") + time.sleep(1) + print("\n") + + print("Component details:") + count = acquisitionContext.getComponentCount() + for i in range(count): + info = acquisitionContext.getComponentInfo(i) + isOnline = acquisitionContext.getOnline(i) + print("Component {} is {}".format(info.DisplayName, "online" if isOnline else "offline")) + print(" -- info: {}".format(info.SensorInfo)) + print(" -- use: {}".format(info.UserField)) + print(" -- pixelformat: {}".format(info.Pixelformat)) + + print("initializing hardware...") + acquisitionContext.setIntegrationTime(exposure) + acquisitionContext.setOperationMode("Internal") + acquisitionContext.setFPS(fps) + acquisitionContext.setAutoExp(autoExp) + acquisitionContext.setContinuous(True) + + print("configuring worker...") + workerSettings = cuvis.CubertWorkerSettings(KeepOutOfSequence=0, + PollInterval=10, + WorkerCount=0, + WorkerQueueSize=100) + worker = cuvis.Worker(workerSettings) + worker.setAcquisitionContext(acquisitionContext) + worker.setProcessingContext(processingContext) + worker.setExporter(cubeExporter) + + print("recording...! (will stop after 2 minutes)") + start = datetime.now() + while (datetime.now() - start) < timedelta(minutes=2): + + while 1: + if worker.hasNextResult(): + break + else: + time.sleep(0.001) + + workerContainer = worker.getNextResult() + if workerContainer["Measurement"].Data is not None: + print("current handle index: {}".format( + workerContainer["Measurement"].get_metadata()["session_info_sequence_no"])) + if worker.getQueueSize() == worker.getQueueUsed(): + print("worker queue is full! Main() loop can not keep up!") + break + if acquisitionContext.getQueueSize() == acquisitionContext.getQueueUsed(): + print("acquisition queue is full! Worker can not keep up!") + break + + print("acquisition stopped...") + acquisitionContext.setContinuous(False) + print("finished.") + + pass + + +if __name__ == "__main__": + print("Example 06: Record video file. Please provide:") + + def_input = os.path.join(data_dir, "settings") + userSettingsDir = input("User settings directory (default: {}): ".format(def_input)) + if userSettingsDir.strip().lower() in ["", "default"]: + userSettingsDir = def_input + + def_input = os.path.join(data_dir, "factory") + factoryDir = input("Factory directory (default: {}): ".format(def_input)) + if factoryDir.strip().lower() in ["", "default"]: + factoryDir = def_input + + def_input = os.path.join(os.getcwd(), "EX06") + recDir = input("Name of recording directory (default: {}): ".format(def_input)) + if recDir.strip().lower() in ["", "default"]: + recDir = def_input + + def_input = 100 + exposure = input("Exposure/Integration time [ms] (default: {}): ".format(def_input)) + if exposure.strip().lower() in ["", "default"]: + exposure = def_input + exposure = int(exposure) + + def_input = False + autoExp = input("Auto-exposure time [True/False] (default: {}): ".format(def_input)) + if autoExp.strip().lower() in ["", "default"]: + autoExp = def_input + + def_input = 2 + fps = input("Target frames per second (fps) (default: {}): ".format(def_input)) + if fps.strip().lower() in ["", "default"]: + fps = def_input + fps = int(fps) + + run_example_recordVideo(userSettingsDir, factoryDir, recDir, exposure, autoExp, fps) + + while 1: + sys.exit(0) diff --git a/Python/src/cuvis/examples/EX99_classification_experimental.py b/Python/src/cuvis/examples/EX99_classification_experimental.py new file mode 100644 index 0000000..689bc01 --- /dev/null +++ b/Python/src/cuvis/examples/EX99_classification_experimental.py @@ -0,0 +1,104 @@ +import cuvis.classificator as cuvClass +import os +from pprint import pprint + +if __name__ == '__main__': + Labeling = True + classi_dir = input("This is the Cuvis Classification Tool." + " \nTo get started please provide the path to the folder containing .cu3-files you want to label: ") + # classi_dir = r'M:\Evaluations\2022_08_18_Effilux_LED_Foods\cornflakes_and_noodles_000' + + + if os.path.exists(os.path.join(classi_dir, "labels", "cuvis_labels.csv")): + Labeling = False + + if Labeling: + lg = cuvClass.LabelingGUI() + lg.load_images(classi_dir) + labels_string = input("\nPlease provide a comma seperated list of all labels you want to use." + "Example: 'background, apple, orange, pineapple' \nYour lables: ") + # labels_string = r"Fruits,Background, Wood, Plastic, Paper, Metal" + lg.get_labels(labels_string) + lg.run() + + preprocessor_dict = { + "methods": [ + # {"INDICES": { + # "indices": ["simple_difference", "NDVI", "hNDVI", "simple_integral"], + # "choice": "closest", + # }}, + {"NORM": { + "direction": "Brightness" + }}, + # {"NORM": { + # "direction": "Channel" + # }}, + # {"SUBSET": { + # "wavelengths": [500, 520, 540, 560, 580, 600, 620, 640, 660, 680, 700, 720, 740, 760, 780, 800, 820, + # 840, 860], + # "choice": "closest" + # }}, + {"PCA": { + "number_of_componenents": 3 + }}, + ], + } + + model_dict = {"methods": + # [{"RndForrest": {"max_depth": 2,"random_state": 0, "n_jobs": -1}}] + # [{"DIST": {"from": "median"}}] + [{"KNN": {"k": 5, "weights": "distance", "algorithm": "auto", "n_jobs": -1}}] + + } + + postprocessor_dict = {"methods": + [{"Base": {"alpha": 0.3, + "threshold": 0.5, + "definity": 0.05, + "erode1": 0, + "dilate": 0, + "erode2": 0, + }}]} + + CC = cuvClass.CuvisClassificator(classi_dir=classi_dir) + CC.set_preprocessor(preprocessor_dict) + CC.set_model(model_dict) + CC.set_postprocessor(postprocessor_dict) + CC.build_pipeline() + CC.evaluate() + + CC.save("CuvisClassificator.pckl") + + CC2 = cuvClass.CuvisClassificator() + CC2.load(os.path.join(classi_dir, "CuvisClassificator.pckl")) + + res = CC2.predict( + r"C:\Users\benjamin.mueller\Documents\strawberries4brezel" + r"\strawberries_black_flat_angled_lights_foreign_000_007_snapshot.cu3") + + CC2.visualize(alpha=0.75, + scale=2.5, + save_path=r"C:\Users\benjamin.mueller\Documents\strawberries4brezel" + r"\strawberries_black_flat_angled_lights_foreign_000_007_snapshot.png") + + # pprint(res) + + # val = np.zeros(res[0]["orig_shape"]) - 999 + # prob = np.zeros(res[0]["orig_shape"]) + 0.9 # threshold + # for ind, i in enumerate(res[0]["labels"].items()): + # resprobs = i[1]["probabilities"] + # resprobs = resprobs.reshape(res[0]["orig_shape"]) + # val[prob < resprobs] = ind + # prob = np.maximum(prob, resprobs) + + # val = np.zeros(res[0]["orig_shape"]) + # for ind, i in enumerate(res[0]["labels"].items()): + # val = val + i[1]["mask"] * ind# + + # val[val == -999] = np.nan + + # plt.imshow(val, origin="lower", interpolation='nearest') + # plt.colorbar() + # plt.show() + + # results = CC.predict("new_image", post_process=False) diff --git a/Python/src/cuvis/examples/__init__.py b/Python/src/cuvis/examples/__init__.py new file mode 100644 index 0000000..3a6579e --- /dev/null +++ b/Python/src/cuvis/examples/__init__.py @@ -0,0 +1,7 @@ +from .EX01_loadMeasurement import run_example_loadMeasurement +from .EX02_reprocessMeasurement import run_example_reprocessMeasurement +from .EX03_exportMeasurement import run_example_exportMeasurement +from .EX04_changeDistance import run_example_changeDistance +from .EX05_recordSingleImage import run_example_recordSingleImage +from .EX06_recordVideo import run_example_recordVideo +# from .EX07_simpleGUI import run_example_simpleGUI diff --git a/Python/src/setup.py b/Python/src/setup.py new file mode 100644 index 0000000..abbdff8 --- /dev/null +++ b/Python/src/setup.py @@ -0,0 +1,65 @@ +from pathlib import Path +from setuptools import setup, find_packages, Extension +import os +import shutil + +name = 'cuvis' + +REQUIREMENTS = { + # Installation script (this file) dependencies + 'setup': [ + 'setuptools_scm', + ], + # Installation dependencies + # Use with pip install . to install from source + 'install': [ + 'Cpython', + 'setuptools < 64', + 'numpy >= 1.23', + 'matplotlib', + 'DateTime', + 'psutil', + 'xarray', + 'PyYAML', + 'scipy', + 'PySimpleGui', + 'opencv-python', + 'scikit-learn', + 'dill', + ], +} + +lib_dir = "" +if 'CUVIS' in os.environ: + lib_dir = os.getenv('CUVIS') + print('CUVIS SDK found at {}!'.format(lib_dir)) +else: + Exception('CUVIS SDK does not seem to exist on this machine! Make sure that the environment variable CUVIS is set.') + + +def __createManifest__(subdirs): + """inventory all files in path and create a manifest file""" + current = os.path.dirname(__file__) + relative_paths = [os.path.relpath(path, current) for path in subdirs] + with open(os.path.join(current, "MANIFEST.in"), "w") as manifest: + manifest.writelines("recursive-include {} *.pyd".format(" ".join(relative_paths))) + + +add_il = os.path.join(os.path.dirname(__file__), "cuvis") + +__createManifest__([add_il]) + +setup( + name=name, + python_requires='>= 3.9', + version='0.1', + packages=find_packages(), + url='https://www.cubert-hyperspectral.com/', + license='', + author='Ben Mueller @ Cubert GmbH, Ulm, Germany', + author_email='mueller@cubert-gmbh.com', + description='CUVIS Python SDK. Linked to the cuvis installation at {}.'.format(lib_dir), + setup_requires=REQUIREMENTS['setup'], + install_requires=REQUIREMENTS['install'], + include_package_data=True, +) From 0b2e67428128f08b2347362b8946b6ad982234db Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:28:37 +0100 Subject: [PATCH 02/12] Update README.md --- Python/README.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Python/README.md b/Python/README.md index acd9121..6440e2c 100644 --- a/Python/README.md +++ b/Python/README.md @@ -1,2 +1,11 @@ -In order to import cuvis to your CMake project, Cuvis must be installed. -Download the installer for windows or the .deb files for Ubuntu 20.04 here: https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 \ No newline at end of file +# CUVIS Python SDK + +Python Version: 3.9 + +## Installing Cuvis Python SDK via setup.py + +__In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here: +https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0__ + +After installing, check out the repository and copy the _cuvis_pyil file into *Cubert-Community-Hub\Python\src\cuvis\*. +Then navigate to *Cubert-Community-Hub\Python\src\* and run *python setup.py install* in the command line. From 56df33f0f9debf32fb06931fc3692f41b5dde293 Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:28:56 +0100 Subject: [PATCH 03/12] Update README.md --- Python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index 6440e2c..cc7e4ad 100644 --- a/Python/README.md +++ b/Python/README.md @@ -5,7 +5,7 @@ Python Version: 3.9 ## Installing Cuvis Python SDK via setup.py __In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here: -https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0__ +https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 __ After installing, check out the repository and copy the _cuvis_pyil file into *Cubert-Community-Hub\Python\src\cuvis\*. Then navigate to *Cubert-Community-Hub\Python\src\* and run *python setup.py install* in the command line. From 01c6ef9f4064230e8ebb3190e91477c1e796ef09 Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:29:09 +0100 Subject: [PATCH 04/12] Update README.md --- Python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index cc7e4ad..5a70c32 100644 --- a/Python/README.md +++ b/Python/README.md @@ -4,7 +4,7 @@ Python Version: 3.9 ## Installing Cuvis Python SDK via setup.py -__In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here: +__ In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here: https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 __ After installing, check out the repository and copy the _cuvis_pyil file into *Cubert-Community-Hub\Python\src\cuvis\*. From 93c2814f9702a162218a077ca090797d2837f554 Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:29:41 +0100 Subject: [PATCH 05/12] Update README.md --- Python/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/README.md b/Python/README.md index 5a70c32..81e034e 100644 --- a/Python/README.md +++ b/Python/README.md @@ -4,8 +4,8 @@ Python Version: 3.9 ## Installing Cuvis Python SDK via setup.py -__ In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here: -https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 __ +In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here: +https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 After installing, check out the repository and copy the _cuvis_pyil file into *Cubert-Community-Hub\Python\src\cuvis\*. Then navigate to *Cubert-Community-Hub\Python\src\* and run *python setup.py install* in the command line. From bfb390b8ed41c714cc8d125f2eb6abb38f6e3078 Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 11:30:56 +0100 Subject: [PATCH 06/12] Update README.md --- Python/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/README.md b/Python/README.md index 81e034e..53a5a02 100644 --- a/Python/README.md +++ b/Python/README.md @@ -4,8 +4,8 @@ Python Version: 3.9 ## Installing Cuvis Python SDK via setup.py -In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here: +__In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here:__ https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 -After installing, check out the repository and copy the _cuvis_pyil file into *Cubert-Community-Hub\Python\src\cuvis\*. +After installing, check out the repository and copy the *_cuvis_pyil* file into *Cubert-Community-Hub\Python\src\cuvis\*. Then navigate to *Cubert-Community-Hub\Python\src\* and run *python setup.py install* in the command line. From f8cf9a5353979c6c14c2b96785cd2d580629919a Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 12:10:08 +0100 Subject: [PATCH 07/12] Update README.md --- Python/README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Python/README.md b/Python/README.md index 53a5a02..1584f3c 100644 --- a/Python/README.md +++ b/Python/README.md @@ -4,8 +4,10 @@ Python Version: 3.9 ## Installing Cuvis Python SDK via setup.py -__In order to install the Python SDK, Cuvis must be installed. Download the installer for windows (or the .deb files for Ubuntu 20.04) and the _cuvis_pyil file here:__ +__In order to install the Python SDK, Cuvis must be installed. +Download the installer for windows (or the .deb files for Ubuntu 20.04) and the \_cuvis\_pyil file here:__ https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 -After installing, check out the repository and copy the *_cuvis_pyil* file into *Cubert-Community-Hub\Python\src\cuvis\*. -Then navigate to *Cubert-Community-Hub\Python\src\* and run *python setup.py install* in the command line. +After installing, check out the repository and copy the *\_cuvis\_pyil* file into *Cubert-Community-Hub\Python\src\cuvis*. + +Then navigate to *Cubert-Community-Hub\Python\src* and run *python setup.py install* in the command line. From f65ea3a33c5e83598945f3c558b2c2012445456c Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 12:17:59 +0100 Subject: [PATCH 08/12] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d8a67fa..a577f9f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Cubert Community Hub ### This is a place to collaborate on projects, that are being build upon the Cubert SDK and work with Cubert Hyperspectral Cameras. -The repository is aimed at students, researchers and professionals alike. It contains __everything you need__ to connect and integrate Cubert hyperspectral cameras into your processing pipeline in __various programming languages__. Even without a camera, you can start straight ahead with the __demo data provided__. +The repository is aimed at students, researchers and professionals alike. It contains __everything you need__ to connect and integrate __Cubert hyperspectral cameras__ into your processing pipeline in __various programming languages__. Even without a camera, you can start straight ahead with the __demo data provided__. Additionally it contains a __classification engine__ in python, designed to work efficiently and transparently on cubert hyperspectral data cubes. The engine lets you __train, process and evaluate__ your dataset and the resulting model can __easily be deployed__ in the field. From 7f37c4b04f6513b075632259a574cfcf160e1e40 Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 12:32:12 +0100 Subject: [PATCH 09/12] Update .gitignore --- .gitignore | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.gitignore b/.gitignore index e69de29..594076b 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,10 @@ +.pyd +*.o +*.orig +*.a +*.so +*.x +*.lib +*.exe +*.obj +cuvis_il.py From b17bda0d38e4e64000acc8bd09d3b5382da94522 Mon Sep 17 00:00:00 2001 From: "robert.briegel" Date: Wed, 8 Feb 2023 12:32:58 +0100 Subject: [PATCH 10/12] rm cuvis/cuvis_il.py --- Python/src/cuvis/cuvis_il.py | 1095 ---------------------------------- 1 file changed, 1095 deletions(-) delete mode 100644 Python/src/cuvis/cuvis_il.py diff --git a/Python/src/cuvis/cuvis_il.py b/Python/src/cuvis/cuvis_il.py deleted file mode 100644 index e24bb2f..0000000 --- a/Python/src/cuvis/cuvis_il.py +++ /dev/null @@ -1,1095 +0,0 @@ -# This file was automatically generated by SWIG (http://www.swig.org). -# Version 4.0.2 -# -# Do not make changes to this file unless you know what you are doing--modify -# the SWIG interface file instead. - -from sys import version_info as _swig_python_version_info -if _swig_python_version_info < (2, 7, 0): - raise RuntimeError("Python 2.7 or later required") - -# Import the low-level C/C++ module -if __package__ or "." in __name__: - from . import _cuvis_pyil -else: - import _cuvis_pyil - -try: - import builtins as __builtin__ -except ImportError: - import __builtin__ - -def _swig_repr(self): - try: - strthis = "proxy of " + self.this.__repr__() - except __builtin__.Exception: - strthis = "" - return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,) - - -def _swig_setattr_nondynamic_instance_variable(set): - def set_instance_attr(self, name, value): - if name == "thisown": - self.this.own(value) - elif name == "this": - set(self, name, value) - elif hasattr(self, name) and isinstance(getattr(type(self), name), property): - set(self, name, value) - else: - raise AttributeError("You cannot add instance attributes to %s" % self) - return set_instance_attr - - -def _swig_setattr_nondynamic_class_variable(set): - def set_class_attr(cls, name, value): - if hasattr(cls, name) and not isinstance(getattr(cls, name), property): - set(cls, name, value) - else: - raise AttributeError("You cannot add class attributes to %s" % cls) - return set_class_attr - - -def _swig_add_metaclass(metaclass): - """Class decorator for adding a metaclass to a SWIG wrapped class - a slimmed down version of six.add_metaclass""" - def wrapper(cls): - return metaclass(cls.__name__, cls.__bases__, cls.__dict__.copy()) - return wrapper - - -class _SwigNonDynamicMeta(type): - """Meta class to enforce nondynamic attributes (no new attributes) for a class""" - __setattr__ = _swig_setattr_nondynamic_class_variable(type.__setattr__) - - - -def cuvis_version_swig(): - return _cuvis_pyil.cuvis_version_swig() - -def cuvis_measurement_get_data_info_swig(i_mesu, o_pType, i_id): - return _cuvis_pyil.cuvis_measurement_get_data_info_swig(i_mesu, o_pType, i_id) - -def cuvis_measurement_get_data_string_swig(i_mesu, i_key): - return _cuvis_pyil.cuvis_measurement_get_data_string_swig(i_mesu, i_key) - -def new_p_int(): - return _cuvis_pyil.new_p_int() - -def copy_p_int(value): - return _cuvis_pyil.copy_p_int(value) - -def delete_p_int(obj): - return _cuvis_pyil.delete_p_int(obj) - -def p_int_assign(obj, value): - return _cuvis_pyil.p_int_assign(obj, value) - -def p_int_value(obj): - return _cuvis_pyil.p_int_value(obj) - -def new_p_double(): - return _cuvis_pyil.new_p_double() - -def copy_p_double(value): - return _cuvis_pyil.copy_p_double(value) - -def delete_p_double(obj): - return _cuvis_pyil.delete_p_double(obj) - -def p_double_assign(obj, value): - return _cuvis_pyil.p_double_assign(obj, value) - -def p_double_value(obj): - return _cuvis_pyil.p_double_value(obj) - -def new_p_unsigned_char(nelements): - return _cuvis_pyil.new_p_unsigned_char(nelements) - -def delete_p_unsigned_char(ary): - return _cuvis_pyil.delete_p_unsigned_char(ary) - -def p_unsigned_char_getitem(ary, index): - return _cuvis_pyil.p_unsigned_char_getitem(ary, index) - -def p_unsigned_char_setitem(ary, index, value): - return _cuvis_pyil.p_unsigned_char_setitem(ary, index, value) - -def new_p_unsigned_int(nelements): - return _cuvis_pyil.new_p_unsigned_int(nelements) - -def delete_p_unsigned_int(ary): - return _cuvis_pyil.delete_p_unsigned_int(ary) - -def p_unsigned_int_getitem(ary, index): - return _cuvis_pyil.p_unsigned_int_getitem(ary, index) - -def p_unsigned_int_setitem(ary, index, value): - return _cuvis_pyil.p_unsigned_int_setitem(ary, index, value) - -def cuvis_read_imbuf_uint8(imbuf): - return _cuvis_pyil.cuvis_read_imbuf_uint8(imbuf) - -def cuvis_read_imbuf_uint16(imbuf): - return _cuvis_pyil.cuvis_read_imbuf_uint16(imbuf) - -def cuvis_read_imbuf_uint32(imbuf): - return _cuvis_pyil.cuvis_read_imbuf_uint32(imbuf) - -def cuvis_read_imbuf_float32(imbuf): - return _cuvis_pyil.cuvis_read_imbuf_float32(imbuf) -CUVIS_MAXBUF = _cuvis_pyil.CUVIS_MAXBUF -CUVIS_MODE_CAPABILITY_ACQUISITION_CAPTURE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_CAPTURE -CUVIS_MODE_CAPABILITY_ACQUISITION_TIMELAPSE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_TIMELAPSE -CUVIS_MODE_CAPABILITY_ACQUISITION_CONTINUOUS = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_CONTINUOUS -CUVIS_MODE_CAPABILITY_ACQUISITION_SNAPSHOT = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_SNAPSHOT -CUVIS_MODE_CAPABILITY_ACQUISITION_SETINTEGRATIONTIME = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_SETINTEGRATIONTIME -CUVIS_MODE_CAPABILITY_ACQUISITION_SETGAIN = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_SETGAIN -CUVIS_MODE_CAPABILITY_ACQUISITION_AVERAGING = _cuvis_pyil.CUVIS_MODE_CAPABILITY_ACQUISITION_AVERAGING -CUVIS_MODE_CAPABILITY_PROCESSING_SENSOR_RAW = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SENSOR_RAW -CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_RAW = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_RAW -CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_REF = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_REF -CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_DARKSUBTRACT = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_DARKSUBTRACT -CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_FLATFIELDING = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_FLATFIELDING -CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_SPECTRALRADIANCE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CUBE_SPECTRALRADIANCE -CUVIS_MODE_CAPABILITY_PROCESSING_SAVE_FILE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SAVE_FILE -CUVIS_MODE_CAPABILITY_PROCESSING_CLEAR_RAW = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CLEAR_RAW -CUVIS_MODE_CAPABILITY_PROCESSING_CALC_LIVE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_CALC_LIVE -CUVIS_MODE_CAPABILITY_PROCESSING_AUTOEXPOSURE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_AUTOEXPOSURE -CUVIS_MODE_CAPABILITY_PROCESSING_ORIENTATION = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_ORIENTATION -CUVIS_MODE_CAPABILITY_PROCESSING_SET_WHITE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_WHITE -CUVIS_MODE_CAPABILITY_PROCESSING_SET_DARK = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DARK -CUVIS_MODE_CAPABILITY_PROCESSING_SET_SPRADCALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_SPRADCALIB -CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCECALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCECALIB -CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCE_VALUE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_SET_DISTANCE_VALUE -CUVIS_MODE_CAPABILITY_PROCESSING_USE_DARK_SPRADCALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_USE_DARK_SPRADCALIB -CUVIS_MODE_CAPABILITY_PROCESSING_USE_WHITE_SPRADCALIB = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_USE_WHITE_SPRADCALIB -CUVIS_MODE_CAPABILITY_PROCESSING_REQUIRE_WHITEDARK_REFLECTANCE = _cuvis_pyil.CUVIS_MODE_CAPABILITY_PROCESSING_REQUIRE_WHITEDARK_REFLECTANCE -AcquisitionCapture = _cuvis_pyil.AcquisitionCapture -AcquisitionTimelapse = _cuvis_pyil.AcquisitionTimelapse -AcquisitionContinuous = _cuvis_pyil.AcquisitionContinuous -AcquisitionSnapshot = _cuvis_pyil.AcquisitionSnapshot -AcquisitionSetIntegrationtime = _cuvis_pyil.AcquisitionSetIntegrationtime -AcquisitionSetGain = _cuvis_pyil.AcquisitionSetGain -AcquisitionAveraging = _cuvis_pyil.AcquisitionAveraging -ProcessingSensorRaw = _cuvis_pyil.ProcessingSensorRaw -ProcessingCubeRaw = _cuvis_pyil.ProcessingCubeRaw -ProcessingCubeRef = _cuvis_pyil.ProcessingCubeRef -ProcessingCubeDarkSubtract = _cuvis_pyil.ProcessingCubeDarkSubtract -ProcessingCubeFlatFielding = _cuvis_pyil.ProcessingCubeFlatFielding -ProcessingCubeSpectralRadiance = _cuvis_pyil.ProcessingCubeSpectralRadiance -ProcessingSaveFile = _cuvis_pyil.ProcessingSaveFile -ProcessingClearRaw = _cuvis_pyil.ProcessingClearRaw -ProcessingCalcLive = _cuvis_pyil.ProcessingCalcLive -ProcessingAutoExposure = _cuvis_pyil.ProcessingAutoExposure -ProcessingOrientation = _cuvis_pyil.ProcessingOrientation -ProcessingSetWhite = _cuvis_pyil.ProcessingSetWhite -ProcessingSetDark = _cuvis_pyil.ProcessingSetDark -ProcessingSetSprad = _cuvis_pyil.ProcessingSetSprad -ProcessingSetDistanceCalib = _cuvis_pyil.ProcessingSetDistanceCalib -ProcessingSetDistanceValue = _cuvis_pyil.ProcessingSetDistanceValue -ProcessingUseDarkSpradcalib = _cuvis_pyil.ProcessingUseDarkSpradcalib -ProcessingUseWhiteSpradCalib = _cuvis_pyil.ProcessingUseWhiteSpradCalib -ProcessingRequireWhiteDarkReflectance = _cuvis_pyil.ProcessingRequireWhiteDarkReflectance -CUVIS_MESU_FLAG_OVERILLUMINATED = _cuvis_pyil.CUVIS_MESU_FLAG_OVERILLUMINATED -CUVIS_MESU_FLAG_POOR_REFERENCE = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_REFERENCE -CUVIS_MESU_FLAG_POOR_WHITE_BALANCING = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_WHITE_BALANCING -CUVIS_MESU_FLAG_DARK_INTTIME = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_INTTIME -CUVIS_MESU_FLAG_DARK_TEMP = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_TEMP -CUVIS_MESU_FLAG_WHITE_INTTIME = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_INTTIME -CUVIS_MESU_FLAG_WHITE_TEMP = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_TEMP -CUVIS_MESU_FLAG_WHITEDARK_INTTIME = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_INTTIME -CUVIS_MESU_FLAG_WHITEDARK_TEMP = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_TEMP -CUVIS_MESU_CUBE_KEY = _cuvis_pyil.CUVIS_MESU_CUBE_KEY -CUVIS_MESU_PAN_KEY = _cuvis_pyil.CUVIS_MESU_PAN_KEY -CUVIS_MESU_GPS_KEY = _cuvis_pyil.CUVIS_MESU_GPS_KEY -CUVIS_MESU_PREVIEW_KEY = _cuvis_pyil.CUVIS_MESU_PREVIEW_KEY -CUVIS_MESU_DARKREF_KEY = _cuvis_pyil.CUVIS_MESU_DARKREF_KEY -CUVIS_MESU_WHITEREF_KEY = _cuvis_pyil.CUVIS_MESU_WHITEREF_KEY -CUVIS_MESU_WHITEDARKREF_KEY = _cuvis_pyil.CUVIS_MESU_WHITEDARKREF_KEY -CUVIS_MESU_FLAG_OVERILLUMINATED_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_OVERILLUMINATED_KEY -CUVIS_MESU_FLAG_POOR_REFERENCE_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_REFERENCE_KEY -CUVIS_MESU_FLAG_POOR_WHITE_BALANCING_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_POOR_WHITE_BALANCING_KEY -CUVIS_MESU_FLAG_DARK_INTTIME_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_INTTIME_KEY -CUVIS_MESU_FLAG_DARK_TEMP_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_DARK_TEMP_KEY -CUVIS_MESU_FLAG_WHITE_INTTIME_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_INTTIME_KEY -CUVIS_MESU_FLAG_WHITE_TEMP_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITE_TEMP_KEY -CUVIS_MESU_FLAG_WHITEDARK_INTTIME_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_INTTIME_KEY -CUVIS_MESU_FLAG_WHITEDARK_TEMP_KEY = _cuvis_pyil.CUVIS_MESU_FLAG_WHITEDARK_TEMP_KEY -CUVIS_MESU_CUBE_INFO_KEY = _cuvis_pyil.CUVIS_MESU_CUBE_INFO_KEY -CUVIS_MESU_PAN_INFO_KEY = _cuvis_pyil.CUVIS_MESU_PAN_INFO_KEY -CUVIS_MESU_INFO_OK = _cuvis_pyil.CUVIS_MESU_INFO_OK -CUVIS_MESU_INFO_OVERILLUMINATED = _cuvis_pyil.CUVIS_MESU_INFO_OVERILLUMINATED -CUVIS_MESU_INFO_BAD_PIXEL = _cuvis_pyil.CUVIS_MESU_INFO_BAD_PIXEL -CUVIS_MESU_INFO_OVERILLUMINATED_REFERENCE = _cuvis_pyil.CUVIS_MESU_INFO_OVERILLUMINATED_REFERENCE -CUVIS_MESU_INFO_UNDERFLOW_MEASUREMENT_MIN_DARK = _cuvis_pyil.CUVIS_MESU_INFO_UNDERFLOW_MEASUREMENT_MIN_DARK -CUVIS_MESU_INFO_UNDERFLOW_WHITE_MIN_DARK = _cuvis_pyil.CUVIS_MESU_INFO_UNDERFLOW_WHITE_MIN_DARK -CUVIS_MESU_INFO_REFERENCE_CALC_OVERFLOW = _cuvis_pyil.CUVIS_MESU_INFO_REFERENCE_CALC_OVERFLOW -CUVIS_MESU_INFO_INCOMPLETE = _cuvis_pyil.CUVIS_MESU_INFO_INCOMPLETE -status_ok = _cuvis_pyil.status_ok -status_error = _cuvis_pyil.status_error -status_deferred = _cuvis_pyil.status_deferred -status_overwritten = _cuvis_pyil.status_overwritten -status_timeout = _cuvis_pyil.status_timeout -status_no_measurement = _cuvis_pyil.status_no_measurement -status_not_available = _cuvis_pyil.status_not_available -status_not_processed = _cuvis_pyil.status_not_processed -status_not_stored = _cuvis_pyil.status_not_stored -status_no_view = _cuvis_pyil.status_no_view -hardware_state_offline = _cuvis_pyil.hardware_state_offline -hardware_state_partially_online = _cuvis_pyil.hardware_state_partially_online -hardware_state_online = _cuvis_pyil.hardware_state_online -loglevel_fatal = _cuvis_pyil.loglevel_fatal -loglevel_error = _cuvis_pyil.loglevel_error -loglevel_warning = _cuvis_pyil.loglevel_warning -loglevel_info = _cuvis_pyil.loglevel_info -loglevel_debug = _cuvis_pyil.loglevel_debug -imbuffer_format_uint8 = _cuvis_pyil.imbuffer_format_uint8 -imbuffer_format_uint16 = _cuvis_pyil.imbuffer_format_uint16 -imbuffer_format_uint32 = _cuvis_pyil.imbuffer_format_uint32 -imbuffer_format_float = _cuvis_pyil.imbuffer_format_float -data_type_unsupported = _cuvis_pyil.data_type_unsupported -data_type_image = _cuvis_pyil.data_type_image -data_type_gps = _cuvis_pyil.data_type_gps -data_type_string = _cuvis_pyil.data_type_string -data_type_sensor_info = _cuvis_pyil.data_type_sensor_info -Cube_Raw = _cuvis_pyil.Cube_Raw -Cube_DarkSubtract = _cuvis_pyil.Cube_DarkSubtract -Cube_Reflectance = _cuvis_pyil.Cube_Reflectance -Cube_SpectralRadiance = _cuvis_pyil.Cube_SpectralRadiance -Preview = _cuvis_pyil.Preview -Reference_Dark = _cuvis_pyil.Reference_Dark -Reference_White = _cuvis_pyil.Reference_White -Reference_WhiteDark = _cuvis_pyil.Reference_WhiteDark -Reference_SpRad = _cuvis_pyil.Reference_SpRad -Reference_Distance = _cuvis_pyil.Reference_Distance -OperationMode_Software = _cuvis_pyil.OperationMode_Software -OperationMode_Internal = _cuvis_pyil.OperationMode_Internal -OperationMode_External = _cuvis_pyil.OperationMode_External -OperationMode_Undefined = _cuvis_pyil.OperationMode_Undefined -pan_sharpening_interpolation_type_NearestNeighbor = _cuvis_pyil.pan_sharpening_interpolation_type_NearestNeighbor -pan_sharpening_interpolation_type_Linear = _cuvis_pyil.pan_sharpening_interpolation_type_Linear -pan_sharpening_interpolation_type_Cubic = _cuvis_pyil.pan_sharpening_interpolation_type_Cubic -pan_sharpening_interpolation_type_Lanczos = _cuvis_pyil.pan_sharpening_interpolation_type_Lanczos -pan_sharpening_algorithm_Noop = _cuvis_pyil.pan_sharpening_algorithm_Noop -pan_sharpening_algorithm_CubertMacroPixel = _cuvis_pyil.pan_sharpening_algorithm_CubertMacroPixel -pan_sharpening_algorithm_CubertPanRatio = _cuvis_pyil.pan_sharpening_algorithm_CubertPanRatio -tiff_compression_mode_None = _cuvis_pyil.tiff_compression_mode_None -tiff_compression_mode_LZW = _cuvis_pyil.tiff_compression_mode_LZW -tiff_format_Single = _cuvis_pyil.tiff_format_Single -tiff_format_MultiChannel = _cuvis_pyil.tiff_format_MultiChannel -tiff_format_MultiPage = _cuvis_pyil.tiff_format_MultiPage -view_category_image = _cuvis_pyil.view_category_image -view_category_data = _cuvis_pyil.view_category_data -component_type_image_sensor = _cuvis_pyil.component_type_image_sensor -component_type_misc_sensor = _cuvis_pyil.component_type_misc_sensor -class cuvis_imbuffer_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - raw = property(_cuvis_pyil.cuvis_imbuffer_t_raw_get, _cuvis_pyil.cuvis_imbuffer_t_raw_set) - bytes = property(_cuvis_pyil.cuvis_imbuffer_t_bytes_get, _cuvis_pyil.cuvis_imbuffer_t_bytes_set) - length = property(_cuvis_pyil.cuvis_imbuffer_t_length_get, _cuvis_pyil.cuvis_imbuffer_t_length_set) - width = property(_cuvis_pyil.cuvis_imbuffer_t_width_get, _cuvis_pyil.cuvis_imbuffer_t_width_set) - height = property(_cuvis_pyil.cuvis_imbuffer_t_height_get, _cuvis_pyil.cuvis_imbuffer_t_height_set) - channels = property(_cuvis_pyil.cuvis_imbuffer_t_channels_get, _cuvis_pyil.cuvis_imbuffer_t_channels_set) - format = property(_cuvis_pyil.cuvis_imbuffer_t_format_get, _cuvis_pyil.cuvis_imbuffer_t_format_set) - wavelength = property(_cuvis_pyil.cuvis_imbuffer_t_wavelength_get, _cuvis_pyil.cuvis_imbuffer_t_wavelength_set) - - def __init__(self): - _cuvis_pyil.cuvis_imbuffer_t_swiginit(self, _cuvis_pyil.new_cuvis_imbuffer_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_imbuffer_t - -# Register cuvis_imbuffer_t in _cuvis_pyil: -_cuvis_pyil.cuvis_imbuffer_t_swigregister(cuvis_imbuffer_t) - -class cuvis_sensor_info_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - averages = property(_cuvis_pyil.cuvis_sensor_info_t_averages_get, _cuvis_pyil.cuvis_sensor_info_t_averages_set) - temperature = property(_cuvis_pyil.cuvis_sensor_info_t_temperature_get, _cuvis_pyil.cuvis_sensor_info_t_temperature_set) - gain = property(_cuvis_pyil.cuvis_sensor_info_t_gain_get, _cuvis_pyil.cuvis_sensor_info_t_gain_set) - readout_time = property(_cuvis_pyil.cuvis_sensor_info_t_readout_time_get, _cuvis_pyil.cuvis_sensor_info_t_readout_time_set) - - def __init__(self): - _cuvis_pyil.cuvis_sensor_info_t_swiginit(self, _cuvis_pyil.new_cuvis_sensor_info_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_sensor_info_t - -# Register cuvis_sensor_info_t in _cuvis_pyil: -_cuvis_pyil.cuvis_sensor_info_t_swigregister(cuvis_sensor_info_t) - -class cuvis_gps_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - longitude = property(_cuvis_pyil.cuvis_gps_t_longitude_get, _cuvis_pyil.cuvis_gps_t_longitude_set) - latitude = property(_cuvis_pyil.cuvis_gps_t_latitude_get, _cuvis_pyil.cuvis_gps_t_latitude_set) - altitude = property(_cuvis_pyil.cuvis_gps_t_altitude_get, _cuvis_pyil.cuvis_gps_t_altitude_set) - time = property(_cuvis_pyil.cuvis_gps_t_time_get, _cuvis_pyil.cuvis_gps_t_time_set) - - def __init__(self): - _cuvis_pyil.cuvis_gps_t_swiginit(self, _cuvis_pyil.new_cuvis_gps_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_gps_t - -# Register cuvis_gps_t in _cuvis_pyil: -_cuvis_pyil.cuvis_gps_t_swigregister(cuvis_gps_t) - -class cuvis_session_info_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - name = property(_cuvis_pyil.cuvis_session_info_t_name_get, _cuvis_pyil.cuvis_session_info_t_name_set) - session_no = property(_cuvis_pyil.cuvis_session_info_t_session_no_get, _cuvis_pyil.cuvis_session_info_t_session_no_set) - sequence_no = property(_cuvis_pyil.cuvis_session_info_t_sequence_no_get, _cuvis_pyil.cuvis_session_info_t_sequence_no_set) - - def __init__(self): - _cuvis_pyil.cuvis_session_info_t_swiginit(self, _cuvis_pyil.new_cuvis_session_info_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_session_info_t - -# Register cuvis_session_info_t in _cuvis_pyil: -_cuvis_pyil.cuvis_session_info_t_swigregister(cuvis_session_info_t) - -class cuvis_mesu_metadata_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - name = property(_cuvis_pyil.cuvis_mesu_metadata_t_name_get, _cuvis_pyil.cuvis_mesu_metadata_t_name_set) - path = property(_cuvis_pyil.cuvis_mesu_metadata_t_path_get, _cuvis_pyil.cuvis_mesu_metadata_t_path_set) - comment = property(_cuvis_pyil.cuvis_mesu_metadata_t_comment_get, _cuvis_pyil.cuvis_mesu_metadata_t_comment_set) - capture_time = property(_cuvis_pyil.cuvis_mesu_metadata_t_capture_time_get, _cuvis_pyil.cuvis_mesu_metadata_t_capture_time_set) - factory_calibration = property(_cuvis_pyil.cuvis_mesu_metadata_t_factory_calibration_get, _cuvis_pyil.cuvis_mesu_metadata_t_factory_calibration_set) - product_name = property(_cuvis_pyil.cuvis_mesu_metadata_t_product_name_get, _cuvis_pyil.cuvis_mesu_metadata_t_product_name_set) - serial_number = property(_cuvis_pyil.cuvis_mesu_metadata_t_serial_number_get, _cuvis_pyil.cuvis_mesu_metadata_t_serial_number_set) - assembly = property(_cuvis_pyil.cuvis_mesu_metadata_t_assembly_get, _cuvis_pyil.cuvis_mesu_metadata_t_assembly_set) - integration_time = property(_cuvis_pyil.cuvis_mesu_metadata_t_integration_time_get, _cuvis_pyil.cuvis_mesu_metadata_t_integration_time_set) - averages = property(_cuvis_pyil.cuvis_mesu_metadata_t_averages_get, _cuvis_pyil.cuvis_mesu_metadata_t_averages_set) - session_info_name = property(_cuvis_pyil.cuvis_mesu_metadata_t_session_info_name_get, _cuvis_pyil.cuvis_mesu_metadata_t_session_info_name_set) - session_info_session_no = property(_cuvis_pyil.cuvis_mesu_metadata_t_session_info_session_no_get, _cuvis_pyil.cuvis_mesu_metadata_t_session_info_session_no_set) - session_info_sequence_no = property(_cuvis_pyil.cuvis_mesu_metadata_t_session_info_sequence_no_get, _cuvis_pyil.cuvis_mesu_metadata_t_session_info_sequence_no_set) - processing_mode = property(_cuvis_pyil.cuvis_mesu_metadata_t_processing_mode_get, _cuvis_pyil.cuvis_mesu_metadata_t_processing_mode_set) - measurement_flags = property(_cuvis_pyil.cuvis_mesu_metadata_t_measurement_flags_get, _cuvis_pyil.cuvis_mesu_metadata_t_measurement_flags_set) - - def __init__(self): - _cuvis_pyil.cuvis_mesu_metadata_t_swiginit(self, _cuvis_pyil.new_cuvis_mesu_metadata_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_mesu_metadata_t - -# Register cuvis_mesu_metadata_t in _cuvis_pyil: -_cuvis_pyil.cuvis_mesu_metadata_t_swigregister(cuvis_mesu_metadata_t) - -class cuvis_save_args_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - allow_fragmentation = property(_cuvis_pyil.cuvis_save_args_t_allow_fragmentation_get, _cuvis_pyil.cuvis_save_args_t_allow_fragmentation_set) - allow_overwrite = property(_cuvis_pyil.cuvis_save_args_t_allow_overwrite_get, _cuvis_pyil.cuvis_save_args_t_allow_overwrite_set) - allow_drop = property(_cuvis_pyil.cuvis_save_args_t_allow_drop_get, _cuvis_pyil.cuvis_save_args_t_allow_drop_set) - allow_session_file = property(_cuvis_pyil.cuvis_save_args_t_allow_session_file_get, _cuvis_pyil.cuvis_save_args_t_allow_session_file_set) - allow_info_file = property(_cuvis_pyil.cuvis_save_args_t_allow_info_file_get, _cuvis_pyil.cuvis_save_args_t_allow_info_file_set) - operation_mode = property(_cuvis_pyil.cuvis_save_args_t_operation_mode_get, _cuvis_pyil.cuvis_save_args_t_operation_mode_set) - fps = property(_cuvis_pyil.cuvis_save_args_t_fps_get, _cuvis_pyil.cuvis_save_args_t_fps_set) - soft_limit = property(_cuvis_pyil.cuvis_save_args_t_soft_limit_get, _cuvis_pyil.cuvis_save_args_t_soft_limit_set) - hard_limit = property(_cuvis_pyil.cuvis_save_args_t_hard_limit_get, _cuvis_pyil.cuvis_save_args_t_hard_limit_set) - max_buftime = property(_cuvis_pyil.cuvis_save_args_t_max_buftime_get, _cuvis_pyil.cuvis_save_args_t_max_buftime_set) - - def __init__(self): - _cuvis_pyil.cuvis_save_args_t_swiginit(self, _cuvis_pyil.new_cuvis_save_args_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_save_args_t - -# Register cuvis_save_args_t in _cuvis_pyil: -_cuvis_pyil.cuvis_save_args_t_swigregister(cuvis_save_args_t) - -class cuvis_proc_args_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - processing_mode = property(_cuvis_pyil.cuvis_proc_args_t_processing_mode_get, _cuvis_pyil.cuvis_proc_args_t_processing_mode_set) - allow_recalib = property(_cuvis_pyil.cuvis_proc_args_t_allow_recalib_get, _cuvis_pyil.cuvis_proc_args_t_allow_recalib_set) - - def __init__(self): - _cuvis_pyil.cuvis_proc_args_t_swiginit(self, _cuvis_pyil.new_cuvis_proc_args_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_proc_args_t - -# Register cuvis_proc_args_t in _cuvis_pyil: -_cuvis_pyil.cuvis_proc_args_t_swigregister(cuvis_proc_args_t) - -class cuvis_export_general_settings_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - export_dir = property(_cuvis_pyil.cuvis_export_general_settings_t_export_dir_get, _cuvis_pyil.cuvis_export_general_settings_t_export_dir_set) - channel_selection = property(_cuvis_pyil.cuvis_export_general_settings_t_channel_selection_get, _cuvis_pyil.cuvis_export_general_settings_t_channel_selection_set) - spectra_multiplier = property(_cuvis_pyil.cuvis_export_general_settings_t_spectra_multiplier_get, _cuvis_pyil.cuvis_export_general_settings_t_spectra_multiplier_set) - pan_scale = property(_cuvis_pyil.cuvis_export_general_settings_t_pan_scale_get, _cuvis_pyil.cuvis_export_general_settings_t_pan_scale_set) - pan_interpolation_type = property(_cuvis_pyil.cuvis_export_general_settings_t_pan_interpolation_type_get, _cuvis_pyil.cuvis_export_general_settings_t_pan_interpolation_type_set) - pan_algorithm = property(_cuvis_pyil.cuvis_export_general_settings_t_pan_algorithm_get, _cuvis_pyil.cuvis_export_general_settings_t_pan_algorithm_set) - add_pan = property(_cuvis_pyil.cuvis_export_general_settings_t_add_pan_get, _cuvis_pyil.cuvis_export_general_settings_t_add_pan_set) - add_fullscale_pan = property(_cuvis_pyil.cuvis_export_general_settings_t_add_fullscale_pan_get, _cuvis_pyil.cuvis_export_general_settings_t_add_fullscale_pan_set) - permissive = property(_cuvis_pyil.cuvis_export_general_settings_t_permissive_get, _cuvis_pyil.cuvis_export_general_settings_t_permissive_set) - - def __init__(self): - _cuvis_pyil.cuvis_export_general_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_export_general_settings_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_export_general_settings_t - -# Register cuvis_export_general_settings_t in _cuvis_pyil: -_cuvis_pyil.cuvis_export_general_settings_t_swigregister(cuvis_export_general_settings_t) - -class cuvis_export_view_settings_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - userplugin = property(_cuvis_pyil.cuvis_export_view_settings_t_userplugin_get, _cuvis_pyil.cuvis_export_view_settings_t_userplugin_set) - - def __init__(self): - _cuvis_pyil.cuvis_export_view_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_export_view_settings_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_export_view_settings_t - -# Register cuvis_export_view_settings_t in _cuvis_pyil: -_cuvis_pyil.cuvis_export_view_settings_t_swigregister(cuvis_export_view_settings_t) - -class cuvis_export_tiff_settings_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - compression_mode = property(_cuvis_pyil.cuvis_export_tiff_settings_t_compression_mode_get, _cuvis_pyil.cuvis_export_tiff_settings_t_compression_mode_set) - format = property(_cuvis_pyil.cuvis_export_tiff_settings_t_format_get, _cuvis_pyil.cuvis_export_tiff_settings_t_format_set) - - def __init__(self): - _cuvis_pyil.cuvis_export_tiff_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_export_tiff_settings_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_export_tiff_settings_t - -# Register cuvis_export_tiff_settings_t in _cuvis_pyil: -_cuvis_pyil.cuvis_export_tiff_settings_t_swigregister(cuvis_export_tiff_settings_t) - -class cuvis_viewer_settings_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - userplugin = property(_cuvis_pyil.cuvis_viewer_settings_t_userplugin_get, _cuvis_pyil.cuvis_viewer_settings_t_userplugin_set) - pan_scale = property(_cuvis_pyil.cuvis_viewer_settings_t_pan_scale_get, _cuvis_pyil.cuvis_viewer_settings_t_pan_scale_set) - pan_interpolation_type = property(_cuvis_pyil.cuvis_viewer_settings_t_pan_interpolation_type_get, _cuvis_pyil.cuvis_viewer_settings_t_pan_interpolation_type_set) - pan_algorithm = property(_cuvis_pyil.cuvis_viewer_settings_t_pan_algorithm_get, _cuvis_pyil.cuvis_viewer_settings_t_pan_algorithm_set) - complete = property(_cuvis_pyil.cuvis_viewer_settings_t_complete_get, _cuvis_pyil.cuvis_viewer_settings_t_complete_set) - - def __init__(self): - _cuvis_pyil.cuvis_viewer_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_viewer_settings_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_viewer_settings_t - -# Register cuvis_viewer_settings_t in _cuvis_pyil: -_cuvis_pyil.cuvis_viewer_settings_t_swigregister(cuvis_viewer_settings_t) - -class cuvis_view_data_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - id = property(_cuvis_pyil.cuvis_view_data_t_id_get, _cuvis_pyil.cuvis_view_data_t_id_set) - category = property(_cuvis_pyil.cuvis_view_data_t_category_get, _cuvis_pyil.cuvis_view_data_t_category_set) - data = property(_cuvis_pyil.cuvis_view_data_t_data_get, _cuvis_pyil.cuvis_view_data_t_data_set) - show = property(_cuvis_pyil.cuvis_view_data_t_show_get, _cuvis_pyil.cuvis_view_data_t_show_set) - - def __init__(self): - _cuvis_pyil.cuvis_view_data_t_swiginit(self, _cuvis_pyil.new_cuvis_view_data_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_view_data_t - -# Register cuvis_view_data_t in _cuvis_pyil: -_cuvis_pyil.cuvis_view_data_t_swigregister(cuvis_view_data_t) - -class cuvis_component_info_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - type = property(_cuvis_pyil.cuvis_component_info_t_type_get, _cuvis_pyil.cuvis_component_info_t_type_set) - displayname = property(_cuvis_pyil.cuvis_component_info_t_displayname_get, _cuvis_pyil.cuvis_component_info_t_displayname_set) - sensorinfo = property(_cuvis_pyil.cuvis_component_info_t_sensorinfo_get, _cuvis_pyil.cuvis_component_info_t_sensorinfo_set) - userfield = property(_cuvis_pyil.cuvis_component_info_t_userfield_get, _cuvis_pyil.cuvis_component_info_t_userfield_set) - pixelformat = property(_cuvis_pyil.cuvis_component_info_t_pixelformat_get, _cuvis_pyil.cuvis_component_info_t_pixelformat_set) - - def __init__(self): - _cuvis_pyil.cuvis_component_info_t_swiginit(self, _cuvis_pyil.new_cuvis_component_info_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_component_info_t - -# Register cuvis_component_info_t in _cuvis_pyil: -_cuvis_pyil.cuvis_component_info_t_swigregister(cuvis_component_info_t) - -class cuvis_event_base_data_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - event_id = property(_cuvis_pyil.cuvis_event_base_data_t_event_id_get, _cuvis_pyil.cuvis_event_base_data_t_event_id_set) - - def __init__(self): - _cuvis_pyil.cuvis_event_base_data_t_swiginit(self, _cuvis_pyil.new_cuvis_event_base_data_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_base_data_t - -# Register cuvis_event_base_data_t in _cuvis_pyil: -_cuvis_pyil.cuvis_event_base_data_t_swigregister(cuvis_event_base_data_t) - -class cuvis_event_acquisition_data_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - source = property(_cuvis_pyil.cuvis_event_acquisition_data_t_source_get, _cuvis_pyil.cuvis_event_acquisition_data_t_source_set) - - def __init__(self): - _cuvis_pyil.cuvis_event_acquisition_data_t_swiginit(self, _cuvis_pyil.new_cuvis_event_acquisition_data_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_acquisition_data_t - -# Register cuvis_event_acquisition_data_t in _cuvis_pyil: -_cuvis_pyil.cuvis_event_acquisition_data_t_swigregister(cuvis_event_acquisition_data_t) - -class cuvis_event_processing_event_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - source = property(_cuvis_pyil.cuvis_event_processing_event_t_source_get, _cuvis_pyil.cuvis_event_processing_event_t_source_set) - - def __init__(self): - _cuvis_pyil.cuvis_event_processing_event_t_swiginit(self, _cuvis_pyil.new_cuvis_event_processing_event_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_processing_event_t - -# Register cuvis_event_processing_event_t in _cuvis_pyil: -_cuvis_pyil.cuvis_event_processing_event_t_swigregister(cuvis_event_processing_event_t) - -class cuvis_event_qualitiy_event_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - source = property(_cuvis_pyil.cuvis_event_qualitiy_event_t_source_get, _cuvis_pyil.cuvis_event_qualitiy_event_t_source_set) - - def __init__(self): - _cuvis_pyil.cuvis_event_qualitiy_event_t_swiginit(self, _cuvis_pyil.new_cuvis_event_qualitiy_event_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_qualitiy_event_t - -# Register cuvis_event_qualitiy_event_t in _cuvis_pyil: -_cuvis_pyil.cuvis_event_qualitiy_event_t_swigregister(cuvis_event_qualitiy_event_t) - -class cuvis_event_component_data_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - compent_id = property(_cuvis_pyil.cuvis_event_component_data_t_compent_id_get, _cuvis_pyil.cuvis_event_component_data_t_compent_id_set) - - def __init__(self): - _cuvis_pyil.cuvis_event_component_data_t_swiginit(self, _cuvis_pyil.new_cuvis_event_component_data_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_event_component_data_t - -# Register cuvis_event_component_data_t in _cuvis_pyil: -_cuvis_pyil.cuvis_event_component_data_t_swigregister(cuvis_event_component_data_t) - -class cuvis_worker_settings_t(object): - thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") - __repr__ = _swig_repr - worker_count = property(_cuvis_pyil.cuvis_worker_settings_t_worker_count_get, _cuvis_pyil.cuvis_worker_settings_t_worker_count_set) - poll_interval = property(_cuvis_pyil.cuvis_worker_settings_t_poll_interval_get, _cuvis_pyil.cuvis_worker_settings_t_poll_interval_set) - keep_out_of_sequence = property(_cuvis_pyil.cuvis_worker_settings_t_keep_out_of_sequence_get, _cuvis_pyil.cuvis_worker_settings_t_keep_out_of_sequence_set) - worker_queue_size = property(_cuvis_pyil.cuvis_worker_settings_t_worker_queue_size_get, _cuvis_pyil.cuvis_worker_settings_t_worker_queue_size_set) - - def __init__(self): - _cuvis_pyil.cuvis_worker_settings_t_swiginit(self, _cuvis_pyil.new_cuvis_worker_settings_t()) - __swig_destroy__ = _cuvis_pyil.delete_cuvis_worker_settings_t - -# Register cuvis_worker_settings_t in _cuvis_pyil: -_cuvis_pyil.cuvis_worker_settings_t_swigregister(cuvis_worker_settings_t) - -CUVIS_EVENT_PROCESSING = _cuvis_pyil.CUVIS_EVENT_PROCESSING -CUVIS_EVENT_ACQUISTION = _cuvis_pyil.CUVIS_EVENT_ACQUISTION -CUVIS_EVENT_COMPONENT = _cuvis_pyil.CUVIS_EVENT_COMPONENT -CUVIS_EVENT_TRIGGER_SKIPPED = _cuvis_pyil.CUVIS_EVENT_TRIGGER_SKIPPED - -def cuvis_event_get_acquisition_data(i_event, o_p_acquisition_data): - return _cuvis_pyil.cuvis_event_get_acquisition_data(i_event, o_p_acquisition_data) - -def cuvis_register_external_event_callback(i_callback, i_type, o_p_handler_id): - return _cuvis_pyil.cuvis_register_external_event_callback(i_callback, i_type, o_p_handler_id) - -def cuvis_unregister_event_callback(i_handler_id): - return _cuvis_pyil.cuvis_unregister_event_callback(i_handler_id) - -def cuvis_get_last_error_msg(): - return _cuvis_pyil.cuvis_get_last_error_msg() - -def cuvis_set_last_error_locale(id): - return _cuvis_pyil.cuvis_set_last_error_locale(id) - -def cuvis_get_last_error_msg_localized(): - return _cuvis_pyil.cuvis_get_last_error_msg_localized() - -def cuvis_set_log_level(level): - return _cuvis_pyil.cuvis_set_log_level(level) - -def cuvis_register_log_callback(i_callback, i_min_level): - return _cuvis_pyil.cuvis_register_log_callback(i_callback, i_min_level) - -def cuvis_reset_log_callback(): - return _cuvis_pyil.cuvis_reset_log_callback() - -def cuvis_register_log_callback_localized(i_callback_localized, i_min_level, i_locale_id): - return _cuvis_pyil.cuvis_register_log_callback_localized(i_callback_localized, i_min_level, i_locale_id) - -def cuvis_reset_log_callback_localized(): - return _cuvis_pyil.cuvis_reset_log_callback_localized() - -def cuvis_init(i_settings_path): - return _cuvis_pyil.cuvis_init(i_settings_path) - -def cuvis_async_call_get(io_pAsyncResult, timeout_ms): - return _cuvis_pyil.cuvis_async_call_get(io_pAsyncResult, timeout_ms) - -def cuvis_async_capture_free(io_pAsyncResult): - return _cuvis_pyil.cuvis_async_capture_free(io_pAsyncResult) - -def cuvis_async_call_free(io_pAsyncResult): - return _cuvis_pyil.cuvis_async_call_free(io_pAsyncResult) - -def cuvis_acq_cont_capture(i_acqCont, o_pMesu, timeout_ms): - return _cuvis_pyil.cuvis_acq_cont_capture(i_acqCont, o_pMesu, timeout_ms) - -def cuvis_acq_cont_capture_async(i_acqCont, o_pAsyncResult): - return _cuvis_pyil.cuvis_acq_cont_capture_async(i_acqCont, o_pAsyncResult) - -def cuvis_async_capture_get(io_pAsyncResult, timeout_ms, o_pMesu): - return _cuvis_pyil.cuvis_async_capture_get(io_pAsyncResult, timeout_ms, o_pMesu) - -def cuvis_measurement_load(i_path, o_pMesu): - return _cuvis_pyil.cuvis_measurement_load(i_path, o_pMesu) - -def cuvis_measurement_deep_copy(i_mesu, o_pMesu): - return _cuvis_pyil.cuvis_measurement_deep_copy(i_mesu, o_pMesu) - -def cuvis_session_file_load(i_path, o_pSess): - return _cuvis_pyil.cuvis_session_file_load(i_path, o_pSess) - -def cuvis_session_file_free(o_pSess): - return _cuvis_pyil.cuvis_session_file_free(o_pSess) - -def cuvis_session_file_get_mesu(i_sess, i_frameNo, o_pMesu): - return _cuvis_pyil.cuvis_session_file_get_mesu(i_sess, i_frameNo, o_pMesu) - -def cuvis_session_file_get_size(i_sess, o_pSize): - return _cuvis_pyil.cuvis_session_file_get_size(i_sess, o_pSize) - -def cuvis_session_file_get_size_non_dropped(i_sess, o_pSize): - return _cuvis_pyil.cuvis_session_file_get_size_non_dropped(i_sess, o_pSize) - -def cuvis_session_file_get_mesu_non_dropped(i_sess, i_frameNo, o_pMesu): - return _cuvis_pyil.cuvis_session_file_get_mesu_non_dropped(i_sess, i_frameNo, o_pMesu) - -def cuvis_session_file_get_fps(i_sess, o_pFps): - return _cuvis_pyil.cuvis_session_file_get_fps(i_sess, o_pFps) - -def cuvis_session_file_get_operation_mode(i_sess, o_pMode): - return _cuvis_pyil.cuvis_session_file_get_operation_mode(i_sess, o_pMode) - -def cuvis_acq_cont_get_next_measurement(i_acqCont, o_pMesu, timeout_ms): - return _cuvis_pyil.cuvis_acq_cont_get_next_measurement(i_acqCont, o_pMesu, timeout_ms) - -def cuvis_acq_cont_has_next_measurement(i_acqCont, o_pHasNext): - return _cuvis_pyil.cuvis_acq_cont_has_next_measurement(i_acqCont, o_pHasNext) - -def cuvis_measurement_save(i_mesu, i_path, args): - return _cuvis_pyil.cuvis_measurement_save(i_mesu, i_path, args) - -def cuvis_measurement_set_name(i_mesu, i_name): - return _cuvis_pyil.cuvis_measurement_set_name(i_mesu, i_name) - -def cuvis_measurement_set_comment(i_mesu, i_comment): - return _cuvis_pyil.cuvis_measurement_set_comment(i_mesu, i_comment) - -def cuvis_measurement_free(io_pMesu): - return _cuvis_pyil.cuvis_measurement_free(io_pMesu) - -def cuvis_measurement_get_metadata(i_mesu, o_pMetaData): - return _cuvis_pyil.cuvis_measurement_get_metadata(i_mesu, o_pMetaData) - -def cuvis_measurement_get_data_image(i_mesu, i_key, o_pBuf): - return _cuvis_pyil.cuvis_measurement_get_data_image(i_mesu, i_key, o_pBuf) - -def cuvis_measurement_get_data_sensor_info(i_mesu, i_key, o_pValue): - return _cuvis_pyil.cuvis_measurement_get_data_sensor_info(i_mesu, i_key, o_pValue) - -def cuvis_measurement_get_data_gps(i_mesu, i_key, o_pGps): - return _cuvis_pyil.cuvis_measurement_get_data_gps(i_mesu, i_key, o_pGps) - -def cuvis_measurement_get_data_count(i_mesu, o_pCount): - return _cuvis_pyil.cuvis_measurement_get_data_count(i_mesu, o_pCount) - -def cuvis_calib_create_from_path(i_factoryDir, o_pCalibration): - return _cuvis_pyil.cuvis_calib_create_from_path(i_factoryDir, o_pCalibration) - -def cuvis_calib_free(io_pCalibration): - return _cuvis_pyil.cuvis_calib_free(io_pCalibration) - -def cuvis_acq_cont_create_from_calib(i_calib, o_pAcqCont): - return _cuvis_pyil.cuvis_acq_cont_create_from_calib(i_calib, o_pAcqCont) - -def cuvis_acq_cont_get_state(i_acqCont, o_pState): - return _cuvis_pyil.cuvis_acq_cont_get_state(i_acqCont, o_pState) - -def cuvis_acq_cont_get_session_info(i_acqCont, o_pSessionInfo): - return _cuvis_pyil.cuvis_acq_cont_get_session_info(i_acqCont, o_pSessionInfo) - -def cuvis_acq_cont_set_session_info(i_acqCont, i_pSessionInfo): - return _cuvis_pyil.cuvis_acq_cont_set_session_info(i_acqCont, i_pSessionInfo) - -def cuvis_acq_cont_queue_size_set(i_acqCont, i_size): - return _cuvis_pyil.cuvis_acq_cont_queue_size_set(i_acqCont, i_size) - -def cuvis_acq_cont_free(io_pAcqCont): - return _cuvis_pyil.cuvis_acq_cont_free(io_pAcqCont) - -def cuvis_acq_cont_get_component_info(i_acqCont, i_id, o_pCompInfo): - return _cuvis_pyil.cuvis_acq_cont_get_component_info(i_acqCont, i_id, o_pCompInfo) - -def cuvis_acq_cont_get_component_count(i_acqCont, o_pCount): - return _cuvis_pyil.cuvis_acq_cont_get_component_count(i_acqCont, o_pCount) - -def cuvis_proc_cont_create_from_calib(i_calib, o_pProcCont): - return _cuvis_pyil.cuvis_proc_cont_create_from_calib(i_calib, o_pProcCont) - -def cuvis_proc_cont_create_from_mesu(i_mesu, o_pProcCont): - return _cuvis_pyil.cuvis_proc_cont_create_from_mesu(i_mesu, o_pProcCont) - -def cuvis_proc_cont_create_from_session_file(i_sess, o_pProcCont): - return _cuvis_pyil.cuvis_proc_cont_create_from_session_file(i_sess, o_pProcCont) - -def cuvis_proc_cont_get_reference(i_procCont, o_pMesu, i_type): - return _cuvis_pyil.cuvis_proc_cont_get_reference(i_procCont, o_pMesu, i_type) - -def cuvis_proc_cont_set_reference(i_procCont, i_mesu, i_type): - return _cuvis_pyil.cuvis_proc_cont_set_reference(i_procCont, i_mesu, i_type) - -def cuvis_proc_cont_clear_reference(i_procCont, i_type): - return _cuvis_pyil.cuvis_proc_cont_clear_reference(i_procCont, i_type) - -def cuvis_proc_cont_calc_distance(i_procCont, i_distanceMM): - return _cuvis_pyil.cuvis_proc_cont_calc_distance(i_procCont, i_distanceMM) - -def cuvis_proc_cont_has_reference(i_procCont, i_type, o_pHasReference): - return _cuvis_pyil.cuvis_proc_cont_has_reference(i_procCont, i_type, o_pHasReference) - -def cuvis_proc_cont_is_capable(i_procCont, i_mesu, args, o_pIsCapable): - return _cuvis_pyil.cuvis_proc_cont_is_capable(i_procCont, i_mesu, args, o_pIsCapable) - -def cuvis_proc_cont_apply(i_procCont, i_mesu): - return _cuvis_pyil.cuvis_proc_cont_apply(i_procCont, i_mesu) - -def cuvis_proc_cont_set_args(i_procCont, i_args): - return _cuvis_pyil.cuvis_proc_cont_set_args(i_procCont, i_args) - -def cuvis_proc_cont_free(io_pProcCont): - return _cuvis_pyil.cuvis_proc_cont_free(io_pProcCont) - -def cuvis_exporter_create_cube(o_pExporter, generalSettings, formatSettings): - return _cuvis_pyil.cuvis_exporter_create_cube(o_pExporter, generalSettings, formatSettings) - -def cuvis_exporter_create_tiff(o_pExporter, generalSettings, formatSettings): - return _cuvis_pyil.cuvis_exporter_create_tiff(o_pExporter, generalSettings, formatSettings) - -def cuvis_exporter_create_envi(o_pExporter, generalSettings): - return _cuvis_pyil.cuvis_exporter_create_envi(o_pExporter, generalSettings) - -def cuvis_exporter_create_view(o_pExporter, generalSettings, formatSettings): - return _cuvis_pyil.cuvis_exporter_create_view(o_pExporter, generalSettings, formatSettings) - -def cuvis_exporter_apply(i_exporter, i_mesu): - return _cuvis_pyil.cuvis_exporter_apply(i_exporter, i_mesu) - -def cuvis_exporter_get_queue_used(i_exporter, o_pQueueUsed): - return _cuvis_pyil.cuvis_exporter_get_queue_used(i_exporter, o_pQueueUsed) - -def cuvis_exporter_free(io_pExporter): - return _cuvis_pyil.cuvis_exporter_free(io_pExporter) - -def cuvis_viewer_create(o_pViewer, viewerSettings): - return _cuvis_pyil.cuvis_viewer_create(o_pViewer, viewerSettings) - -def cuvis_viewer_apply(i_viewer, i_mesu, o_pView): - return _cuvis_pyil.cuvis_viewer_apply(i_viewer, i_mesu, o_pView) - -def cuvis_viewer_free(io_pViewer): - return _cuvis_pyil.cuvis_viewer_free(io_pViewer) - -def cuvis_view_get_data_count(i_view, o_pCount): - return _cuvis_pyil.cuvis_view_get_data_count(i_view, o_pCount) - -def cuvis_view_get_data(i_view, i_index, o_pData): - return _cuvis_pyil.cuvis_view_get_data(i_view, i_index, o_pData) - -def cuvis_view_free(io_pView): - return _cuvis_pyil.cuvis_view_free(io_pView) - -def cuvis_calib_get_capabilities(i_calibration, i_mode, o_pCapabilities): - return _cuvis_pyil.cuvis_calib_get_capabilities(i_calibration, i_mode, o_pCapabilities) - -def cuvis_measurement_get_capabilities(i_mesu, o_pCapabilities): - return _cuvis_pyil.cuvis_measurement_get_capabilities(i_mesu, o_pCapabilities) - -def cuvis_measurement_get_calib_id(i_mesu, o_pCalibId): - return _cuvis_pyil.cuvis_measurement_get_calib_id(i_mesu, o_pCalibId) - -def cuvis_calib_get_id(i_calib, o_pCalibId): - return _cuvis_pyil.cuvis_calib_get_id(i_calib, o_pCalibId) - -def cuvis_proc_cont_get_calib_id(i_procCont, o_pCalibId): - return _cuvis_pyil.cuvis_proc_cont_get_calib_id(i_procCont, o_pCalibId) - -def cuvis_worker_create(o_pWorker, worker_settings): - return _cuvis_pyil.cuvis_worker_create(o_pWorker, worker_settings) - -def cuvis_worker_free(io_pWorker): - return _cuvis_pyil.cuvis_worker_free(io_pWorker) - -def cuvis_worker_set_acq_cont(i_worker, i_acq_cont): - return _cuvis_pyil.cuvis_worker_set_acq_cont(i_worker, i_acq_cont) - -def cuvis_worker_set_proc_cont(i_worker, i_proc_cont): - return _cuvis_pyil.cuvis_worker_set_proc_cont(i_worker, i_proc_cont) - -def cuvis_worker_set_exporter(i_worker, i_exporter): - return _cuvis_pyil.cuvis_worker_set_exporter(i_worker, i_exporter) - -def cuvis_worker_set_viewer(i_worker, i_viewer): - return _cuvis_pyil.cuvis_worker_set_viewer(i_worker, i_viewer) - -def cuvis_worker_get_next_result(i_worker, o_pMesu, o_pView): - return _cuvis_pyil.cuvis_worker_get_next_result(i_worker, o_pMesu, o_pView) - -def cuvis_worker_has_next_result(i_worker, o_pHasNext): - return _cuvis_pyil.cuvis_worker_has_next_result(i_worker, o_pHasNext) - -def cuvis_worker_get_queue_limit(i_worker, o_pQueueLimit): - return _cuvis_pyil.cuvis_worker_get_queue_limit(i_worker, o_pQueueLimit) - -def cuvis_worker_get_queue_used(i_worker, o_pQueueUsed): - return _cuvis_pyil.cuvis_worker_get_queue_used(i_worker, o_pQueueUsed) - -def cuvis_worker_set_queue_limit(i_worker, i_QueueLimit): - return _cuvis_pyil.cuvis_worker_set_queue_limit(i_worker, i_QueueLimit) - -def cuvis_set_special(arg1): - return _cuvis_pyil.cuvis_set_special(arg1) - -def cuvis_imbuffer_allocate(): - return _cuvis_pyil.cuvis_imbuffer_allocate() - -def cuvis_imbuffer_free(ptr): - return _cuvis_pyil.cuvis_imbuffer_free(ptr) - -def cuvis_gps_allocate(): - return _cuvis_pyil.cuvis_gps_allocate() - -def cuvis_gps_free(ptr): - return _cuvis_pyil.cuvis_gps_free(ptr) - -def cuvis_sensor_info_allocate(): - return _cuvis_pyil.cuvis_sensor_info_allocate() - -def cuvis_sensor_info_free(ptr): - return _cuvis_pyil.cuvis_sensor_info_free(ptr) - -def cuvis_session_info_allocate(): - return _cuvis_pyil.cuvis_session_info_allocate() - -def cuvis_session_info_free(ptr): - return _cuvis_pyil.cuvis_session_info_free(ptr) - -def cuvis_mesu_metadata_allocate(): - return _cuvis_pyil.cuvis_mesu_metadata_allocate() - -def cuvis_mesu_metadata_free(ptr): - return _cuvis_pyil.cuvis_mesu_metadata_free(ptr) - -def cuvis_save_args_allocate(): - return _cuvis_pyil.cuvis_save_args_allocate() - -def cuvis_save_args_free(ptr): - return _cuvis_pyil.cuvis_save_args_free(ptr) - -def cuvis_proc_args_allocate(): - return _cuvis_pyil.cuvis_proc_args_allocate() - -def cuvis_proc_args_free(ptr): - return _cuvis_pyil.cuvis_proc_args_free(ptr) - -def cuvis_export_general_settings_allocate(): - return _cuvis_pyil.cuvis_export_general_settings_allocate() - -def cuvis_export_general_settings_free(ptr): - return _cuvis_pyil.cuvis_export_general_settings_free(ptr) - -def cuvis_export_cube_settings_allocate(): - return _cuvis_pyil.cuvis_export_cube_settings_allocate() - -def cuvis_export_cube_settings_free(ptr): - return _cuvis_pyil.cuvis_export_cube_settings_free(ptr) - -def cuvis_export_view_settings_allocate(): - return _cuvis_pyil.cuvis_export_view_settings_allocate() - -def cuvis_export_view_settings_free(ptr): - return _cuvis_pyil.cuvis_export_view_settings_free(ptr) - -def cuvis_export_tiff_settings_allocate(): - return _cuvis_pyil.cuvis_export_tiff_settings_allocate() - -def cuvis_export_tiff_settings_free(ptr): - return _cuvis_pyil.cuvis_export_tiff_settings_free(ptr) - -def cuvis_viewer_settings_allocate(): - return _cuvis_pyil.cuvis_viewer_settings_allocate() - -def cuvis_viewer_settings_free(ptr): - return _cuvis_pyil.cuvis_viewer_settings_free(ptr) - -def cuvis_view_data_allocate(): - return _cuvis_pyil.cuvis_view_data_allocate() - -def cuvis_view_data_free(ptr): - return _cuvis_pyil.cuvis_view_data_free(ptr) - -def cuvis_cuvis_component_info_allocate(): - return _cuvis_pyil.cuvis_cuvis_component_info_allocate() - -def cuvis_cuvis_component_info_free(ptr): - return _cuvis_pyil.cuvis_cuvis_component_info_free(ptr) - -def cuvis_worker_settings_allocate(): - return _cuvis_pyil.cuvis_worker_settings_allocate() - -def cuvis_worker_settings_free(ptr): - return _cuvis_pyil.cuvis_worker_settings_free(ptr) - -def cuvis_acq_cont_fps_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_fps_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_fps_set(i_acqCont, value): - return _cuvis_pyil.cuvis_acq_cont_fps_set(i_acqCont, value) - -def cuvis_acq_cont_fps_set_async(i_acqCont, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_acq_cont_fps_set_async(i_acqCont, o_pAsyncResult, value) - -def cuvis_acq_cont_average_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_average_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_average_set(i_acqCont, value): - return _cuvis_pyil.cuvis_acq_cont_average_set(i_acqCont, value) - -def cuvis_acq_cont_average_set_async(i_acqCont, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_acq_cont_average_set_async(i_acqCont, o_pAsyncResult, value) - -def cuvis_acq_cont_integration_time_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_integration_time_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_integration_time_set(i_acqCont, value): - return _cuvis_pyil.cuvis_acq_cont_integration_time_set(i_acqCont, value) - -def cuvis_acq_cont_integration_time_set_async(i_acqCont, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_acq_cont_integration_time_set_async(i_acqCont, o_pAsyncResult, value) - -def cuvis_acq_cont_auto_exp_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_auto_exp_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_auto_exp_set(i_acqCont, value): - return _cuvis_pyil.cuvis_acq_cont_auto_exp_set(i_acqCont, value) - -def cuvis_acq_cont_auto_exp_set_async(i_acqCont, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_acq_cont_auto_exp_set_async(i_acqCont, o_pAsyncResult, value) - -def cuvis_acq_cont_preview_mode_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_preview_mode_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_preview_mode_set(i_acqCont, value): - return _cuvis_pyil.cuvis_acq_cont_preview_mode_set(i_acqCont, value) - -def cuvis_acq_cont_preview_mode_set_async(i_acqCont, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_acq_cont_preview_mode_set_async(i_acqCont, o_pAsyncResult, value) - -def cuvis_acq_cont_operation_mode_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_operation_mode_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_operation_mode_set(i_acqCont, value): - return _cuvis_pyil.cuvis_acq_cont_operation_mode_set(i_acqCont, value) - -def cuvis_acq_cont_operation_mode_set_async(i_acqCont, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_acq_cont_operation_mode_set_async(i_acqCont, o_pAsyncResult, value) - -def cuvis_acq_cont_continuous_set(i_acqCont, value): - return _cuvis_pyil.cuvis_acq_cont_continuous_set(i_acqCont, value) - -def cuvis_acq_cont_continuous_set_async(i_acqCont, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_acq_cont_continuous_set_async(i_acqCont, o_pAsyncResult, value) - -def cuvis_acq_cont_bandwidth_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_bandwidth_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_queue_size_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_queue_size_get(i_acqCont, o_pvalue) - -def cuvis_acq_cont_queue_used_get(i_acqCont, o_pvalue): - return _cuvis_pyil.cuvis_acq_cont_queue_used_get(i_acqCont, o_pvalue) - -def cuvis_comp_online_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_online_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_temperature_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_temperature_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_bandwidth_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_bandwidth_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_driver_queue_size_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_driver_queue_size_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_driver_queue_used_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_driver_queue_used_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_hardware_queue_size_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_hardware_queue_size_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_hardware_queue_used_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_hardware_queue_used_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_gain_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_gain_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_gain_set(i_acqCont, i_id, value): - return _cuvis_pyil.cuvis_comp_gain_set(i_acqCont, i_id, value) - -def cuvis_comp_gain_set_async(i_acqCont, i_id, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_comp_gain_set_async(i_acqCont, i_id, o_pAsyncResult, value) - -def cuvis_comp_integration_time_factor_get(i_acqCont, i_id, o_pvalue): - return _cuvis_pyil.cuvis_comp_integration_time_factor_get(i_acqCont, i_id, o_pvalue) - -def cuvis_comp_integration_time_factor_set(i_acqCont, i_id, value): - return _cuvis_pyil.cuvis_comp_integration_time_factor_set(i_acqCont, i_id, value) - -def cuvis_comp_integration_time_factor_set_async(i_acqCont, i_id, o_pAsyncResult, value): - return _cuvis_pyil.cuvis_comp_integration_time_factor_set_async(i_acqCont, i_id, o_pAsyncResult, value) - -def new_p_cuvis_data_type_t(): - return _cuvis_pyil.new_p_cuvis_data_type_t() - -def copy_p_cuvis_data_type_t(value): - return _cuvis_pyil.copy_p_cuvis_data_type_t(value) - -def delete_p_cuvis_data_type_t(obj): - return _cuvis_pyil.delete_p_cuvis_data_type_t(obj) - -def p_cuvis_data_type_t_assign(obj, value): - return _cuvis_pyil.p_cuvis_data_type_t_assign(obj, value) - -def p_cuvis_data_type_t_value(obj): - return _cuvis_pyil.p_cuvis_data_type_t_value(obj) - -def new_p_cuvis_operation_mode_t(): - return _cuvis_pyil.new_p_cuvis_operation_mode_t() - -def copy_p_cuvis_operation_mode_t(value): - return _cuvis_pyil.copy_p_cuvis_operation_mode_t(value) - -def delete_p_cuvis_operation_mode_t(obj): - return _cuvis_pyil.delete_p_cuvis_operation_mode_t(obj) - -def p_cuvis_operation_mode_t_assign(obj, value): - return _cuvis_pyil.p_cuvis_operation_mode_t_assign(obj, value) - -def p_cuvis_operation_mode_t_value(obj): - return _cuvis_pyil.p_cuvis_operation_mode_t_value(obj) - -def new_p_cuvis_hardware_state_t(): - return _cuvis_pyil.new_p_cuvis_hardware_state_t() - -def copy_p_cuvis_hardware_state_t(value): - return _cuvis_pyil.copy_p_cuvis_hardware_state_t(value) - -def delete_p_cuvis_hardware_state_t(obj): - return _cuvis_pyil.delete_p_cuvis_hardware_state_t(obj) - -def p_cuvis_hardware_state_t_assign(obj, value): - return _cuvis_pyil.p_cuvis_hardware_state_t_assign(obj, value) - -def p_cuvis_hardware_state_t_value(obj): - return _cuvis_pyil.p_cuvis_hardware_state_t_value(obj) - - From 91046d4909fae23ffd85261ab4456e3ecc982e6e Mon Sep 17 00:00:00 2001 From: Robert Briegel <123163218+robertCubert@users.noreply.github.com> Date: Wed, 8 Feb 2023 12:34:49 +0100 Subject: [PATCH 11/12] Update README.md --- Python/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Python/README.md b/Python/README.md index 1584f3c..59c146f 100644 --- a/Python/README.md +++ b/Python/README.md @@ -5,9 +5,9 @@ Python Version: 3.9 ## Installing Cuvis Python SDK via setup.py __In order to install the Python SDK, Cuvis must be installed. -Download the installer for windows (or the .deb files for Ubuntu 20.04) and the \_cuvis\_pyil file here:__ +Download the installer for windows (or the .deb files for Ubuntu 20.04) and the \_cuvis\_pyil file as well as the cuvis\_il.py file here:__ https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 -After installing, check out the repository and copy the *\_cuvis\_pyil* file into *Cubert-Community-Hub\Python\src\cuvis*. +After installing, check out the repository and copy the *\_cuvis\_pyil* as well as the cuvis\_il.py file into *Cubert-Community-Hub\Python\src\cuvis*. Then navigate to *Cubert-Community-Hub\Python\src* and run *python setup.py install* in the command line. From 869400792d3b2b69f90e79f295463187b8063d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20M=C3=BCller?= Date: Wed, 8 Feb 2023 14:40:08 +0100 Subject: [PATCH 12/12] Update README.md --- Python/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Python/README.md b/Python/README.md index 59c146f..f135cb7 100644 --- a/Python/README.md +++ b/Python/README.md @@ -10,4 +10,4 @@ https://cloud.cubert-gmbh.de/index.php/s/dPycyPcjnvee9F0 After installing, check out the repository and copy the *\_cuvis\_pyil* as well as the cuvis\_il.py file into *Cubert-Community-Hub\Python\src\cuvis*. -Then navigate to *Cubert-Community-Hub\Python\src* and run *python setup.py install* in the command line. +Then navigate from within your coding environment to *Cubert-Community-Hub\Python\src* and run *pip install . [-e]* in the command line.