├── .github ├── ISSUE_TEMPLATE │ ├── 1-support-request.yml │ ├── 2-bug_report.yml │ └── config.yml └── workflows │ ├── build_config.json │ └── main.yml ├── .gitignore ├── LICENSE ├── README.md ├── changelog.txt ├── docs └── images │ ├── Pypylon_grey_RZ.pdf │ ├── Pypylon_grey_RZ.png │ ├── Pypylon_grey_RZ.svg │ └── Pypylon_grey_RZ_400px.png ├── pyproject.toml ├── samples ├── HelloWorld.xml ├── call.py ├── callback.py ├── cameraeventprinter.py ├── configurationeventprinter.py ├── datacontainer_load.py ├── dataprocessing_barcode.precipe ├── dataprocessing_barcode.py ├── dataprocessing_builders_recipe.py ├── dataprocessing_camera.precipe ├── dataprocessing_camera.py ├── dataprocessing_composite_data_types.precipe ├── dataprocessing_composite_data_types.py ├── gige_action_command.py ├── gige_announce_renounce.py ├── gige_ip_config.py ├── grab.py ├── grabcameraevents.py ├── grabchunkimage.py ├── grabdatacontainer.py ├── grabmultiplecameras.py ├── grabone.py ├── grabstrategies.py ├── grabusinggrabloopthread.py ├── guiimagewindow.py ├── helloworld.py ├── ifacenodemap_pocxp.py ├── imageeventprinter.py ├── images │ ├── 3D │ │ └── little_boxes.gendc │ ├── barcode │ │ ├── barcode01.png │ │ ├── barcode02.png │ │ └── barcode03.png │ └── shapes │ │ ├── shapes01.png │ │ ├── shapes02.png │ │ ├── shapes03.png │ │ ├── shapes04.png │ │ ├── shapes05.png │ │ ├── shapes06.png │ │ ├── shapes07.png │ │ ├── shapes08.png │ │ ├── shapes09.png │ │ ├── shapes10.png │ │ ├── shapes11.png │ │ └── shapes12.png ├── load_unload_transportlayer.py ├── opencv.py ├── parametrizecameraloadandsaveconfig.py ├── pixelformatandaoiconfiguration.py ├── save_image.py ├── startup.py ├── utilityimageformatconverter.py ├── utilityimageformatconverter1.py └── zerocopy.py ├── scripts ├── build-linux-with-sdks-dir.sh ├── build │ ├── Dockerfile.debian │ ├── Dockerfile.manylinux │ ├── build-arch.sh │ ├── build.sh │ └── msvc_build_wrapper.cmd ├── builddoxy2swig │ ├── Doxyfile │ ├── HOW TO BUILD │ ├── builddoxygen.py │ └── doxy2swig │ │ ├── LICENSE │ │ └── doxy2swig.py ├── check_output.py ├── format_swig.py └── generatedoc │ ├── __init__.py │ └── generatedoc.py ├── setup.py ├── src ├── genicam │ ├── CNodeMapRef.i │ ├── ChunkAdapter.i │ ├── ChunkAdapterGEV.i │ ├── ChunkAdapterGeneric.i │ ├── ChunkAdapterU3V.i │ ├── ChunkPort.i │ ├── Container.i │ ├── DoxyGenApi.i │ ├── EnumClasses.i │ ├── EventAdapter.i │ ├── EventAdapterGEV.i │ ├── EventAdapterGeneric.i │ ├── EventAdapterU3V.i │ ├── EventPort.i │ ├── FileProtocolAdapter.i │ ├── GCException.i │ ├── IBase.i │ ├── IBoolean.i │ ├── ICategory.i │ ├── IChunkPort.i │ ├── ICommand.i │ ├── IDeviceInfo.i │ ├── IEnumEntry.i │ ├── IEnumeration.i │ ├── IFloat.i │ ├── IInteger.i │ ├── INode.i │ ├── INodeMap.i │ ├── IPort.i │ ├── IPortConstruct.i │ ├── IPortRecorder.i │ ├── IRegister.i │ ├── ISelector.i │ ├── ISelectorDigit.i │ ├── IString.i │ ├── IValue.i │ ├── NodeCallback.i │ ├── PortImpl.i │ ├── PyPortImpl.h │ ├── Reference.i │ ├── SelectorSet.i │ ├── Types.i │ ├── Version.i │ ├── genicam.i │ └── staging │ │ ├── CNodeMapRef.i │ │ ├── FileProtocolAdapter.i │ │ ├── INode.i │ │ ├── IPort.i │ │ ├── IPortConstruct.i │ │ ├── PortImpl.i │ │ └── readme.md ├── pylon │ ├── AcquireContinuousConfiguration.i │ ├── AcquireSingleFrameConfiguration.i │ ├── ActionTriggerConfiguration.i │ ├── CameraEventHandler.i │ ├── ConfigurationEventHandler.i │ ├── Container.i │ ├── Device.i │ ├── DeviceFactory.i │ ├── DeviceInfo.i │ ├── DoxyPylon.i │ ├── FeaturePersistence.i │ ├── GigETransportLayer.i │ ├── GrabResultData.i │ ├── GrabResultPtr.i │ ├── Image.i │ ├── ImageDecompressor.i │ ├── ImageEventHandler.i │ ├── ImageFormatConverter.i │ ├── Info.i │ ├── InstantCamera.i │ ├── InstantCameraArray.i │ ├── InstantCameraParams.i │ ├── Interface.i │ ├── InterfaceInfo.i │ ├── PayloadType.i │ ├── PixelType.i │ ├── PylonDataComponent.i │ ├── PylonDataContainer.i │ ├── PylonGUI.i │ ├── PylonImage.i │ ├── PylonImageBase.i │ ├── PylonVersionInfo.i │ ├── Result.i │ ├── ReusableImage.i │ ├── SoftwareTriggerConfiguration.i │ ├── StreamGrabber.i │ ├── TlFactory.i │ ├── TlInfo.i │ ├── TransportLayer.i │ ├── TypeMappings.i │ ├── WaitObject.i │ ├── WaitObjects.i │ ├── _ImageFormatConverterParams.i │ └── pylon.i └── pylondataprocessing │ ├── AcquisitionMode.i │ ├── BuildersRecipe.i │ ├── CircleF.i │ ├── DoxyPylonDataProcessing.i │ ├── EllipseF.i │ ├── EventObserver.i │ ├── GenericOutputObserver.i │ ├── LineF2D.i │ ├── OutputObserver.i │ ├── PointF2D.i │ ├── QueueMode.i │ ├── Recipe.i │ ├── RecipeFileFormat.i │ ├── RectangleF.i │ ├── Region.i │ ├── RegionEntry.i │ ├── RegionType.i │ ├── TransformationData.i │ ├── Update.i │ ├── UpdateObserver.i │ ├── Variant.i │ ├── VariantContainer.i │ ├── VariantContainerType.i │ ├── VariantDataType.i │ └── pylondataprocessing.i └── tests ├── .gitignore ├── all_emulated_tests.py ├── all_emulated_tests_with_pylondataprocessing.py ├── all_genicam_tests.py ├── all_pylon_emulated_tests.py ├── all_pylondataprocessing_tests.py ├── all_tests.py ├── all_utils_tests.py ├── genicam_tests ├── CSR.py ├── HelloWorld.xml ├── __init__.py ├── alias_test.py ├── boolean_test.py ├── callback_test.py ├── callbackhelper.py ├── category_test.py ├── command_test.py ├── converter_test.py ├── cycledetector_test.py ├── enumeration_test.py ├── error_test.py ├── floattestsuite.py ├── genicam.py ├── genicamtestcase.py ├── helloworld.py ├── integer_test.py ├── node_test.py ├── poll_test.py ├── port_test.py ├── properties_test.py ├── register_test.py ├── selector_test.py ├── snipper.py ├── streaming_test.py ├── string_test.py ├── swissknife_test.py └── testport.py ├── pylon_tests ├── emulated │ ├── __init__.py │ ├── barcode01.png │ ├── call_test.py │ ├── datacontainer_test.py │ ├── grab_test.py │ ├── grabresult_test.py │ ├── grabresultdata_test.py │ ├── import_test.py │ ├── instantcamera_test.py │ ├── instantcameraarray_test.py │ ├── instantcameraparams_test.py │ ├── little_boxes.gendc │ ├── loadandsave_test.py │ ├── pylonemutestcase.py │ ├── pylonimage_test.py │ └── version_test.py ├── gigE │ ├── __init__.py │ ├── call_test.py │ ├── chunkimage_test.py │ ├── grab_test.py │ ├── loadandsave_test.py │ └── pylongigetestcase.py ├── usb │ ├── __init__.py │ ├── call_test.py │ ├── chunkimage_test.py │ ├── decompression_test.py │ ├── grab_test.py │ ├── grabcameventstest_dis.py │ ├── loadandsave_test.py │ └── pylonusbtestcase.py └── utils │ └── decompression_test.py ├── pylondataprocessing_tests ├── __init__.py ├── buildersrecipe_test.py ├── circlef_test.py ├── ellipsef_test.py ├── genericoutputobserver_test.py ├── linef2d_test.py ├── pointf2d_test.py ├── pylondataprocessingtestcase.py ├── queuemode_test.py ├── recipe_eventobserver_test.precipe ├── recipe_test.precipe ├── recipe_test.py ├── recipe_test1.tif ├── recipe_test2.tif ├── recipe_test3.tif ├── recipefileformat_test.py ├── rectanglef_test.py ├── region_test.py ├── regionentry_test.py ├── regiontype_test.py ├── transformationdata_test.py ├── update_test.py ├── variant_test.py ├── variantcontainer_test.py ├── variantcontainertest_test.py ├── variantcontainertype.py └── variantdatatype_test.py └── testCoverage.bat /.github/ISSUE_TEMPLATE/2-bug_report.yml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Report a bug. 3 | title: "BUG: " 4 | labels: ["Bug", "Needs Triage"] 5 | 6 | body: 7 | - type: markdown 8 | attributes: 9 | value: > 10 | Thank you for taking the time to file a bug report. Before creating a new 11 | issue, please make sure to take a few minutes to check the issue tracker 12 | for existing issues about the bug. 13 | 14 | - type: textarea 15 | attributes: 16 | label: "Describe the issue:" 17 | validations: 18 | required: true 19 | 20 | - type: textarea 21 | attributes: 22 | label: "Reproduce the code example:" 23 | description: > 24 | A short code example that reproduces the problem/missing feature. It 25 | should be self-contained, i.e., can be copy-pasted into the Python 26 | interpreter or run as-is via `python sample_code.py`. 27 | placeholder: | 28 | import pypylon.pylon as py 29 | << your code here >> 30 | render: python 31 | validations: 32 | required: true 33 | 34 | - type: textarea 35 | attributes: 36 | label: "Error message:" 37 | description: > 38 | Please include full error message, if any. 39 | placeholder: | 40 | << Full traceback starting from `Traceback: ...` >> 41 | render: shell 42 | 43 | - type: dropdown 44 | attributes: 45 | label: Is your camera operational in Basler pylon viewer on your platform 46 | description: To better understand if the issue is a core pylon/camera or a pypylon/camera issue please tell us if the camera works in Basler pylon viewer on your platform. 47 | options: 48 | - 'Yes' 49 | - 'No' 50 | validations: 51 | required: true 52 | 53 | 54 | - type: textarea 55 | attributes: 56 | label: "Hardware setup & camera model(s) used" 57 | description: > 58 | List the camera model names involved in this bug report. 59 | Describe your hardware setup including, e.g.: 60 | 61 | * PC or embedded system model/type: 62 | * CPU architecture X86/X86_64/ARM/ARM64 63 | * Operating System 64 | * RAM 65 | * Interfaces used to connect the cameras 66 | * Type type/model/name of interface cards 67 | * Switches or hubs used 68 | * cable types/lengths 69 | validations: 70 | required: true 71 | 72 | - type: textarea 73 | attributes: 74 | label: "Runtime information:" 75 | description: | 76 | Do you have the full Basler pylon Camera Software Suite installed in addition to pypylon? 77 | 78 | > In the pylon Viewer the keys `Shift + Ctrl + Alt + i` will capture OS / software version information, that you can paste here. 79 | 80 | The below command will output python/pypylon and system versions. Please use the python interpreter used in your project to execute 81 | 82 | ```python 83 | import sys, pypylon.pylon, platform 84 | print(f'python: {sys.version}') 85 | print(f'platform: {sys.platform}/{platform.machine()}/{platform.release()}') 86 | print(f'pypylon: {pypylon.pylon.__version__} / {".".join([str(i) for i in pypylon.pylon.GetPylonVersion()])}') 87 | ``` 88 | 89 | And in case of containerized applications also list the operating system and platform of the base system and platform! 90 | placeholder: | 91 | << Runtime information >> 92 | render: shell 93 | validations: 94 | required: true 95 | 96 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: PyPylon general usage questions 4 | url: https://github.com/basler/pypylon-samples 5 | about: "For more documentation and specific use cases see the companion repository pypylon-samples" 6 | 7 | - name: Basler Feature Documentation 8 | url: https://docs.baslerweb.com/features 9 | about: "For questions on how a camera feature works please check first in the Basler Product Documention" 10 | -------------------------------------------------------------------------------- /.github/workflows/build_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "linux-x86_64": { 3 | "pylon_sdks": ["8.1.0"] 4 | }, 5 | "linux-aarch64": { 6 | "pylon_sdks": ["8.1.0"] 7 | }, 8 | "windows": { 9 | "pylon_sdks": ["8.1.0"] 10 | }, 11 | "macos": { 12 | "pylon_sdks": ["8.1.0"] 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore SWIG generates 2 | generated/ 3 | 4 | # Ignore build/dist tree 5 | /build* 6 | /dist/ 7 | /pypylon/ 8 | *.egg-info 9 | 10 | # Ignore python stuff 11 | __pycache__ 12 | *.pyc 13 | python*/ 14 | 15 | # Ignore compiler stuff 16 | *.idb 17 | *.pdb 18 | 19 | #ignore linux build stuff 20 | /linux-build/ 21 | /linux-build-tools/ 22 | 23 | # Ignore Genicamtest XML Stuff 24 | /xml 25 | scripts/xml 26 | tests/genicam/xml/ 27 | 28 | # Ignore .idea folder 29 | /.idea/ 30 | 31 | # Ignore reference_types.txt 32 | scripts/reference_types.txt 33 | 34 | # Ignore NodeMap.pfs 35 | NodeMap.pfs 36 | 37 | #ignore generated html 38 | pypylon.*.html 39 | osx_includes 40 | wheelhouse 41 | 42 | # macOS 43 | .DS_Store 44 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2017-2023 Basler AG 2 | Redistribution and use in source and binary forms, with or without modification, 3 | are permitted provided that the following conditions are met: 4 | 1. Redistributions of source code must retain the above copyright notice, 5 | this list of conditions and the following disclaimer. 6 | 2. Redistributions in binary form must reproduce the above copyright notice, 7 | this list of conditions and the following disclaimer in the documentation 8 | and/or other materials provided with the distribution. 9 | 3. Neither the name of the copyright holder nor the names of its contributors 10 | may be used to endorse or promote products derived from this software 11 | without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 14 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 17 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 18 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 20 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 21 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 22 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /docs/images/Pypylon_grey_RZ.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/docs/images/Pypylon_grey_RZ.pdf -------------------------------------------------------------------------------- /docs/images/Pypylon_grey_RZ.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/docs/images/Pypylon_grey_RZ.png -------------------------------------------------------------------------------- /docs/images/Pypylon_grey_RZ_400px.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/docs/images/Pypylon_grey_RZ_400px.png -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["setuptools>=42,<72", "swig==4.3", "wheel", "lief; sys_platform == 'darwin'"] 3 | build-backend = "setuptools.build_meta" 4 | 5 | [tool.cibuildwheel] 6 | skip = "pp* cp36-* cp37-* cp38-*" 7 | build-verbosity = "0" 8 | test-requires = "pytest numpy" 9 | 10 | [tool.pytest.ini_options] 11 | testpaths = [ 12 | "tests/genicam_tests", 13 | "tests/pylon_tests/emulated", 14 | "tests/pylondataprocessing_tests", 15 | ] 16 | 17 | [tool.cibuildwheel.windows] 18 | archs = "AMD64" 19 | build = "cp39-win_*" 20 | before-all = 'echo "Building: %CIBW_BUILD%"' 21 | 22 | [tool.cibuildwheel.macos] 23 | archs = "x86_64 arm64" 24 | build = "cp39-macosx_*" 25 | before-all = 'echo "Building: $CIBW_BUILD"' 26 | repair-wheel-command = "" 27 | test-skip = [ 28 | "tests/pylondataprocessing_tests" 29 | ] 30 | 31 | [[tool.cibuildwheel.overrides]] 32 | select = "*-macosx_arm64" 33 | before-build = [ 34 | ''' 35 | echo "arm framework" 36 | if [ -z "${PYLON_FRAMEWORK_ARM64}" ]; then 37 | echo "Set PYLON_FRAMEWORK_ARM64 to the directory where pylon.framework for arm64 is installed" 38 | echo "default of /Library/Frameworks will be used" 39 | fi 40 | ''' 41 | ] 42 | environment = { SYSTEM_VERSION_COMPAT="0",PYLON_FRAMEWORK_LOCATION="${PYLON_FRAMEWORK_ARM64}",MACOSX_DEPLOYMENT_TARGET="14.0" } 43 | 44 | [[tool.cibuildwheel.overrides]] 45 | select = "*-macosx_x86_64" 46 | before-build = [ 47 | ''' 48 | echo "intel framework" 49 | if [ -z "${PYLON_FRAMEWORK_X86_64}" ]; then 50 | echo "Set PYLON_FRAMEWORK_X86_64 to the directory where pylon.framework for x86_64 is installed" 51 | echo "default of /Library/Frameworks will be used" 52 | fi 53 | ''' 54 | ] 55 | environment = { SYSTEM_VERSION_COMPAT="0",PYLON_FRAMEWORK_LOCATION="${PYLON_FRAMEWORK_X86_64}",MACOSX_DEPLOYMENT_TARGET="14.0" } 56 | -------------------------------------------------------------------------------- /samples/HelloWorld.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | Hello World! 22 | 23 | 24 | TheFloat 25 | 42 26 | 27 | 28 | TheInt 29 | 3.1415 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /samples/call.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 09.06.2015 3 | 4 | @author: TMoeller 5 | ''' 6 | 7 | from pypylon import pylon 8 | 9 | cam = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) 10 | cam.Open() 11 | print(cam.GetSfncVersion()) 12 | cam.MaxNumBuffer.Value = 22 13 | 14 | cam.GainRaw.Value = 127 15 | print(cam.GainRaw) 16 | 17 | print(cam.MaxNumBuffer) 18 | cam.Close() 19 | 20 | print("done") 21 | -------------------------------------------------------------------------------- /samples/callback.py: -------------------------------------------------------------------------------- 1 | from pypylon import pylon 2 | from pypylon import genicam 3 | 4 | camera = pylon.InstantCamera( 5 | pylon.TlFactory.GetInstance().CreateFirstDevice()) 6 | 7 | camera.Open() 8 | 9 | # Print the model name of the camera. 10 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 11 | 12 | 13 | def callback(node): 14 | print("Callback", type(node)) 15 | print("Callback", node.Node.Name) 16 | 17 | 18 | genicam.Register(camera.GainRaw.Node, callback) 19 | 20 | camera.GainRaw.Value = camera.GainRaw.Max 21 | 22 | camera.Close() 23 | -------------------------------------------------------------------------------- /samples/cameraeventprinter.py: -------------------------------------------------------------------------------- 1 | # Contains a Camera Event Handler that prints a message for each event method call. 2 | 3 | from pypylon import pylon 4 | from pypylon import genicam 5 | 6 | 7 | class CameraEventPrinter(pylon.CameraEventHandler): 8 | def OnCameraEvent(self, camera, userProvidedId, node): 9 | print("OnCameraEvent event for device ", camera.GetDeviceInfo().GetModelName()) 10 | print("User provided ID: ", userProvidedId) 11 | print("Event data node name: ", node.GetName()) 12 | value = genicam.CValuePtr(node) 13 | if value.IsValid(): 14 | print("Event node data: ", value.ToString()) 15 | print() 16 | -------------------------------------------------------------------------------- /samples/configurationeventprinter.py: -------------------------------------------------------------------------------- 1 | # Contains a Configuration Event Handler that prints a message for each event method call. 2 | 3 | from pypylon import pylon 4 | 5 | 6 | class ConfigurationEventPrinter(pylon.ConfigurationEventHandler): 7 | def OnAttach(self, camera): 8 | print("OnAttach event") 9 | 10 | def OnAttached(self, camera): 11 | print("OnAttached event for device ", camera.GetDeviceInfo().GetModelName()) 12 | 13 | def OnOpen(self, camera): 14 | print("OnOpen event for device ", camera.GetDeviceInfo().GetModelName()) 15 | 16 | def OnOpened(self, camera): 17 | print("OnOpened event for device ", camera.GetDeviceInfo().GetModelName()) 18 | 19 | def OnGrabStart(self, camera): 20 | print("OnGrabStart event for device ", camera.GetDeviceInfo().GetModelName()) 21 | 22 | def OnGrabStarted(self, camera): 23 | print("OnGrabStarted event for device ", camera.GetDeviceInfo().GetModelName()) 24 | 25 | def OnGrabStop(self, camera): 26 | print("OnGrabStop event for device ", camera.GetDeviceInfo().GetModelName()) 27 | 28 | def OnGrabStopped(self, camera): 29 | print("OnGrabStopped event for device ", camera.GetDeviceInfo().GetModelName()) 30 | 31 | def OnClose(self, camera): 32 | print("OnClose event for device ", camera.GetDeviceInfo().GetModelName()) 33 | 34 | def OnClosed(self, camera): 35 | print("OnClosed event for device ", camera.GetDeviceInfo().GetModelName()) 36 | 37 | def OnDestroy(self, camera): 38 | print("OnDestroy event for device ", camera.GetDeviceInfo().GetModelName()) 39 | 40 | def OnDestroyed(self, camera): 41 | print("OnDestroyed event") 42 | 43 | def OnDetach(self, camera): 44 | print("OnDetach event for device ", camera.GetDeviceInfo().GetModelName()) 45 | 46 | def OnDetached(self, camera): 47 | print("OnDetached event for device ", camera.GetDeviceInfo().GetModelName()) 48 | 49 | def OnGrabError(self, camera, errorMessage): 50 | print("OnGrabError event for device ", camera.GetDeviceInfo().GetModelName()) 51 | print("Error Message: ", errorMessage) 52 | 53 | def OnCameraDeviceRemoved(self, camera): 54 | print("OnCameraDeviceRemoved event for device ", camera.GetDeviceInfo().GetModelName()) 55 | -------------------------------------------------------------------------------- /samples/datacontainer_load.py: -------------------------------------------------------------------------------- 1 | # =============================================================================== 2 | # This sample shows how to access data containers. 3 | # This is needed when using 3D cameras, e.g., Basler blaze. 4 | # =============================================================================== 5 | import os 6 | from pypylon import pylon 7 | from pypylon import genicam 8 | 9 | import sys 10 | 11 | # This is used for visualization. 12 | import cv2 13 | import time 14 | 15 | # The exit code of the sample application. 16 | exitCode = 0 17 | 18 | try: 19 | # Create a pylon data container object. 20 | pylonDataContainer = pylon.PylonDataContainer() 21 | 22 | # Load the recipe file. 23 | thisdir = os.path.dirname(__file__) 24 | filename = os.path.join(thisdir, 'images/3D/little_boxes.gendc') 25 | pylonDataContainer.Load(filename) 26 | 27 | print("Component Count: ", pylonDataContainer.DataComponentCount); 28 | 29 | # Access data components if the component type indicates image data 30 | for componentIndex in range(pylonDataContainer.DataComponentCount): 31 | pylonDataComponent = pylonDataContainer.GetDataComponent(componentIndex); 32 | # Access the component data. 33 | print("ComponentType: ", pylonDataComponent.ComponentType) 34 | print("PixelType: ", pylonDataComponent.PixelType) 35 | print("SizeX: ", pylonDataComponent.Width) 36 | print("SizeY: ", pylonDataComponent.Height) 37 | print("OffsetX: ", pylonDataComponent.OffsetX) 38 | print("OffsetY: ", pylonDataComponent.OffsetY) 39 | print("PaddingX: ", pylonDataComponent.PaddingX) 40 | print("DataSize: ", pylonDataComponent.DataSize) 41 | print("TimeStamp: ", pylonDataComponent.TimeStamp) 42 | img = pylonDataComponent.Array 43 | print("Gray value of first pixel: ", img[0, 0]) 44 | if pylonDataComponent.PixelType == pylon.PixelType_Coord3D_ABC32f: 45 | None 46 | else: 47 | cv2.imshow('Image' + str(componentIndex), img) 48 | # Release the data, otherwise it will not be freed 49 | # The data is held by the container and the components until all of them are released. 50 | pylonDataComponent.Release() 51 | 52 | for i in range(60): 53 | time.sleep(1) 54 | # Break the endless loop by pressing ESC. 55 | k = cv2.waitKey(5) & 0xFF 56 | if k == 27: 57 | break 58 | 59 | # Free the data held by the container 60 | pylonDataContainer.Release() 61 | 62 | except genicam.GenericException as e: 63 | # Error handling. 64 | print("An exception occurred.") 65 | print(e) 66 | exitCode = 1 67 | 68 | sys.exit(exitCode) 69 | -------------------------------------------------------------------------------- /samples/gige_announce_renounce.py: -------------------------------------------------------------------------------- 1 | # This sample demonstates the usage of the GigE transport layer methods 2 | # AnnounceRemoteDevice and RenounceRemoteDevice. 3 | 4 | from pypylon import pylon 5 | 6 | tl_factory = pylon.TlFactory.GetInstance() 7 | 8 | for dev_info in tl_factory.EnumerateDevices(): 9 | if dev_info.GetDeviceClass() == 'BaslerGigE': 10 | cam_info = dev_info 11 | print( 12 | "using %s @ %s (%s)" % ( 13 | cam_info.GetModelName(), 14 | cam_info.GetIpAddress(), 15 | cam_info.GetMacAddress() 16 | ) 17 | ) 18 | break 19 | else: 20 | raise EnvironmentError("no GigE device found") 21 | 22 | 23 | def announce_renounce(tl, addr): 24 | ok, info = tl.AnnounceRemoteDevice(addr) 25 | print("announce %s: %s" % (addr, "ok" if ok else "failed")) 26 | if ok: 27 | print("found:", info.GetFullName()) 28 | 29 | ok = tl.RenounceRemoteDevice(addr) 30 | print("rennounce %s: %s" % (addr, "ok" if ok else "failed")) 31 | 32 | 33 | 34 | gige_tl = tl_factory.CreateTl('BaslerGigE') 35 | announce_renounce(gige_tl, cam_info.GetIpAddress()) 36 | 37 | non_existant = "1.2.3.4" 38 | announce_renounce(gige_tl, non_existant) 39 | -------------------------------------------------------------------------------- /samples/grab.py: -------------------------------------------------------------------------------- 1 | # =============================================================================== 2 | # This sample illustrates how to grab and process images using the CInstantCamera class. 3 | # The images are grabbed and processed asynchronously, i.e., 4 | # while the application is processing a buffer, the acquisition of the next buffer is done 5 | # in parallel. 6 | # 7 | # The CInstantCamera class uses a pool of buffers to retrieve image data 8 | # from the camera device. Once a buffer is filled and ready, 9 | # the buffer can be retrieved from the camera object for processing. The buffer 10 | # and additional image data are collected in a grab result. The grab result is 11 | # held by a smart pointer after retrieval. The buffer is automatically reused 12 | # when explicitly released or when the smart pointer object is destroyed. 13 | # =============================================================================== 14 | from pypylon import pylon 15 | from pypylon import genicam 16 | 17 | import sys 18 | 19 | # Number of images to be grabbed. 20 | countOfImagesToGrab = 100 21 | 22 | # The exit code of the sample application. 23 | exitCode = 0 24 | 25 | try: 26 | # Create an instant camera object with the camera device found first. 27 | camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) 28 | camera.Open() 29 | 30 | # Print the model name of the camera. 31 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 32 | 33 | # demonstrate some feature access 34 | new_width = camera.Width.Value - camera.Width.Inc 35 | if new_width >= camera.Width.Min: 36 | camera.Width.Value = new_width 37 | 38 | # The parameter MaxNumBuffer can be used to control the count of buffers 39 | # allocated for grabbing. The default value of this parameter is 10. 40 | camera.MaxNumBuffer.Value = 5 41 | 42 | # Start the grabbing of c_countOfImagesToGrab images. 43 | # The camera device is parameterized with a default configuration which 44 | # sets up free-running continuous acquisition. 45 | camera.StartGrabbingMax(countOfImagesToGrab) 46 | 47 | # Camera.StopGrabbing() is called automatically by the RetrieveResult() method 48 | # when c_countOfImagesToGrab images have been retrieved. 49 | while camera.IsGrabbing(): 50 | # Wait for an image and then retrieve it. A timeout of 5000 ms is used. 51 | grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) 52 | 53 | # Image grabbed successfully? 54 | if grabResult.GrabSucceeded(): 55 | # Access the image data. 56 | print("SizeX: ", grabResult.Width) 57 | print("SizeY: ", grabResult.Height) 58 | img = grabResult.Array 59 | print("Gray value of first pixel: ", img[0, 0]) 60 | else: 61 | print("Error: ", grabResult.ErrorCode, grabResult.ErrorDescription) 62 | grabResult.Release() 63 | camera.Close() 64 | 65 | except genicam.GenericException as e: 66 | # Error handling. 67 | print("An exception occurred.") 68 | print(e) 69 | exitCode = 1 70 | 71 | sys.exit(exitCode) 72 | -------------------------------------------------------------------------------- /samples/grabone.py: -------------------------------------------------------------------------------- 1 | from pypylon import pylon 2 | from pypylon import genicam 3 | import numpy 4 | 5 | camera = pylon.InstantCamera( 6 | pylon.TlFactory.GetInstance().CreateFirstDevice()) 7 | 8 | camera.Open() 9 | 10 | # enable all chunks 11 | camera.ChunkModeActive.Value = True 12 | 13 | for cf in camera.ChunkSelector.Symbolics: 14 | camera.ChunkSelector.Value = cf 15 | camera.ChunkEnable.Value = True 16 | 17 | result = camera.GrabOne(100) 18 | print("Mean Gray value:", numpy.mean(result.Array[0:20, 0])) 19 | 20 | 21 | def ChunksOnResult(result): 22 | ret = "" 23 | for f in camera.ChunkSelector.Symbolics: 24 | try: 25 | if genicam.IsAvailable(getattr(result, "Chunk" + f)): 26 | ret += f + "," 27 | except AttributeError as e: 28 | # some cameras have chunkselectors which never occur in the video stream 29 | print(e) 30 | return ret 31 | 32 | 33 | print(ChunksOnResult(result)) 34 | -------------------------------------------------------------------------------- /samples/guiimagewindow.py: -------------------------------------------------------------------------------- 1 | from pypylon import pylon 2 | from pypylon import genicam 3 | import time 4 | 5 | try: 6 | imageWindow = pylon.PylonImageWindow() 7 | imageWindow.Create(1) 8 | # Create an instant camera object with the camera device found first. 9 | camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) 10 | 11 | # Print the model name of the camera. 12 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 13 | 14 | # Start the grabbing of c_countOfImagesToGrab images. 15 | # The camera device is parameterized with a default configuration which 16 | # sets up free-running continuous acquisition. 17 | camera.StartGrabbingMax(10000, pylon.GrabStrategy_LatestImageOnly) 18 | 19 | while camera.IsGrabbing(): 20 | # Wait for an image and then retrieve it. A timeout of 5000 ms is used. 21 | grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) 22 | 23 | # Image grabbed successfully? 24 | if grabResult.GrabSucceeded(): 25 | imageWindow.SetImage(grabResult) 26 | imageWindow.Show() 27 | else: 28 | print("Error: ", 29 | grabResult.ErrorCode) # grabResult.ErrorDescription does not work properly in python could throw UnicodeDecodeError 30 | grabResult.Release() 31 | time.sleep(0.05) 32 | 33 | if not imageWindow.IsVisible(): 34 | camera.StopGrabbing() 35 | 36 | # camera has to be closed manually 37 | camera.Close() 38 | # imageWindow has to be closed manually 39 | imageWindow.Close() 40 | 41 | except genicam.GenericException as e: 42 | # Error handling. 43 | print("An exception occurred.") 44 | print(e) 45 | -------------------------------------------------------------------------------- /samples/helloworld.py: -------------------------------------------------------------------------------- 1 | from pypylon import genicam # CNodeMapRef, GenericException, IsReadable 2 | 3 | 4 | def main(): 5 | try: 6 | XMLFileName = "HelloWorld.xml" 7 | 8 | Camera = genicam.CNodeMapRef() 9 | Camera._LoadXMLFromFile(XMLFileName) 10 | 11 | theNode = Camera.GetNode("TheNode") 12 | print(type(theNode)) 13 | 14 | theInt = Camera.GetNode("TheInt") 15 | print(type(theInt)) 16 | 17 | nodes = Camera._GetNodes() 18 | for n in nodes: 19 | print(n.ToString()) 20 | 21 | theFloat = Camera.GetNode("TheFloat") 22 | 23 | print(theNode.ToString()) 24 | print(theInt.ToString()) 25 | print(theInt.Node.GetPropertyNames()) 26 | print(genicam.IsReadable(theNode)) 27 | 28 | print(theFloat.GetIntAlias()) 29 | print(theInt.GetFloatAlias()) 30 | 31 | print(Camera.DeviceInfo) 32 | 33 | return 0 34 | except genicam.GenericException as e: 35 | print("Error ", e) 36 | 37 | return -1 38 | 39 | 40 | if __name__ == "__main__": 41 | main() 42 | -------------------------------------------------------------------------------- /samples/ifacenodemap_pocxp.py: -------------------------------------------------------------------------------- 1 | # This sample demonstrates the use of an interface node map. 2 | # Here we are going to use the interface node map of a Basler CXP interface 3 | # card to toggle 'Power Over CoaXPress' (PoCXP) between 'Auto' and 'Off'. 4 | 5 | from os import environ 6 | from pypylon import pylon 7 | 8 | # First check if GENICAM_GENTL64_PATH environment variable is set. 9 | # This is set automatically by the Basler setup when installing pylon CXP 10 | if environ.get('GENICAM_GENTL64_PATH') is None: 11 | raise RuntimeError("GENICAM_GENTL64_PATH not set! Please install the CXP GenTL producer and drivers using the pylon Camera Software Suite setup.") 12 | 13 | # We need access to the interface node map. This can only be obtained from 14 | # a transport layer. Therefore we have to create the TL first. 15 | tl = pylon.TlFactory.GetInstance().CreateTl('BaslerGTC/Basler/CXP') 16 | iface_infos = tl.EnumerateInterfaces() 17 | if iface_infos: 18 | print("Toggling PoCXP on these interfaces:") 19 | 20 | for info in iface_infos: 21 | # Handling interface node maps is actually more complicated: 22 | # - create interface 23 | # - open interface 24 | # - get node map and deal with it 25 | # - close interface 26 | # - destroy interface 27 | # Therefore there is this context manager object called InterfaceNodeMap 28 | # that handles all that. 29 | with tl.InterfaceNodeMap(info) as nmap: 30 | # Some transport layers (GigE, Usb ...) only have interfaces 31 | # without node maps. Therefore we have to test for None. 32 | if nmap is None: 33 | # Since we are using the CXP TL, we assume there is a node map. 34 | raise ValueError("node map should be present") 35 | node = nmap.GetNode('CxpPoCxpStatus') 36 | old_value = node.Value 37 | new_value = 'Auto' if old_value == 'Off' else 'Off' 38 | print(" %s: %s -> %s" % (info.GetFriendlyName(), old_value, new_value)) 39 | node.Value = new_value 40 | 41 | # A transport layer object has to be released when it is no longer needed. 42 | pylon.TlFactory.GetInstance().ReleaseTl(tl) 43 | -------------------------------------------------------------------------------- /samples/imageeventprinter.py: -------------------------------------------------------------------------------- 1 | # Contains an Image Event Handler that prints a message for each event method call. 2 | 3 | from pypylon import pylon 4 | 5 | 6 | class ImageEventPrinter(pylon.ImageEventHandler): 7 | def OnImagesSkipped(self, camera, countOfSkippedImages): 8 | print("OnImagesSkipped event for device ", camera.GetDeviceInfo().GetModelName()) 9 | print(countOfSkippedImages, " images have been skipped.") 10 | print() 11 | 12 | def OnImageGrabbed(self, camera, grabResult): 13 | print("OnImageGrabbed event for device ", camera.GetDeviceInfo().GetModelName()) 14 | 15 | # Image grabbed successfully? 16 | if grabResult.GrabSucceeded(): 17 | print("SizeX: ", grabResult.GetWidth()) 18 | print("SizeY: ", grabResult.GetHeight()) 19 | img = grabResult.GetArray() 20 | print("Gray values of first row: ", img[0]) 21 | print() 22 | else: 23 | print("Error: ", grabResult.GetErrorCode(), grabResult.GetErrorDescription()) 24 | -------------------------------------------------------------------------------- /samples/images/3D/little_boxes.gendc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/3D/little_boxes.gendc -------------------------------------------------------------------------------- /samples/images/barcode/barcode01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/barcode/barcode01.png -------------------------------------------------------------------------------- /samples/images/barcode/barcode02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/barcode/barcode02.png -------------------------------------------------------------------------------- /samples/images/barcode/barcode03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/barcode/barcode03.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes01.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes02.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes03.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes04.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes05.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes06.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes07.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes08.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes09.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes10.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes11.png -------------------------------------------------------------------------------- /samples/images/shapes/shapes12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/samples/images/shapes/shapes12.png -------------------------------------------------------------------------------- /samples/load_unload_transportlayer.py: -------------------------------------------------------------------------------- 1 | # this example demonstrates full loading/unloading 2 | # of transport layers to allow full shutdown of the 3 | # hardware associated with the transport layer 4 | 5 | # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 6 | # this sequence of calls should only be used 7 | # if you need _full control_ over the object lifetimes 8 | # e.g. if you need to powerdown a framegrabber in an 9 | # embedded setup. 10 | # the standard API to create a device is via TlFactory 11 | # as demonstrated in the grab.py sample 12 | # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 13 | 14 | import pypylon.pylon as py 15 | 16 | 17 | tlf = py.TlFactory.GetInstance() 18 | 19 | 20 | # load the transport layer 21 | tl = tlf.CreateTl("BaslerGTC/Basler/CXP") 22 | 23 | cam = py.InstantCamera() 24 | 25 | # instantiate the first device on the transport 26 | # layer 27 | dev = tl.CreateFirstDevice() 28 | # attach the device to the InstantCamera class 29 | cam.Attach(dev) 30 | 31 | cam.Open() 32 | # ... work with the camera 33 | cam.Close() 34 | 35 | 36 | # detach the the device from the InstantCamera 37 | # and release the device with the returned 38 | # device handle 39 | tl.DestroyDevice(cam.DetachDevice()) 40 | 41 | # unload the transport layer 42 | tlf.ReleaseTl(tl) 43 | 44 | # delete the now empty python objects 45 | # to prevent further access from python side 46 | del cam 47 | del dev 48 | del tl 49 | 50 | # now all references to the transport layer 51 | # hardware are released. 52 | -------------------------------------------------------------------------------- /samples/opencv.py: -------------------------------------------------------------------------------- 1 | ''' 2 | A simple Program for grabing video from basler camera and converting it to opencv img. 3 | Tested on Basler acA1300-200uc (USB3, linux 64bit , python 3.5) 4 | 5 | ''' 6 | from pypylon import pylon 7 | import cv2 8 | 9 | # conecting to the first available camera 10 | camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) 11 | 12 | # Grabing Continusely (video) with minimal delay 13 | camera.StartGrabbing(pylon.GrabStrategy_LatestImageOnly) 14 | converter = pylon.ImageFormatConverter() 15 | 16 | # converting to opencv bgr format 17 | converter.OutputPixelFormat = pylon.PixelType_BGR8packed 18 | converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned 19 | 20 | while camera.IsGrabbing(): 21 | grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) 22 | 23 | if grabResult.GrabSucceeded(): 24 | # Access the image data 25 | image = converter.Convert(grabResult) 26 | img = image.GetArray() 27 | cv2.namedWindow('title', cv2.WINDOW_NORMAL) 28 | cv2.imshow('title', img) 29 | k = cv2.waitKey(1) 30 | if k == 27: 31 | break 32 | grabResult.Release() 33 | 34 | # Releasing the resource 35 | camera.StopGrabbing() 36 | 37 | cv2.destroyAllWindows() 38 | -------------------------------------------------------------------------------- /samples/parametrizecameraloadandsaveconfig.py: -------------------------------------------------------------------------------- 1 | # LoadAndSaveConfig.py 2 | from pypylon import pylon 3 | 4 | # The name of the pylon file handle 5 | nodeFile = "NodeMap.pfs" 6 | 7 | # Create an instant camera object with the camera device found first. 8 | camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) 9 | camera.Open() 10 | # Print the model name of the camera. 11 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 12 | 13 | # featurePersistence = pylon.FeaturePersistence() 14 | 15 | print("Saving camera's node map to file...") 16 | print(nodeFile) 17 | 18 | # Save the content of the camera's node map into the file. 19 | pylon.FeaturePersistence.Save(nodeFile, camera.GetNodeMap()) 20 | 21 | # Just for demonstration, read the content of the file back to the camera's node map with enabled validation. 22 | print("Reading file back to camera's node map...") 23 | pylon.FeaturePersistence.Load(nodeFile, camera.GetNodeMap(), True) 24 | # Close the camera. 25 | camera.Close() 26 | -------------------------------------------------------------------------------- /samples/pixelformatandaoiconfiguration.py: -------------------------------------------------------------------------------- 1 | # Contains a configuration that sets pixel data format and Image AOI. 2 | 3 | from pypylon import pylon 4 | from pypylon import genicam 5 | 6 | 7 | class CPixelFormatAndAoiConfiguration(pylon.ConfigurationEventHandler): 8 | def OnOpened(self, camera): 9 | try: 10 | # Maximize the Image AOI. 11 | if genicam.IsWritable(camera.OffsetX): 12 | camera.OffsetX.Value = camera.OffsetX.Min 13 | if genicam.IsWritable(camera.OffsetY): 14 | camera.OffsetY.Value = camera.OffsetY.Min 15 | camera.Width.Value = camera.Width.Max 16 | camera.Height.Value = camera.Height.Max 17 | 18 | # Set the pixel data format. 19 | camera.PixelFormat.Value = "Mono8" 20 | except genicam.GenericException as e: 21 | raise genicam.RuntimeException("Could not apply configuration. GenICam::GenericException \ 22 | caught in OnOpened method msg=%s" % e.what()) 23 | -------------------------------------------------------------------------------- /samples/save_image.py: -------------------------------------------------------------------------------- 1 | """This sample shows how grabbed images can be saved using pypylon only (no 2 | need to use openCV). 3 | 4 | Available image formats are (depending on platform): 5 | - pylon.ImageFileFormat_Bmp (Windows) 6 | - pylon.ImageFileFormat_Tiff (Linux, Windows) 7 | - pylon.ImageFileFormat_Jpeg (Windows) 8 | - pylon.ImageFileFormat_Png (Linux, Windows) 9 | - pylon.ImageFileFormat_Raw (Windows) 10 | """ 11 | from pypylon import pylon 12 | import platform 13 | 14 | num_img_to_save = 5 15 | img = pylon.PylonImage() 16 | tlf = pylon.TlFactory.GetInstance() 17 | 18 | cam = pylon.InstantCamera(tlf.CreateFirstDevice()) 19 | cam.Open() 20 | cam.StartGrabbing() 21 | for i in range(num_img_to_save): 22 | with cam.RetrieveResult(2000) as result: 23 | 24 | # Calling AttachGrabResultBuffer creates another reference to the 25 | # grab result buffer. This prevents the buffer's reuse for grabbing. 26 | img.AttachGrabResultBuffer(result) 27 | 28 | if platform.system() == 'Windows': 29 | # The JPEG format that is used here supports adjusting the image 30 | # quality (100 -> best quality, 0 -> poor quality). 31 | ipo = pylon.ImagePersistenceOptions() 32 | quality = 90 - i * 10 33 | ipo.SetQuality(quality) 34 | 35 | filename = "saved_pypylon_img_%d.jpeg" % quality 36 | img.Save(pylon.ImageFileFormat_Jpeg, filename, ipo) 37 | else: 38 | filename = "saved_pypylon_img_%d.png" % i 39 | img.Save(pylon.ImageFileFormat_Png, filename) 40 | 41 | # In order to make it possible to reuse the grab result for grabbing 42 | # again, we have to release the image (effectively emptying the 43 | # image object). 44 | img.Release() 45 | 46 | cam.StopGrabbing() 47 | cam.Close() 48 | -------------------------------------------------------------------------------- /samples/startup.py: -------------------------------------------------------------------------------- 1 | from pypylon import pylon 2 | from pypylon import genicam 3 | import numpy 4 | 5 | IMAGES_TO_GRAB = 50000 6 | exitCode = 0 7 | 8 | while True: 9 | camera = pylon.InstantCamera( 10 | pylon.TlFactory.GetInstance().CreateFirstDevice()) 11 | 12 | camera.Open() 13 | 14 | # Print the model name of the camera. 15 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 16 | 17 | camera.MaxNumBuffer.Value = 2 18 | try: 19 | camera.Gain.Value = camera.Gain.Max 20 | except genicam.LogicalErrorException: 21 | camera.GainRaw.Value = camera.GainRaw.Max 22 | camera.Width.Value = camera.Width.Max 23 | camera.Height.Value = camera.Height.Max 24 | # camera.ExposureTime.Value = camera.ExposureTime.Min 25 | camera.PixelFormat.Value = "Mono12" 26 | 27 | # Start the grabbing of IMAGES_TO_GRAB images. 28 | # The camera device is parameterized with a default configuration which 29 | # sets up free-running continuous acquisition. 30 | camera.StartGrabbingMax(IMAGES_TO_GRAB) 31 | 32 | # Camera.StopGrabbing() is called automatically by the RetrieveResult() method 33 | # when IMAGES_TO_GRAB images have been retrieved. 34 | try: 35 | while camera.IsGrabbing(): 36 | result = camera.RetrieveResult( 37 | 5000, 38 | pylon.TimeoutHandling_ThrowException) 39 | print(result.GrabSucceeded()) 40 | # Image grabbed successfully? 41 | if result.GrabSucceeded(): 42 | # Access the image data. 43 | print("SizeX: ", result.Width) 44 | print("SizeY: ", result.Height) 45 | print(pylon.IsPacked(result.PixelType)) 46 | print("Mean Gray value:", numpy.mean(result.Array[0:20, 0])) 47 | # Display the grabbed image. 48 | # pylon.DisplayImage(1, result) 49 | result.Release() 50 | 51 | else: 52 | print("Error: ", result.GetErrorCode(), result.GetErrorDescription()) 53 | 54 | except genicam.GenericException as e: 55 | # Error handling. 56 | print("An exception occurred.", e) 57 | 58 | camera.Close() 59 | -------------------------------------------------------------------------------- /samples/utilityimageformatconverter.py: -------------------------------------------------------------------------------- 1 | # Note: Before getting started, Basler recommends reading the Programmer's Guide topic 2 | # in the pylon C++ API documentation that gets installed with pylon. 3 | # If you are upgrading to a higher major version of pylon, Basler also 4 | # strongly recommends reading the Migration topic in the pylon C++ API documentation. 5 | 6 | # This sample illustrates how to use the image format 7 | # converter class CImageFormatConverter. 8 | 9 | # The image format converter accepts all image formats 10 | # produced by Basler camera devices and it is able to 11 | # convert these to a number of output formats. 12 | # The conversion can be controlled by several parameters. 13 | # See the converter class documentation for more details. 14 | 15 | from pypylon import pylon 16 | from pypylon import genicam 17 | 18 | 19 | # This is a helper function for showing an image on the screen if Windows is used, 20 | # and for printing the first bytes of the image. 21 | def show_image(image, message): 22 | print(message) 23 | pBytes = image.Array 24 | print("Bytes of the image: \n") 25 | print(pBytes) 26 | 27 | 28 | try: 29 | # Create the converter and set parameters. 30 | converter = pylon.ImageFormatConverter() 31 | converter.OutputPixelFormat = pylon.PixelType_RGB8packed 32 | converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned 33 | 34 | # Try to get a grab result for demonstration purposes. 35 | print("Waiting for an image to be grabbed.") 36 | try: 37 | camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) 38 | grabResult = camera.GrabOne(1000) 39 | show_image(grabResult, "Grabbed image.") 40 | targetImage = pylon.PylonImage.Create(pylon.PixelType_Mono8, grabResult.GetWidth(), grabResult.GetHeight()); 41 | print(converter.IsSupportedOutputFormat(pylon.PixelType_Mono8)) 42 | # Now we can check if conversion is required. 43 | if converter.ImageHasDestinationFormat(grabResult): 44 | # No conversion is needed. It can be skipped for saving processing 45 | # time. 46 | show_image(grabResult, "Grabbed image.") 47 | 48 | else: 49 | # Conversion is needed. 50 | show_image(grabResult, "Grabbed image.") 51 | targetImage=converter.Convert(grabResult) 52 | show_image(targetImage, "Converted image.") 53 | filename = "saved_pypylon_converted.png" 54 | targetImage.Save(pylon.ImageFileFormat_Png, filename) 55 | 56 | except genicam.GenericException as e: 57 | print("Could not grab an image: ", e) 58 | except genicam.GenericException as e: 59 | print("An exception occurred. ", e) 60 | -------------------------------------------------------------------------------- /samples/utilityimageformatconverter1.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Note: Before getting started, Basler recommends reading the Programmer's Guide topic 3 | in the pylon C++ API documentation that gets installed with pylon. 4 | If you are upgrading to a higher major version of pylon, Basler also 5 | strongly recommends reading the Migration topic in the pylon C++ API documentation. 6 | 7 | This sample illustrates how to use the image format 8 | converter class CImageFormatConverter. 9 | 10 | The image format converter accepts all image formats 11 | produced by Basler camera devices and it is able to 12 | convert these to a number of output formats. 13 | The conversion can be controlled by several parameters. 14 | See the converter class documentation for more details. 15 | ''' 16 | 17 | from pypylon import pylon 18 | from pypylon import genicam 19 | 20 | 21 | def show_image(img, message): 22 | print(message) 23 | 24 | image_array = img.GetArray() 25 | print(image_array) 26 | 27 | 28 | 29 | def grab_image(): 30 | try: 31 | camera = pylon.InstantCamera( 32 | pylon.TlFactory.GetInstance().CreateFirstDevice()) 33 | 34 | camera.Open() 35 | result = camera.GrabOne(100) 36 | camera.Close() 37 | return result 38 | except genicam.GenericException as e: 39 | print("Could not grab an image: ", e) 40 | 41 | 42 | try: 43 | # The image format converter basics. 44 | # First the image format converter class must be created. 45 | converter = pylon.ImageFormatConverter() 46 | 47 | # Second the converter must be parameterized. 48 | converter.OutputPixelFormat = pylon.PixelType_Mono16 49 | converter.OutputBitAlignment = "MsbAligned" 50 | # or alternatively 51 | converter.OutputBitAlignment = pylon.OutputBitAlignment_MsbAligned 52 | 53 | 54 | # Then it can be used to convert input images to 55 | # the target image format. 56 | 57 | # Grab an image 58 | image = grab_image() 59 | show_image(image, "Source Image") 60 | 61 | # Now we can check if conversion is required. 62 | if (converter.ImageHasDestinationFormat(image)): 63 | show_image(image, "No conversion needed.") 64 | else: 65 | # Convert the image. Note that there are more overloaded Convert methods avilable, e.g. 66 | # for converting the image from or to a user buffer. 67 | target_image = converter.Convert(image) 68 | show_image(target_image, "Converted image.") 69 | except genicam.GenericException as e: 70 | print("An exception occurred. ", e) 71 | -------------------------------------------------------------------------------- /samples/zerocopy.py: -------------------------------------------------------------------------------- 1 | """This sample shows how some time can be saved by accessing the image buffer 2 | without copying its contents. Keep in mind that while a zero-copy array has a 3 | reference to the image buffer, this buffer cannot be released and cannot be 4 | reused for grabbing. 5 | """ 6 | import numpy 7 | import time 8 | from pypylon import pylon 9 | 10 | cam = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) 11 | cam.Open() 12 | print("camera model: %s" % cam.DeviceModelName.Value) 13 | print("AOI: %d x %d" % (cam.Width.Value, cam.Height.Value)) 14 | print("payload size: %d\n" % cam.PayloadSize.Value) 15 | 16 | pxl_sum = 0 17 | time_zc = 0 18 | count_zc = 0 19 | time_cpy = 0 20 | count_cpy = 0 21 | cam.StartGrabbing(pylon.GrabStrategy_OneByOne) 22 | 23 | deadline = time.perf_counter() + 10 24 | print("Using zero copy for 10 seconds.") 25 | while time.perf_counter() < deadline: 26 | with cam.RetrieveResult(1000) as result: 27 | start = time.perf_counter() 28 | with result.GetArrayZeroCopy() as zc: 29 | pxl_sum += zc[0, 0] 30 | time_zc += time.perf_counter() - start 31 | count_zc += 1 32 | 33 | deadline = time.perf_counter() + 10 34 | print("Using copy for 10 seconds.") 35 | while time.perf_counter() < deadline: 36 | with cam.RetrieveResult(1000) as result: 37 | start = time.perf_counter() 38 | pxl_sum += result.GetArray()[0, 0] 39 | time_cpy += time.perf_counter() - start 40 | count_cpy += 1 41 | 42 | cam.StopGrabbing() 43 | cam.Close() 44 | 45 | 46 | print( 47 | " zc: %.3g s, %d images, %.3g s / per image" % 48 | (time_zc, count_zc, time_zc / count_zc) 49 | ) 50 | print( 51 | "cpy: %.3g s, %d images, %.3g s / per image" % 52 | (time_cpy, count_cpy, time_cpy / count_cpy) 53 | ) 54 | ratio = (time_cpy * count_zc) / (time_zc * count_cpy) 55 | print("zero copy is %.1f times faster" % ratio) 56 | -------------------------------------------------------------------------------- /scripts/build-linux-with-sdks-dir.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | #This is a rather hacky script to build pypylon for the current architecture. 4 | #it automatically searches and extracts the correct sdk from the directory given by $1 5 | #this is needed for the jenkins build 6 | #if you want to build pypylon for your installed pylon, don't use this script. You can do: 7 | # PYLON_ROOT=/path/to/your/pylon/install python3 setup.py bdist_wheel 8 | 9 | if [ $# -ne 1 ]; then 10 | echo "Call this script with $0 " 11 | exit 1 12 | fi 13 | 14 | SDK_FILES_DIR=`readlink -f $1` 15 | 16 | cd `dirname $0`/.. 17 | BUILD_DIR=${BUILD_DIR:-`pwd`/linux-build} 18 | 19 | #guess architecture 20 | ARCH=`uname -m` 21 | case "$ARCH" in 22 | i?86) BUILD=x86 ;; 23 | x86_64) BUILD=x86_64 ;; 24 | armel) BUILD=armel ;; 25 | armhf) BUILD=armhf ;; 26 | arm*) 27 | BUILD=armel 28 | if [ -d /lib/arm-linux-gnueabihf ]; then 29 | BUILD=armhf 30 | fi 31 | ;; 32 | aarch64) BUILD=arm64 ;; 33 | esac 34 | 35 | #rm -r $BUILD_DIR 36 | mkdir -p $BUILD_DIR 37 | 38 | #check if we need to extract the SDK 39 | if [ ! -d $BUILD_DIR/pylon5-$BUILD ]; then 40 | ( 41 | cd $BUILD_DIR 42 | tar -xzf $SDK_FILES_DIR/pylonSDK-*-$BUILD.tar.gz 43 | mv pylon5 pylon5-$BUILD 44 | ) 45 | fi 46 | 47 | #we always use the extracted SDK, if you need this script to build against your pylon version add the logic :-) 48 | PYLON_ROOT=$BUILD_DIR/pylon5-$BUILD 49 | echo "Using pylon SDK from $PYLON_ROOT" 50 | export PYLON_ROOT 51 | 52 | python3 setup.py clean 53 | python3 setup.py bdist_wheel 54 | -------------------------------------------------------------------------------- /scripts/build/Dockerfile.debian: -------------------------------------------------------------------------------- 1 | ARG DOCKER_BASE_IMAGE 2 | 3 | #the following lines are used to get a qemu binary only with docker tools 4 | FROM multiarch/qemu-user-static:4.2.0-6 as qemu 5 | 6 | FROM $DOCKER_BASE_IMAGE 7 | ARG CMD_WRAPPER 8 | ARG QEMU_TARGET_ARCH 9 | COPY --from=qemu /usr/bin/* /usr/bin/ 10 | 11 | # Quick fix for the now archived debian jessie. Security updates are also no longer provided for arm64. 12 | # We switch all sources to the debian archive servers, See: 13 | # https://github.com/debuerreotype/docker-debian-artifacts/issues/66 14 | # https://stackoverflow.com/questions/55386246/w-failed-to-fetch-http-deb-debian-org-debian-dists-jessie-updates-main-binary 15 | RUN if cat /etc/debian_version | grep -q "8\." ; then \ 16 | echo "deb [check-valid-until=no] http://archive.debian.org/debian jessie main" > /etc/apt/sources.list; \ 17 | apt-get -o Acquire::Check-Valid-Until=false update; \ 18 | fi 19 | 20 | # auditwheel is limited to 5.1.2 because since 5.2.1 it requires patchelf >= 0.14 which is not available on our debian base images 21 | RUN pip install wheel 'auditwheel<=5.1.2' 22 | 23 | # install swig from pypi 24 | RUN pip install "swig==4.3" 25 | # install setuptools 26 | RUN pip install "setuptools<72" --upgrade 27 | 28 | # numpy is required for the pypylon unittests 29 | # currently disabled because the numpy install exceeds the current travis max duration 30 | # RUN pip install numpy 31 | 32 | # one genicam unittest requires a french locale 33 | # patchelf, unzip are needed for auditwheel 34 | # symlink for libicuuc.so.66 needed for pylon 35 | RUN apt-get update && apt-get install -y locales patchelf unzip libicu67\ 36 | && ln -s /usr/lib/$QEMU_TARGET_ARCH-linux-gnu/libicuuc.so.67 /usr/lib/$QEMU_TARGET_ARCH-linux-gnu/libicuuc.so.66\ 37 | && rm -rf /var/lib/apt/lists/* \ 38 | && sed -i 's/^# *\(fr_FR.UTF-8\)/\1/' /etc/locale.gen \ 39 | && locale-gen 40 | 41 | RUN mkdir /work 42 | RUN mkdir /pylon_installer 43 | RUN mkdir /worker_home && chmod go+rwx /worker_home 44 | ENV HOME=/worker_home 45 | 46 | 47 | # run everything wrapped using CMD_WRAPPER 48 | # In most cases the wrapper is linux64/32. 49 | # This is for example required when running the armv7 container on armv8 hardware to ensure that python really builds for armv7 50 | RUN echo "#!/bin/sh" > /entrypoint.sh; echo exec $CMD_WRAPPER \"\$@\" >> /entrypoint.sh; chmod +x /entrypoint.sh 51 | ENTRYPOINT [ "/entrypoint.sh" ] 52 | 53 | RUN /entrypoint.sh uname -a 54 | -------------------------------------------------------------------------------- /scripts/build/Dockerfile.manylinux: -------------------------------------------------------------------------------- 1 | ARG QEMU_TARGET_ARCH 2 | ARG DOCKER_BASE_IMAGE 3 | 4 | #the following lines are used to get a qemu binary only with docker tools 5 | FROM multiarch/qemu-user-static:4.1.0-1 as qemu 6 | 7 | FROM $DOCKER_BASE_IMAGE 8 | COPY --from=qemu /usr/bin/* /usr/bin/ 9 | 10 | 11 | # install pip from pypi 12 | RUN pip install "swig==4.3" 13 | 14 | # install setuptools 15 | RUN pip install "setuptools<72" --upgrade 16 | 17 | # one genicam unittest requires a french locale 18 | RUN yum -y reinstall glibc-common 19 | 20 | RUN mkdir /work 21 | RUN mkdir /pylon_installer 22 | RUN mkdir /worker_home && chmod go+rwx /worker_home 23 | ENV HOME=/worker_home 24 | 25 | RUN uname -a 26 | -------------------------------------------------------------------------------- /scripts/build/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | usage() 5 | { 6 | echo "Usage: $0 []" 7 | echo "Options:" 8 | echo " --pylon-tgz Use the given pylon installer tgz" 9 | echo " --python Use the given python binary" 10 | echo " --update-platform-tag Use auditwheel repair to set the platform tag" 11 | echo " --disable-tests Disable automatic unittests" 12 | echo " -h This usage help" 13 | } 14 | 15 | PYLON_TGZ="" 16 | PYTHON="python" 17 | DISABLE_TESTS="" 18 | UPDATE_PLATFORM_TAG="" 19 | 20 | # parse args 21 | while [ $# -gt 0 ]; do 22 | arg="$1" 23 | case $arg in 24 | --pylon-tgz) PYLON_TGZ="$2" ; shift ;; 25 | --python) PYTHON="$2" ; shift ;; 26 | --update-platform-tag) UPDATE_PLATFORM_TAG="$2"; shift ;; 27 | --disable-tests) DISABLE_TESTS=1 ;; 28 | -h|--help) usage ; exit 1 ;; 29 | *) echo "Unknown argument $arg" ; usage ; exit 1 ;; 30 | esac 31 | shift 32 | done 33 | 34 | if [ ! -e "$PYLON_TGZ" ]; then 35 | echo "Pylon installer '$PYLON_TGZ' doesn't exist" 36 | exit 1 37 | fi 38 | 39 | #make path absolute 40 | PYLON_TGZ=$(readlink -m "$PYLON_TGZ") 41 | 42 | BASEDIR="$(cd $(dirname $0)/../.. ; pwd)" 43 | #enter source dir 44 | pushd $BASEDIR 45 | 46 | BUILD_DIR="build-dockerized-$(date +%s)" 47 | 48 | if [ -d "$BUILD_DIR" ]; then 49 | echo "Build dir $BUILD_DIR already exists. Abort." 50 | exit 1 51 | fi 52 | 53 | #rm -r $BUILD_DIR 54 | mkdir -p $BUILD_DIR/pylon 55 | pushd $BUILD_DIR/pylon 56 | tar -xzf $PYLON_TGZ 57 | 58 | # cope with different pylon tarball structures 59 | if [ -f pylon*.tar.gz ]; then #pylon 6.1 structure 60 | tar -xzf pylon*.tar.gz 61 | PYLON_ROOT=$BUILD_DIR/pylon 62 | elif [ -d bin ]; then #the pylon 6.0 nightly that was released for dart-mipi didn't contain an second tarball 63 | PYLON_ROOT=$BUILD_DIR/pylon 64 | elif [ -f pylon-*/pylonSDK-*.tar.gz ]; then # pylon < 6 65 | #extract the inner tar from pylon 5 66 | tar -xzf pylon-*/pylonSDK-*.tar.gz 67 | PYLON_ROOT=$BUILD_DIR/pylon/pylon5 68 | else 69 | echo "Failed to detect and extract the pylon version." 70 | exit 1 71 | fi 72 | 73 | popd 74 | 75 | echo "Using pylon SDK from $PYLON_ROOT" 76 | export PYLON_ROOT 77 | 78 | $PYTHON setup.py clean 79 | 80 | if [ -z "$DISABLE_TESTS" ]; then 81 | # Limit numpy version due to issues with build system on armv7l 82 | if [[ "$UPDATE_PLATFORM_TAG" == *"armv7l"* ]]; then 83 | $PYTHON -m pip install --user "numpy<=1.25.2" 84 | else 85 | $PYTHON -m pip install --user numpy 86 | fi 87 | 88 | #For now failed tests are accepted until all are fixed 89 | $PYTHON setup.py test 90 | fi 91 | 92 | $PYTHON setup.py bdist_wheel 93 | 94 | #try to use auditwheel to update the platform tag 95 | if [ -n "$UPDATE_PLATFORM_TAG" ]; then 96 | mkdir $BUILD_DIR/dist 97 | mv dist/*.whl $BUILD_DIR/dist/ 98 | auditwheel repair --plat $UPDATE_PLATFORM_TAG --wheel-dir dist $BUILD_DIR/dist/*.whl 99 | fi 100 | 101 | rm -r "$BUILD_DIR" 102 | 103 | popd 104 | 105 | 106 | -------------------------------------------------------------------------------- /scripts/build/msvc_build_wrapper.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: To build extensions for 64 bit Python 3, we need to configure environment 3 | :: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: 4 | :: MS Windows SDK for Windows 7 and .NET Framework 4 5 | :: 6 | :: More details at: 7 | :: https://github.com/cython/cython/wiki/CythonExtensionsOnWindows 8 | 9 | IF "%DISTUTILS_USE_SDK%"=="1" ( 10 | ECHO Configuring environment to build with MSVC on a 64bit architecture 11 | ECHO Using Windows SDK 7.1 12 | "C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup\WindowsSdkVer.exe" -q -version:v7.1 13 | CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /release 14 | SET MSSdk=1 15 | REM Need the following to allow tox to see the SDK compiler 16 | SET TOX_TESTENV_PASSENV=DISTUTILS_USE_SDK MSSdk INCLUDE LIB 17 | ) ELSE ( 18 | ECHO Using default MSVC build environment 19 | ) 20 | 21 | CALL %* 22 | -------------------------------------------------------------------------------- /scripts/builddoxy2swig/HOW TO BUILD: -------------------------------------------------------------------------------- 1 | The script builddoxygen.py generates DoxyGenApi.i and DoxyPylon.i from your Pylon installation. 2 | 3 | To rebuild the swigfiles from your Pylon installation 4 | you need the following programs: 5 | 6 | - Python (we used 3.5) 7 | - Some version of Pylon (pylon 5.0.7 Build 9644 was used). 8 | - Doxygen 1.5.9 (newest version at the time(1.8.3) does not parse XML correctly) 9 | 10 | -------------------------------------------------------------------------------- /scripts/builddoxy2swig/builddoxygen.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import os 3 | import warnings 4 | import shutil 5 | 6 | #check if PYLON_DEV_DIR is set 7 | print("Is Pylon installed?") 8 | pylonDevDir = os.environ.get("PYLON_DEV_DIR") 9 | if not pylonDevDir: 10 | raise EnvironmentError("PYLON_DEV_DIR is not set") 11 | 12 | #check if doxygen is installed 13 | print("Is Doxygen installed?") 14 | doxyVersion = subprocess.getoutput("doxygen --version") 15 | print ("Version: ", doxyVersion); 16 | if doxyVersion != "1.5.9": 17 | warnings.warn("Only testet with version 1.5.9 other versions of doxygen may not work.") 18 | 19 | #gets the path of this programm. 20 | path = os.path.dirname(os.path.realpath(__file__)); 21 | 22 | 23 | #deletes the xml folder if present 24 | shutil.rmtree(path+"\\xml") 25 | 26 | #runs doxygen over the GenApi folder in PYLON_DEV_DIR/includes 27 | os.system("( type "+path+"\\Doxyfile & echo INPUT=\""+pylonDevDir+"\\include\\GenApi\" & echo OUTPUT_DIRECTORY=\""+path+"\") | doxygen.exe -") 28 | 29 | #runs doxy2swig for GenApi 30 | subprocess.call("python "+path+"\\doxy2swig\\doxy2swig.py \""+path+"\\xml\index.xml\" \""+path[:-22]+"src\\genicam\\DoxyGenApi.i\""); 31 | 32 | 33 | 34 | #runs doxygen over the pylon folder in PYLON_DEV_DIR/includes 35 | os.system("( type "+path+"\\Doxyfile & echo INPUT=\""+pylonDevDir+"\\include\\pylon\" & echo OUTPUT_DIRECTORY=\""+path+"\") | doxygen.exe -") 36 | 37 | #runs doxy2swig for pylon 38 | subprocess.call("python "+path+"\\doxy2swig\\doxy2swig.py \""+path+"\\xml\index.xml\" \""+path[:-22]+"src\\pylon\\DoxyPylon.i\""); 39 | 40 | #deletes the xml folder if present 41 | shutil.rmtree(path+"\\xml") 42 | 43 | 44 | #runs doxygen over the pylon folder in PYLON_DEV_DIR/includes 45 | os.system("( type "+path+"\\Doxyfile & echo INPUT=\""+pylonDevDir+"\\include\\pylondataprocessing\" & echo OUTPUT_DIRECTORY=\""+path+"\") | doxygen.exe -") 46 | 47 | #runs doxy2swig for pylon 48 | subprocess.call("python "+path+"\\doxy2swig\\doxy2swig.py \""+path+"\\xml\index.xml\" \""+path[:-22]+"src\\pylondataprocessing\\DoxyPylonDataProcessing.i\""); 49 | 50 | #deletes the xml folder if present 51 | shutil.rmtree(path+"\\xml") 52 | 53 | print("Successfully generated pylon/DoxyPylon.i, genapi/DoxyGenApi.i and pylondataprocessing/DoxyPylonDataProcessing.i") 54 | -------------------------------------------------------------------------------- /scripts/builddoxy2swig/doxy2swig/LICENSE: -------------------------------------------------------------------------------- 1 | Original work Copyright (c) Prabhu Ramachandran 2 | Modified work Copyright (c) 2015, Michael Thon 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /scripts/check_output.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # extract the relevant type information from the generated modules 4 | # run 5 | 6 | type_def_re = re.compile("(#define SWIGTYPE_p_.*)") 7 | method_def_re = re.compile("(\s*\{\s*\(char\s*\*\)\".*)") 8 | 9 | results = [] 10 | 11 | for f in ("../generated/genicam_wrap.cpp", "../generated/pylon_wrap.cpp"): 12 | for l in open(f).readlines(): 13 | l = l.rstrip("\n") 14 | m = type_def_re.match(l) 15 | if m: 16 | results.append(l) 17 | m = method_def_re.match(l) 18 | if m: 19 | results.append(l) 20 | 21 | results.sort() 22 | 23 | with open("reference_types.txt", "w") as fp: 24 | for r in results: 25 | fp.write(r) 26 | fp.write("\n") 27 | -------------------------------------------------------------------------------- /scripts/generatedoc/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/scripts/generatedoc/__init__.py -------------------------------------------------------------------------------- /scripts/generatedoc/generatedoc.py: -------------------------------------------------------------------------------- 1 | def visiblename(name, all=None, obj=None): 2 | 3 | """Decide whether to show documentation on a variable.""" 4 | 5 | # Certain special names are redundant or internal. 6 | 7 | # XXX Remove __initializing__? 8 | 9 | if name in {'__author__', '__builtins__', '__cached__', '__credits__', 10 | 11 | '__date__', '__doc__', '__file__', '__spec__', 12 | 13 | '__loader__', '__module__', '__name__', '__package__', 14 | 15 | '__path__', '__qualname__', '__slots__', '__version__'}: 16 | 17 | return 0 18 | 19 | if name.endswith("_swigregister"): 20 | return 0 21 | 22 | if name.startswith("__swig"): 23 | return 0 24 | 25 | # Private names are hidden, but special names are displayed. 26 | 27 | if name.startswith('__') and name.endswith('__'): return 1 28 | 29 | # Namedtuples have public fields and methods with a single leading underscore 30 | 31 | if name.startswith('_') and hasattr(obj, '_fields'): 32 | 33 | return True 34 | 35 | if all is not None: 36 | 37 | # only document that which the programmer exported in __all__ 38 | 39 | return name in all 40 | 41 | else: 42 | 43 | return not name.startswith('_') 44 | 45 | """ 46 | 47 | This script generates a HTML doc from the pypylon installation 48 | 49 | """ 50 | if __name__ == '__main__': 51 | import pydoc 52 | pydoc.visiblename = visiblename 53 | from pypylon import pylon, genicam 54 | 55 | pydoc.writedoc(pylon) 56 | pydoc.writedoc(genicam) 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/genicam/ChunkAdapter.i: -------------------------------------------------------------------------------- 1 | %rename (ChunkAdapter) GENAPI_NAMESPACE::CChunkAdapter; 2 | %include 3 | %pythoncode %{ 4 | CChunkAdapter = ChunkAdapter 5 | %} -------------------------------------------------------------------------------- /src/genicam/ChunkAdapterGEV.i: -------------------------------------------------------------------------------- 1 | %rename (ChunkAdapterGEV) GENAPI_NAMESPACE::CChunkAdapterGEV; 2 | %include 3 | %pythoncode %{ 4 | CChunkAdapterGEV = ChunkAdapterGEV 5 | %} -------------------------------------------------------------------------------- /src/genicam/ChunkAdapterGeneric.i: -------------------------------------------------------------------------------- 1 | %rename (ChunkAdapterGeneric) GENAPI_NAMESPACE::CChunkAdapterGeneric; 2 | %include 3 | %pythoncode %{ 4 | CChunkAdapterGeneric = ChunkAdapterGeneric 5 | %} -------------------------------------------------------------------------------- /src/genicam/ChunkAdapterU3V.i: -------------------------------------------------------------------------------- 1 | %rename (ChunkAdapterU3V) GENAPI_NAMESPACE::CChunkAdapterU3V; 2 | %include 3 | %pythoncode %{ 4 | CChunkAdapterU3V = ChunkAdapterU3V 5 | %} 6 | -------------------------------------------------------------------------------- /src/genicam/ChunkPort.i: -------------------------------------------------------------------------------- 1 | %rename (ChunkPort) GENAPI_NAMESPACE::CChunkPort; 2 | %include 3 | %pythoncode %{ 4 | CChunkPort = ChunkPort 5 | %} 6 | %extend GENAPI_NAMESPACE::CChunkPort{ 7 | PROP_GET(AccessMode) 8 | PROP_GET(PrincipalInterfaceType) 9 | } -------------------------------------------------------------------------------- /src/genicam/Container.i: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // (c) 2012 by Basler Vision Technologies 3 | // Section: Vision Components 4 | // Project: GenApi 5 | // Author: Thies Moeller 6 | // $Header$ 7 | // 8 | // License: This file is published under the license of the EMVA GenICam Standard Group. 9 | // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. 10 | // If for some reason you are missing this file please contact the EMVA or visit the website 11 | // (http://www.genicam.org) for a full copy. 12 | // 13 | // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" 14 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP 17 | // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | // POSSIBILITY OF SUCH DAMAGE. 24 | //----------------------------------------------------------------------------- 25 | 26 | 27 | namespace std{ 28 | %template(node_vector) std::vector; 29 | %template(value_vector) std::vector; 30 | %template(string_vector) std::vector; 31 | } 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/genicam/EnumClasses.i: -------------------------------------------------------------------------------- 1 | %ignore EGenApiSchemaVersionClass; 2 | %include ; 3 | -------------------------------------------------------------------------------- /src/genicam/EventAdapter.i: -------------------------------------------------------------------------------- 1 | %rename (EventAdapter) GENAPI_NAMESPACE::CEventAdapter; 2 | %include ; 3 | %pythoncode %{ 4 | CEventAdapter = EventAdapter 5 | %} -------------------------------------------------------------------------------- /src/genicam/EventAdapterGEV.i: -------------------------------------------------------------------------------- 1 | %rename (EventAdapterGEV) GENAPI_NAMESPACE::CEventAdapterGEV; 2 | %ignore GVCP_REQUEST_HEADER; 3 | %ignore GVCP_EVENT_ITEM_BASIC; 4 | %ignore GVCP_EVENT_ITEM; 5 | %ignore GVCP_EVENT_REQUEST; 6 | %ignore GVCP_EVENTDATA_REQUEST; 7 | %ignore GVCP_EVENT_ITEM_EXTENDED_ID; 8 | %ignore GVCP_EVENT_REQUEST_EXTENDED_ID; 9 | %ignore GVCP_EVENTDATA_REQUEST_EXTENDED_ID; 10 | %ignore GVCP_MESSAGE_TAGS; 11 | %ignore DeliverEventMessage; 12 | 13 | //TODO fix for Linux 14 | #define _MSC_VER 15 | %include ; 16 | #undef _MSC_VER 17 | 18 | %pythoncode %{ 19 | CEventAdapterGEV = EventAdapterGEV 20 | %} -------------------------------------------------------------------------------- /src/genicam/EventAdapterGeneric.i: -------------------------------------------------------------------------------- 1 | %rename (EventAdapterGeneric) GENAPI_NAMESPACE::CEventAdapterGeneric; 2 | %include ; 3 | %pythoncode %{ 4 | CEventAdapterGeneric = EventAdapterGeneric 5 | %} -------------------------------------------------------------------------------- /src/genicam/EventAdapterU3V.i: -------------------------------------------------------------------------------- 1 | %rename (EventAdapterU3V) GENAPI_NAMESPACE::CEventAdapterU3V; 2 | %ignore U3V_COMMAND_HEADER; 3 | %ignore U3V_EVENT_DATA; 4 | %ignore U3V_EVENT_MESSAGE; 5 | 6 | //TODO fix for Linux 7 | #define _MSC_VER 8 | %include ; 9 | #undef _MSC_VER 10 | 11 | %pythoncode %{ 12 | CEventAdapterU3V = EventAdapterU3V 13 | %} 14 | -------------------------------------------------------------------------------- /src/genicam/EventPort.i: -------------------------------------------------------------------------------- 1 | %rename (EventPort) GENAPI_NAMESPACE::CEventPort; 2 | %include ; 3 | %pythoncode %{ 4 | CEventPort = EventPort 5 | %} 6 | -------------------------------------------------------------------------------- /src/genicam/IBase.i: -------------------------------------------------------------------------------- 1 | %ignore CBaseRef; 2 | //TODO Ask Thies why the destructor was left out 3 | %ignore ~IBase; 4 | #define DOXYGEN_IGNORE 5 | %include ; 6 | #undef DOXYGEN_IGNORE -------------------------------------------------------------------------------- /src/genicam/IBoolean.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::IBoolean; 2 | %ignore CBooleanRef; 3 | %extend GENAPI_NAMESPACE::IBoolean { 4 | PROP_GETSET(Value) 5 | } 6 | %include ; -------------------------------------------------------------------------------- /src/genicam/ICategory.i: -------------------------------------------------------------------------------- 1 | %ignore INode; 2 | %nodefaultdtor GENAPI_NAMESPACE::ICategory; 3 | namespace GENAPI_NAMESPACE { 4 | typedef value_vector FeatureList_t; 5 | }; 6 | %extend GENAPI_NAMESPACE::ICategory{ 7 | PROP_GET(Features) 8 | }; 9 | #define DOXYGEN_IGNORE 10 | %include ; 11 | #undef DOXYGEN_IGNORE 12 | 13 | -------------------------------------------------------------------------------- /src/genicam/IChunkPort.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::IChunkPort; 2 | %include ; 3 | -------------------------------------------------------------------------------- /src/genicam/ICommand.i: -------------------------------------------------------------------------------- 1 | %ignore CCommandRef; 2 | %nodefaultdtor GENAPI_NAMESPACE::ICommand; 3 | %include ; 4 | -------------------------------------------------------------------------------- /src/genicam/IDeviceInfo.i: -------------------------------------------------------------------------------- 1 | #define Build OUTPUT 2 | #define Version_t GENICAM_NAMESPACE::Version_t 3 | 4 | %nodefaultdtor GENAPI_NAMESPACE::IDeviceInfo; 5 | 6 | %include ; 7 | -------------------------------------------------------------------------------- /src/genicam/IEnumEntry.i: -------------------------------------------------------------------------------- 1 | %ignore CEnumEntryRef; 2 | %nodefaultdtor GENAPI_NAMESPACE::IEnumEntry; 3 | %include ; 4 | %extend GENAPI_NAMESPACE::IEnumEntry { 5 | PROP_GET(Value) 6 | PROP_GET(Symbolic) 7 | PROP_GET(NumericValue) 8 | %pythoncode %{ 9 | def __call__( self ): 10 | return self.GetValue() 11 | %} 12 | } 13 | -------------------------------------------------------------------------------- /src/genicam/IEnumeration.i: -------------------------------------------------------------------------------- 1 | 2 | %ignore GENAPI_NAMESPACE::IEnumeration::operator*(); 3 | %nodefaultdtor GENAPI_NAMESPACE::IEnumeration; 4 | 5 | %extend GENAPI_NAMESPACE::IEnumeration { 6 | virtual GENICAM_NAMESPACE::gcstring operator()(){ 7 | return $self->GetCurrentEntry()->GetSymbolic(); 8 | } 9 | 10 | virtual GENICAM_NAMESPACE::gcstring GetValue(){ 11 | return $self->GetCurrentEntry()->GetSymbolic(); 12 | } 13 | 14 | virtual void SetValue( GENICAM_NAMESPACE::gcstring entry ){ 15 | $self->FromString(entry); 16 | } 17 | }; 18 | 19 | 20 | %extend GENAPI_NAMESPACE::IEnumeration { 21 | PROP_GET(Symbolics) 22 | PROP_GET(Entries) 23 | PROP_GETSET(IntValue) 24 | PROP_GETSET(Value) 25 | }; 26 | 27 | %include ; 28 | -------------------------------------------------------------------------------- /src/genicam/IFloat.i: -------------------------------------------------------------------------------- 1 | #define DOXYGEN_IGNORE 2 | %nodefaultdtor GENAPI_NAMESPACE::IFloat; 3 | namespace GENAPI_NAMESPACE { 4 | class IInteger; 5 | class IEnumeration; 6 | } 7 | %extend GENAPI_NAMESPACE::IFloat { 8 | //! gets the interface of an integer alias node. 9 | IInteger *GetIntAlias() 10 | { 11 | IInteger *p_int; 12 | p_int = dynamic_cast($self->GetNode()->GetCastAlias()); 13 | if (NULL == p_int) 14 | throw LOGICAL_ERROR_EXCEPTION( "Float node as no Int alias" ); 15 | return p_int; 16 | } 17 | 18 | //! gets the interface of an enum alias node. 19 | IEnumeration *GetEnumAlias() 20 | { 21 | IEnumeration *p_enum; 22 | p_enum = dynamic_cast($self->GetNode()->GetCastAlias()); 23 | if (NULL == p_enum) 24 | throw LOGICAL_ERROR_EXCEPTION( "Float node as no Enum alias" ); 25 | return p_enum; 26 | } 27 | PROP_GETSET(Value) 28 | PROP_GET(Min) 29 | PROP_GET(Max) 30 | PROP_GET(IncMode); 31 | PROP_GET(Inc) 32 | PROP_GET(ListOfValidValues) 33 | PROP_GET(Representation) 34 | PROP_GET(Unit) 35 | PROP_GET(DisplayNotation) 36 | PROP_GET(DisplayPrecision) 37 | PROP_GET(IntAlias) 38 | PROP_GET(EnumAlias) 39 | } 40 | %ignore GENAPI_NAMESPACE::IFloat::operator*(); 41 | %include ; -------------------------------------------------------------------------------- /src/genicam/IInteger.i: -------------------------------------------------------------------------------- 1 | #define DOXYGEN_IGNORE 2 | %nodefaultdtor GENAPI_NAMESPACE::IInteger; 3 | %ignore GENAPI_NAMESPACE::IInteger::operator*(); 4 | %extend GENAPI_NAMESPACE::IInteger { 5 | //! gets the interface of an integer alias node. 6 | IFloat *GetFloatAlias() 7 | { 8 | IFloat *p_float; 9 | p_float = dynamic_cast($self->GetNode()->GetCastAlias()); 10 | if (NULL == p_float) 11 | throw LOGICAL_ERROR_EXCEPTION( "Int node as no Float alias" ); 12 | return p_float; 13 | }; 14 | 15 | //! Set the register's contents 16 | /*! 17 | \param pBuffer The buffer containing the data to set 18 | \param Length The number of bytes in pBuffer 19 | \param Verify Enables AccessMode and Range verification (default = true) 20 | */ 21 | virtual void Set(const uint8_t *pBuffer, int64_t Length, bool Verify = true){ 22 | IRegister *p_reg; 23 | p_reg = dynamic_cast($self); 24 | if (NULL == p_reg) 25 | throw LOGICAL_ERROR_EXCEPTION( "Pure Integer has no Set" ); 26 | p_reg->Set(pBuffer, Length, Verify); 27 | }; 28 | 29 | //! Fills a buffer with the register's contents 30 | /*! 31 | \param pBuffer The buffer receiving the data to read 32 | \param Length The number of bytes to retrieve 33 | \param Verify Enables Range verification (default = false). The AccessMode is always checked 34 | \param IgnoreCache If true the value is read ignoring any caches (default = false) 35 | */ 36 | virtual void Get(uint8_t *pBuffer, int64_t Length, bool Verify = false, bool IgnoreCache = false){ 37 | IRegister *p_reg; 38 | p_reg = dynamic_cast($self); 39 | if (NULL == p_reg) 40 | throw LOGICAL_ERROR_EXCEPTION( "Pure Integer has no Set" ); 41 | p_reg->Get(pBuffer, Length, Verify, IgnoreCache); 42 | }; 43 | 44 | //! Retrieves the Length of the register [Bytes] 45 | virtual int64_t GetLength(){ 46 | IRegister *p_reg; 47 | p_reg = dynamic_cast($self); 48 | if (NULL == p_reg) 49 | throw LOGICAL_ERROR_EXCEPTION( "Pure Integer has no Set" ); 50 | return p_reg->GetLength(); 51 | }; 52 | 53 | //! Retrieves the Address of the register 54 | virtual int64_t GetAddress(){ 55 | IRegister *p_reg; 56 | p_reg = dynamic_cast($self); 57 | if (NULL == p_reg) 58 | throw LOGICAL_ERROR_EXCEPTION( "Pure Integer has no Set" ); 59 | return p_reg->GetAddress(); 60 | }; 61 | 62 | PROP_GETSET(Value) 63 | PROP_GET(Min) 64 | PROP_GET(Max) 65 | PROP_GET(IncMode) 66 | PROP_GET(Inc) 67 | PROP_GET(ListOfValidValues) 68 | PROP_GET(Representation) 69 | PROP_GET(Unit) 70 | PROP_GET(FloatAlias) 71 | PROP_GET(Address) 72 | PROP_GET(Length) 73 | 74 | } // extend 75 | %include ; -------------------------------------------------------------------------------- /src/genicam/INodeMap.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::INodeMap; 2 | %nodefaultctor GENAPI_NAMESPACE::INodeMap; 3 | namespace GENAPI_NAMESPACE { 4 | class IDeviceInfo; 5 | } 6 | %extend GENAPI_NAMESPACE::INodeMap { 7 | PROP_GET(DeviceName) 8 | //! gets the interface of the DeviceInfo 9 | IDeviceInfo *GetDeviceInfo() 10 | { 11 | IDeviceInfo *p_di; 12 | p_di = dynamic_cast($self); 13 | if (NULL == p_di) 14 | throw LOGICAL_ERROR_EXCEPTION( "Nodemap has no deviceinfo" ); 15 | return p_di; 16 | }; 17 | 18 | PROP_GET(DeviceInfo) 19 | %pythoncode %{ 20 | def __getattr__(self, attribute): 21 | if attribute in self.__dict__ or attribute in ( "thisown","this") or attribute.startswith("__"): 22 | return object.__getattr__(self, attribute) 23 | else: 24 | return self.GetNode(attribute) 25 | 26 | def __setattr__(self, attribute, val): 27 | if attribute in self.__dict__ or attribute in ( "thisown","this") or attribute.startswith("__"): 28 | object.__setattr__(self, attribute, val) 29 | else: 30 | warnings.warn(f"Setting a feature value by direct assignment is deprecated. Use .{attribute}.Value = {val}", DeprecationWarning, stacklevel=2) 31 | self.GetNode(attribute).SetValue(val) 32 | 33 | def __dir__(self): 34 | l = dir(type(self)) 35 | l.extend(self.__dict__.keys()) 36 | nodes = [] 37 | try: 38 | nodes = self.GetNodeMap().GetNodes() 39 | features = filter(lambda n: n.GetNode().IsFeature(), nodes) 40 | l.extend(x.GetNode().GetName() for x in features) 41 | except: 42 | pass 43 | try: 44 | chunks = filter(lambda n: "ChunkData" in (f.Name for f in n.GetParents()), nodes) 45 | l.extend(x.GetNode().GetName() for x in chunks) 46 | except: 47 | pass 48 | return sorted(set(l)) 49 | %} 50 | } 51 | %include ; 52 | -------------------------------------------------------------------------------- /src/genicam/IPort.i: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // (c) 2012 by Basler Vision Technologies 3 | // Section: Vision Components 4 | // Project: GenApi 5 | // Author: Thies Moeller 6 | // $Header$ 7 | // 8 | 9 | %nodefaultdtor GENAPI_NAMESPACE::IPort; 10 | 11 | 12 | namespace GENAPI_NAMESPACE 13 | { 14 | //************************************************************* 15 | // IPort interface 16 | //************************************************************* 17 | 18 | /** 19 | \brief Interface for ports 20 | \ingroup GenApi_PublicInterface 21 | */ 22 | class IPort : virtual public IBase 23 | { 24 | private: 25 | IPort(); 26 | }; 27 | }; 28 | 29 | 30 | %extend GENAPI_NAMESPACE::IPort { 31 | virtual void Read(int64_t Address, void *pBuffer, int64_t Length){ 32 | $self->Read( pBuffer, Address,Length); 33 | }; 34 | 35 | virtual void Write(int64_t Address, const void *pBuffer, int64_t Length){ 36 | $self->Write( pBuffer, Address,Length); 37 | }; 38 | 39 | virtual GENAPI_NAMESPACE::INode* GetNode() { return dynamic_cast($self); }; 40 | 41 | //! Get the Id of the chunk the port should be attached to 42 | virtual GENICAM_NAMESPACE::gcstring GetChunkID() const { 43 | return dynamic_cast($self)->GetChunkID(); 44 | }; 45 | 46 | virtual EYesNo CacheChunkData() const { 47 | return dynamic_cast($self)->CacheChunkData(); 48 | }; 49 | 50 | //! Determines if the port adapter must perform an endianess swap 51 | virtual EYesNo GetSwapEndianess() { 52 | return dynamic_cast($self)->GetSwapEndianess(); 53 | }; 54 | 55 | PROP_GET(Node); 56 | PROP_GET(ChunkID); 57 | 58 | }; 59 | 60 | -------------------------------------------------------------------------------- /src/genicam/IPortConstruct.i: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------- 2 | // (c) 2012 by Basler Vision Technologies 3 | // Section: Vision Components 4 | // Project: GenApi 5 | // Author: Thies Moeller 6 | // $Header$ 7 | // 8 | // License: This file is published under the license of the EMVA GenICam Standard Group. 9 | // A text file describing the legal terms is included in your installation as 'GenICam_license.pdf'. 10 | // If for some reason you are missing this file please contact the EMVA or visit the website 11 | // (http://www.genicam.org) for a full copy. 12 | // 13 | // THIS SOFTWARE IS PROVIDED BY THE EMVA GENICAM STANDARD GROUP "AS IS" 14 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 | // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 | // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE EMVA GENICAM STANDARD GROUP 17 | // OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 18 | // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 | // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 | // OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 | // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 | // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | // POSSIBILITY OF SUCH DAMAGE. 24 | //----------------------------------------------------------------------------- 25 | 26 | 27 | %nodefaultdtor GENAPI_NAMESPACE::IPortConstruct; 28 | 29 | namespace GENAPI_NAMESPACE 30 | { 31 | //************************************************************* 32 | // IPortContruct interface 33 | //************************************************************* 34 | 35 | /** 36 | \brief Interface for ports 37 | \ingroup GenApi_PublicImpl 38 | */ 39 | class IPortConstruct: virtual public IPort 40 | { 41 | public: 42 | ////! Sets pointer the real port implementation; this function may called only once 43 | //virtual void SetPortImpl(IPort* pPort) = 0; 44 | 45 | //! Determines if the port adapter must perform an endianess swap 46 | virtual EYesNo GetSwapEndianess() = 0; 47 | }; 48 | } 49 | 50 | -------------------------------------------------------------------------------- /src/genicam/IPortRecorder.i: -------------------------------------------------------------------------------- 1 | %ignore CPortRecorderRef; 2 | %nodefaultdtor GENAPI_NAMESPACE::IPortWriteList; 3 | %nodefaultdtor GENAPI_NAMESPACE::IPortReplay; 4 | %nodefaultdtor GENAPI_NAMESPACE::IPortRecorder; 5 | %ignore GENAPI_NAMESPACE::CPortRecorderRefT; 6 | %include ; 7 | -------------------------------------------------------------------------------- /src/genicam/IRegister.i: -------------------------------------------------------------------------------- 1 | 2 | %nodefaultdtor GENAPI_NAMESPACE::IRegister; 3 | %extend GENAPI_NAMESPACE::IRegister { 4 | PROP_GET(Length) 5 | PROP_GET(Address) 6 | }; 7 | 8 | #define DOXYGEN_IGNORE 9 | %include ; 10 | %pythoncode %{ 11 | def GetAll(self): 12 | return self.Get(self.GetLength()) 13 | IRegister.GetAll = GetAll 14 | %} 15 | -------------------------------------------------------------------------------- /src/genicam/ISelector.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::ISelector; 2 | %ignore GENAPI_NAMESPACE::CSelectorRef; 3 | %ignore IsSelector; 4 | %ignore GetSelectedFeatures; 5 | %ignore GetSelectingFeatures; 6 | %include ; 7 | -------------------------------------------------------------------------------- /src/genicam/ISelectorDigit.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::ISelectorDigit; 2 | %ignore ~ISelectorDigit(); 3 | %include ; -------------------------------------------------------------------------------- /src/genicam/IString.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::IString; 2 | %extend GENAPI_NAMESPACE::IString { 3 | //! gets the length of string if it is a stringreg. 4 | //! Retrieves the Length of the register [Bytes] 5 | virtual int64_t GetLength() 6 | { 7 | IRegister *p_reg; 8 | p_reg = dynamic_cast($self); 9 | if (NULL == p_reg) 10 | throw LOGICAL_ERROR_EXCEPTION( "Pure string has no Length" ); 11 | return p_reg->GetLength(); 12 | }; 13 | PROP_GETSET(Value) 14 | PROP_GET(MaxLength) 15 | PROP_GET(Length) 16 | }; 17 | %ignore GENAPI_NAMESPACE::IString::operator*(); 18 | #define DOXYGEN_IGNORE 19 | %include ; 20 | -------------------------------------------------------------------------------- /src/genicam/IValue.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::IValue; 2 | %extend GENAPI_NAMESPACE::IValue { 3 | PROP_GET(Node); 4 | } 5 | #define DOXYGEN_IGNORE 6 | %include ; 7 | -------------------------------------------------------------------------------- /src/genicam/Reference.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::IReference; 2 | %nodefaultdtor GENAPI_NAMESPACE::IEnumReference; 3 | %include ; 4 | -------------------------------------------------------------------------------- /src/genicam/SelectorSet.i: -------------------------------------------------------------------------------- 1 | 2 | %include ; 3 | -------------------------------------------------------------------------------- /src/genicam/Types.i: -------------------------------------------------------------------------------- 1 | %ignore EGenApiSchemaVersion; 2 | %rename (_None) None; 3 | %include ; 4 | -------------------------------------------------------------------------------- /src/genicam/Version.i: -------------------------------------------------------------------------------- 1 | namespace GENICAM_NAMESPACE 2 | { 3 | //! version 4 | 5 | %rename(Version) Version_t; 6 | struct Version_t 7 | { 8 | uint16_t Major; //!> a is incompatible with b if a != b 9 | uint16_t Minor; //!> a is incompatible b a > b 10 | uint16_t SubMinor; //!> a is aways compatible with b 11 | }; 12 | }; 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/genicam/staging/CNodeMapRef.i: -------------------------------------------------------------------------------- 1 | namespace GENAPI_NAMESPACE 2 | { 3 | class IDeviceInfo; 4 | } 5 | %include ; 6 | 7 | -------------------------------------------------------------------------------- /src/genicam/staging/INode.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::INode; 2 | %nodefaultctor GENAPI_NAMESPACE::INodeMap; 3 | %rename(CombineVisibility) Combine(EVisibility Peter, EVisibility Paul); 4 | %rename(CombineCachingMode) Combine(ECachingMode Peter, ECachingMode Paul); 5 | %extend GENAPI_NAMESPACE::INode { 6 | 7 | //! Retrieves a property plus an additional attribute by name 8 | /*! If a property has multiple values/attribute they come with Tabs as delimiters */ 9 | virtual void GetProperty(const GENICAM_NAMESPACE::gcstring& PropertyName, GENICAM_NAMESPACE::gcstring& ValueStr, GENICAM_NAMESPACE::gcstring& AttributeStr) 10 | { 11 | bool result = $self->GetProperty(PropertyName, ValueStr, AttributeStr); 12 | if (!result) 13 | throw LOGICAL_ERROR_EXCEPTION( "property does not exit" ); 14 | }; 15 | 16 | //! true iff this feature selects a group of features 17 | virtual bool IsSelector() const { 18 | return dynamic_cast($self)->IsSelector(); 19 | } 20 | 21 | //! retrieve the group of selected features 22 | virtual void GetSelectedFeatures( GENAPI_NAMESPACE::FeatureList_t& thelist) const{ 23 | return dynamic_cast($self)->GetSelectedFeatures( thelist); 24 | } 25 | 26 | //! retrieve the group of features selecting this node 27 | virtual void GetSelectingFeatures( GENAPI_NAMESPACE::FeatureList_t& thelist) const { 28 | return dynamic_cast($self)->GetSelectingFeatures( thelist); 29 | } 30 | 31 | virtual CallbackHandleType RegisterCallback( CNodeCallback *INPUT ) = 0; 32 | 33 | PROP_GET(Name) 34 | PROP_GET(NameSpace) 35 | PROP_GET(Visibility) 36 | PROP_GET(CachingMode) 37 | PROP_GET(PollingTime) 38 | PROP_GET(ToolTip) 39 | PROP_GET(Description) 40 | PROP_GET(DisplayName) 41 | PROP_GET(DeviceName) 42 | PROP_GET(Children) 43 | PROP_GET(Parents) 44 | PROP_GET(NodeMap) 45 | PROP_GET(EventID) 46 | PROP_GET(PropertyNames) 47 | PROP_GET(Alias) 48 | PROP_GET(CastAlias) 49 | PROP_GET(DocuURL) 50 | PROP_GET(PrincipalInterfaceType) 51 | 52 | } 53 | %ignore GENAPI_NAMESPACE::INode::GetProperty(const GENICAM_NAMESPACE::gcstring& PropertyName, GENICAM_NAMESPACE::gcstring& ValueStr, GENICAM_NAMESPACE::gcstring& AttributeStr); 54 | 55 | %ignore CNodeCallback; 56 | %ignore RegisterCallback( CNodeCallback *pCallback ); 57 | #define pCallback INPUT 58 | 59 | %include ; 60 | 61 | -------------------------------------------------------------------------------- /src/genicam/staging/IPort.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::IPort; 2 | %extend GENAPI_NAMESPACE::IPort { 3 | virtual void Read(int64_t Address, void *pBuffer, int64_t Length){ 4 | $self->Read( pBuffer, Address,Length); 5 | }; 6 | 7 | virtual void Write(int64_t Address, const void *pBuffer, int64_t Length){ 8 | $self->Write( pBuffer, Address,Length); 9 | }; 10 | 11 | virtual GENAPI_NAMESPACE::INode* GetNode() { return dynamic_cast($self); }; 12 | 13 | //! Get the Id of the chunk the port should be attached to 14 | virtual GENICAM_NAMESPACE::gcstring GetChunkID() const { 15 | return dynamic_cast($self)->GetChunkID(); 16 | }; 17 | 18 | virtual EYesNo CacheChunkData() const { 19 | return dynamic_cast($self)->CacheChunkData(); 20 | }; 21 | 22 | //! Determines if the port adapter must perform an endianess swap 23 | virtual EYesNo GetSwapEndianess() { 24 | return dynamic_cast($self)->GetSwapEndianess(); 25 | }; 26 | 27 | PROP_GET(Node); 28 | PROP_GET(ChunkID); 29 | 30 | }; 31 | 32 | %ignore GENAPI_NAMESPACE::IPort::Read(void *, int64_t, int64_t); 33 | %ignore GENAPI_NAMESPACE::IPort::Write(const void *, int64_t, int64_t); 34 | 35 | %include 36 | 37 | -------------------------------------------------------------------------------- /src/genicam/staging/IPortConstruct.i: -------------------------------------------------------------------------------- 1 | %nodefaultdtor GENAPI_NAMESPACE::IPortConstruct; 2 | %ignore GENAPI_NAMESPACE::IPortConstruct::SetPortImpl; 3 | %include ; 4 | %rename ("%s") ""; 5 | 6 | -------------------------------------------------------------------------------- /src/genicam/staging/PortImpl.i: -------------------------------------------------------------------------------- 1 | %{ 2 | #include "PyPortImpl.h" 3 | %} 4 | 5 | %nodefaultdtor GENAPI_NAMESPACE::CPortImpl; 6 | %nodefaultctor GENAPI_NAMESPACE::CPortImpl; 7 | 8 | %warnfilter(403) GENAPI_NAMESPACE::CPortImpl; 9 | 10 | %nodefaultdtor GENAPI_NAMESPACE::CPyPortImpl; 11 | %feature("director") GENAPI_NAMESPACE::CPyPortImpl; 12 | 13 | %rename(Read) GENAPI_NAMESPACE::CPyPortImpl::PyRead; 14 | %rename(Write) GENAPI_NAMESPACE::CPyPortImpl::PyWrite; 15 | %rename(CPortImpl) CPyPortImpl; 16 | 17 | 18 | %ignore CPortImpl; 19 | %include ; 20 | %include "PyPortImpl.h"; 21 | 22 | %extend GENAPI_NAMESPACE::CPyPortImpl { 23 | void InvalidateNode(); 24 | }; 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/genicam/staging/readme.md: -------------------------------------------------------------------------------- 1 | # Staging area for rework on the genicam swig interface files 2 | 3 | the genicam interface files are not fully converted into a format which just references 4 | genicam header files 5 | 6 | The files in this directory are an initial step towards a converted format 7 | 8 | -------------------------------------------------------------------------------- /src/pylon/AcquireContinuousConfiguration.i: -------------------------------------------------------------------------------- 1 | %rename(AcquireContinuousConfiguration) Pylon::CAcquireContinuousConfiguration; 2 | %rename(InstantCamera) Pylon::CInstantCamera; 3 | %include -------------------------------------------------------------------------------- /src/pylon/AcquireSingleFrameConfiguration.i: -------------------------------------------------------------------------------- 1 | %rename(InstantCamera) Pylon::CInstantCamera; 2 | %rename(AcquireSingleFrameConfiguration) Pylon::CAcquireSingleFrameConfiguration; 3 | %include 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/pylon/ActionTriggerConfiguration.i: -------------------------------------------------------------------------------- 1 | %rename(ActionTriggerConfiguration) Pylon::CActionTriggerConfiguration; 2 | %rename(InstantCamera) Pylon::CInstantCamera; 3 | 4 | // SWIG does not understand code like this: 'const T var_name(init_value);' 5 | // But it does understand: 'const T var_name = init_value;' 6 | // In the case of 'const uint32_t AllGroupMask(0xffffffff);' we transform the 7 | // former to the latter with this macro: 8 | #define AllGroupMask(x) AllGroupMask=x 9 | 10 | %ignore ActionParameter; 11 | 12 | 13 | %include 14 | -------------------------------------------------------------------------------- /src/pylon/ConfigurationEventHandler.i: -------------------------------------------------------------------------------- 1 | %rename(InstantCamera) Pylon::CInstantCamera; 2 | %rename(ConfigurationEventHandler) Pylon::CConfigurationEventHandler; 3 | %feature("director") Pylon::CConfigurationEventHandler; 4 | 5 | %ignore Pylon::CConfigurationEventHandler::DebugGetEventHandlerRegistrationCount; 6 | %include 7 | -------------------------------------------------------------------------------- /src/pylon/Container.i: -------------------------------------------------------------------------------- 1 | 2 | namespace std 3 | { 4 | %template(tlinfo_vector) std::vector; 5 | %template(interfaceinfo_vector) std::vector; 6 | %template(deviceinfo_vector) std::vector; 7 | } 8 | 9 | namespace Pylon 10 | { 11 | typedef tlinfo_vector TlInfoList_t; 12 | typedef interfaceinfo_vector InterfaceInfoList_t; 13 | typedef deviceinfo_vector DeviceInfoList_t; 14 | } 15 | -------------------------------------------------------------------------------- /src/pylon/Device.i: -------------------------------------------------------------------------------- 1 | %rename (Device) Pylon::IDevice; 2 | %include; 3 | %pythoncode %{ 4 | IDevice = Device 5 | %} 6 | -------------------------------------------------------------------------------- /src/pylon/DeviceInfo.i: -------------------------------------------------------------------------------- 1 | %rename(DeviceInfo) Pylon::CDeviceInfo; 2 | 3 | %include 4 | 5 | #if PYLON_VERSION_MAJOR < 6 6 | 7 | // swig (3.0.12) cannot handle definitions like: 8 | // const char* const ManufacturerInfoKey("ManufacturerInfo"); 9 | // Since there is no need for the string constants defined in DeviceInfo.h, we 10 | // simply rename them and then tell swig to ignore them 11 | 12 | #define ManufacturerInfoKey ManufacturerInfoKeyI= 13 | #define DeviceGUIDKey DeviceGUIDKeyI= 14 | #define VendorIdKey VendorIdKeyI= 15 | #define ProductIdKey ProductIdKeyI= 16 | #define DriverKeyNameKey DriverKeyNameKeyI= 17 | #define UsbDriverTypeKey UsbDriverTypeKeyI= 18 | #define UsbPortVersionBcdKey UsbPortVersionBcdKeyI= 19 | #define SpeedSupportBitmaskKey SpeedSupportBitmaskKeyI= 20 | #define TransferModeKey TransferModeKeyI= 21 | #define BconAdapterLibraryNameKey BconAdapterLibraryNameKeyI= 22 | #define BconAdapterLibraryVersionKey BconAdapterLibraryVersionKeyI= 23 | #define BconAdapterLibraryApiVersionKey BconAdapterLibraryApiVersionKeyI= 24 | #define SupportedBconAdapterApiVersionKey SupportedBconAdapterApiVersionKeyI= 25 | 26 | %ignore ManufacturerInfoKeyI; 27 | %ignore DeviceGUIDKeyI; 28 | %ignore VendorIdKeyI; 29 | %ignore ProductIdKeyI; 30 | %ignore DriverKeyNameKeyI; 31 | %ignore UsbDriverTypeKeyI; 32 | %ignore UsbPortVersionBcdKeyI; 33 | %ignore SpeedSupportBitmaskKeyI; 34 | %ignore TransferModeKeyI; 35 | %ignore BconAdapterLibraryNameKeyI; 36 | %ignore BconAdapterLibraryVersionKeyI; 37 | %ignore BconAdapterLibraryApiVersionKeyI; 38 | %ignore SupportedBconAdapterApiVersionKeyI; 39 | 40 | #endif 41 | 42 | 43 | %ignore DeviceIdxKey; 44 | %include ; 45 | 46 | %pythoncode %{ 47 | CDeviceInfo = DeviceInfo 48 | %} 49 | 50 | -------------------------------------------------------------------------------- /src/pylon/FeaturePersistence.i: -------------------------------------------------------------------------------- 1 | %rename(FeaturePersistence) Pylon::CFeaturePersistence; 2 | 3 | %nodefaultctor Pylon::CFeaturePersistence; 4 | %nodefaultdtor Pylon::CFeaturePersistence; 5 | %include ; 6 | -------------------------------------------------------------------------------- /src/pylon/Image.i: -------------------------------------------------------------------------------- 1 | // We need to include ImagePersistence.h for the definition of EImageFileFormat. 2 | // But supporting Pylon::CImagePersistence would be too convoluted. So we ignore 3 | // that, since PylonImageBase already supports saving and loading images. 4 | %ignore Pylon::CImagePersistence; 5 | %rename (ImagePersistenceOptions) Pylon::CImagePersistenceOptions; 6 | %rename (Image) Pylon::IImage; 7 | %ignore GetBuffer() const; 8 | 9 | %include ; 10 | %include ; 11 | 12 | %pythoncode %{ 13 | IImage = Image 14 | %} 15 | -------------------------------------------------------------------------------- /src/pylon/ImageEventHandler.i: -------------------------------------------------------------------------------- 1 | %rename (ImageEventHandler) Pylon::CImageEventHandler; 2 | %feature("director") Pylon::CImageEventHandler; 3 | 4 | %ignore Pylon::CImageEventHandler::DebugGetEventHandlerRegistrationCount; 5 | %clear Pylon::CGrabResultPtr& grabResult; 6 | %include 7 | 8 | // ========================================= 9 | // = GrabResult smart ptr output 10 | 11 | %typemap(in,numinputs=0) Pylon::CGrabResultPtr& grabResult { 12 | $1 = new CGrabResultPtr(); 13 | } 14 | 15 | %typemap(argout) Pylon::CGrabResultPtr& grabResult{ 16 | Py_DECREF($result); 17 | $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_Pylon__CGrabResultPtr, SWIG_POINTER_OWN ); 18 | $1 = 0; // Now owned by $result, make sure it is not freed later on success 19 | } 20 | 21 | %typemap(freearg) Pylon::CGrabResultPtr& grabResult { 22 | delete $1; 23 | } 24 | -------------------------------------------------------------------------------- /src/pylon/ImageFormatConverter.i: -------------------------------------------------------------------------------- 1 | %rename(ImageFormatConverter) Pylon::CImageFormatConverter; 2 | %ignore CImageFormatConverterImpl; 3 | 4 | // CImageFormatConverter has a nested class (IOutputPixelFormatEnum) which 5 | // is not supported by SWIG. 6 | %ignore Pylon::CImageFormatConverter::IOutputPixelFormatEnum; 7 | 8 | // Not all overloads of 'Convert' and 'ImageHasDestinationFormat' are usable. So we ignore all of them and 9 | // redefine those that we want. 10 | %extend Pylon::CImageFormatConverter { 11 | 12 | // Repeat conversion from IImage. 13 | void Convert(IReusableImage& dst, const IImage& src) 14 | { 15 | $self->Convert(dst, src); 16 | } 17 | // Make sure CGrabResultPtr can be converted directly 18 | void Convert(IReusableImage& dst, const CGrabResultPtr& src) 19 | { 20 | $self->Convert(dst, src); 21 | } 22 | 23 | // Make sure IImage can be converted directly 24 | bool ImageHasDestinationFormat(const IImage& src) 25 | { 26 | return $self->ImageHasDestinationFormat(src); 27 | } 28 | 29 | // Make sure CGrabResultPtr can be converted directly 30 | bool ImageHasDestinationFormat(const CGrabResultPtr& src) 31 | { 32 | return $self->ImageHasDestinationFormat(src); 33 | } 34 | 35 | // Access nested class instance 36 | void SetOutputPixelFormat(EPixelType pxl_fmt) 37 | { 38 | $self->OutputPixelFormat.SetValue(pxl_fmt); 39 | } 40 | EPixelType GetOutputPixelFormat() 41 | { 42 | return $self->OutputPixelFormat.GetValue(); 43 | } 44 | PROP_GETSET(OutputPixelFormat) 45 | }; 46 | 47 | %ignore Pylon::CImageFormatConverter::Convert; 48 | %ignore Pylon::CImageFormatConverter::ImageHasDestinationFormat; 49 | %ignore Pylon::CImageFormatConverter::OutputPixelFormat; 50 | 51 | %include ; 52 | -------------------------------------------------------------------------------- /src/pylon/Info.i: -------------------------------------------------------------------------------- 1 | 2 | %nodefaultdtor Pylon::IProperties; 3 | %ignore CInfoImpl; 4 | %include ; 5 | 6 | -------------------------------------------------------------------------------- /src/pylon/InstantCameraArray.i: -------------------------------------------------------------------------------- 1 | %rename(InstantCameraArray) Pylon::CInstantCameraArray; 2 | 3 | %pythonprepend Pylon::CInstantCameraArray::operator[]( size_t index) %{ 4 | if index >= self.GetSize(): 5 | raise IndexError 6 | %} 7 | %ignore Pylon::CInstantCameraArray::operator[]( size_t index) const; 8 | %rename(__getitem__) Pylon::CInstantCameraArray::operator[]( size_t index); 9 | 10 | 11 | %include ; -------------------------------------------------------------------------------- /src/pylon/InstantCameraParams.i: -------------------------------------------------------------------------------- 1 | %rename (InstantCameraParams_Params) Basler_InstantCameraParams::CInstantCameraParams_Params; 2 | %ignore CInstantCameraParams_ParamsData; 3 | 4 | %extend Basler_InstantCameraParams::CInstantCameraParams_Params 5 | { 6 | GENICAM_EX_PROP(MaxNumBuffer, GENAPI_NAMESPACE::IInteger); 7 | GENICAM_EX_PROP(MaxNumQueuedBuffer, GENAPI_NAMESPACE::IInteger); 8 | GENICAM_EX_PROP(MaxNumGrabResults, GENAPI_NAMESPACE::IInteger); 9 | GENICAM_EX_PROP(ChunkNodeMapsEnable, GENAPI_NAMESPACE::IBoolean); 10 | GENICAM_EX_PROP(StaticChunkNodeMapPoolSize, GENAPI_NAMESPACE::IInteger); 11 | GENICAM_EX_PROP(GrabCameraEvents, GENAPI_NAMESPACE::IBoolean); 12 | GENICAM_EX_PROP(MonitorModeActive, GENAPI_NAMESPACE::IBoolean); 13 | GENICAM_EX_PROP(GrabLoopThreadUseTimeout, GENAPI_NAMESPACE::IBoolean); 14 | GENICAM_EX_PROP(GrabLoopThreadTimeout, GENAPI_NAMESPACE::IInteger); 15 | GENICAM_EX_PROP(NumQueuedBuffers, GENAPI_NAMESPACE::IInteger); 16 | GENICAM_EX_PROP(NumReadyBuffers, GENAPI_NAMESPACE::IInteger); 17 | GENICAM_EX_PROP(NumEmptyBuffers, GENAPI_NAMESPACE::IInteger); 18 | GENICAM_EX_PROP(OutputQueueSize, GENAPI_NAMESPACE::IInteger); 19 | GENICAM_EX_PROP(InternalGrabEngineThreadPriorityOverride, GENAPI_NAMESPACE::IBoolean); 20 | GENICAM_EX_PROP(InternalGrabEngineThreadPriority, GENAPI_NAMESPACE::IInteger); 21 | GENICAM_EX_PROP(GrabLoopThreadPriorityOverride, GENAPI_NAMESPACE::IBoolean); 22 | GENICAM_EX_PROP(GrabLoopThreadPriority, GENAPI_NAMESPACE::IInteger); 23 | } 24 | 25 | %include ; 26 | -------------------------------------------------------------------------------- /src/pylon/Interface.i: -------------------------------------------------------------------------------- 1 | %rename (Interface) Pylon::IInterface; 2 | %nodefaultdtor Pylon::IInterface; 3 | %extend Pylon::IInterface 4 | { 5 | PROP_GET(InterfaceInfo) 6 | 7 | %pythoncode %{ 8 | class NodeMapContext: 9 | def __init__(self, iface): 10 | self.iface = iface 11 | 12 | def __enter__(self): 13 | self.iface.Open() 14 | return self.iface.GetNodeMap() 15 | 16 | def __exit__(self, type, value, traceback): 17 | self.iface.Close() 18 | 19 | NodeMap = property(NodeMapContext) 20 | %} 21 | 22 | } 23 | 24 | %include ; 25 | -------------------------------------------------------------------------------- /src/pylon/InterfaceInfo.i: -------------------------------------------------------------------------------- 1 | %rename(InterfaceInfo) Pylon::CInterfaceInfo; 2 | %include ; 3 | -------------------------------------------------------------------------------- /src/pylon/PayloadType.i: -------------------------------------------------------------------------------- 1 | %ignore PayloadType; 2 | %include ; 3 | 4 | -------------------------------------------------------------------------------- /src/pylon/PixelType.i: -------------------------------------------------------------------------------- 1 | %ignore IsValidRGB; 2 | %ignore IsValidBGR; 3 | %ignore PixelSize; 4 | %ignore PixelType; 5 | %include; 6 | -------------------------------------------------------------------------------- /src/pylon/PylonDataContainer.i: -------------------------------------------------------------------------------- 1 | %rename(PylonDataContainer) Pylon::CPylonDataContainer; 2 | 3 | %ignore CPylonDataContainerImpl; 4 | 5 | %include ; 6 | %extend Pylon::CPylonDataContainer { 7 | // To allow the instant camera to reuse the CGrabResultData 8 | // and prevent buffer underruns, you must release the PylonDataContainer and all its PylonDataComponent objects. 9 | void Release() 10 | { 11 | *($self) = Pylon::CPylonDataContainer(); 12 | } 13 | }; -------------------------------------------------------------------------------- /src/pylon/PylonGUI.i: -------------------------------------------------------------------------------- 1 | %rename(PylonImageWindow) Pylon::CPylonImageWindow; 2 | %typemap(out) HWND { 3 | $result = PyLong_FromVoidPtr($1); 4 | } 5 | 6 | %extend Pylon::CPylonImageWindow { 7 | %pythoncode %{ 8 | # 9 | # let python code easily detect whether an image window is visible 10 | # 11 | 12 | import ctypes as _tmp_ctypes 13 | __IsWindowVisible = _tmp_ctypes.WinDLL("user32").IsWindowVisible 14 | __IsWindowVisible.argtypes = [_tmp_ctypes.c_void_p] 15 | __IsWindowVisible.restype = _tmp_ctypes.c_bool 16 | del _tmp_ctypes 17 | 18 | def IsVisible(self): 19 | """ 20 | 21 | Checks if this PylonImageWindow is visible 22 | 23 | Returns 24 | ------- 25 | True if visible. 26 | 27 | """ 28 | return self.__IsWindowVisible(self.GetWindowHandle()) 29 | %} 30 | } 31 | 32 | #define IImage CGrabResultPtr 33 | %include ; 34 | #undef IImage 35 | -------------------------------------------------------------------------------- /src/pylon/PylonImageBase.i: -------------------------------------------------------------------------------- 1 | 2 | %rename(PylonImageBase) Pylon::CPylonImageBase; 3 | %nodefaultctor Pylon::CPylonImageBase; 4 | %nodefaultdtor Pylon::CPylonImageBase; 5 | 6 | %include ; 7 | -------------------------------------------------------------------------------- /src/pylon/PylonVersionInfo.i: -------------------------------------------------------------------------------- 1 | %rename(VersionInfo) Pylon::VersionInfo; 2 | 3 | %ignore Pylon::VersionInfo::getVersionString; 4 | 5 | %extend Pylon::VersionInfo { 6 | %pythoncode %{ 7 | def __repr__(self): 8 | return f"" 9 | %} 10 | }; 11 | 12 | %include ; 13 | 14 | -------------------------------------------------------------------------------- /src/pylon/Result.i: -------------------------------------------------------------------------------- 1 | 2 | %include ; 3 | -------------------------------------------------------------------------------- /src/pylon/ReusableImage.i: -------------------------------------------------------------------------------- 1 | %include; 2 | -------------------------------------------------------------------------------- /src/pylon/SoftwareTriggerConfiguration.i: -------------------------------------------------------------------------------- 1 | %rename(InstantCamera) Pylon::CInstantCamera; 2 | %rename(SoftwareTriggerConfiguration) Pylon::CSoftwareTriggerConfiguration; 3 | %include ; -------------------------------------------------------------------------------- /src/pylon/StreamGrabber.i: -------------------------------------------------------------------------------- 1 | %rename (StreamGrabber) Pylon::IStreamGrabber; 2 | %include ; 3 | %pythoncode %{ 4 | IStreamGrabber = StreamGrabber 5 | %} 6 | -------------------------------------------------------------------------------- /src/pylon/TlFactory.i: -------------------------------------------------------------------------------- 1 | 2 | %ignore CSimpleMutex; 3 | %ignore TlMap; 4 | %ignore ImplicitTlRefs; 5 | 6 | %nodefaultctor Pylon::CTlFactory; 7 | %rename(TlFactory) Pylon::CTlFactory; 8 | 9 | //////////////////////////////////////////////////////////////////////////////// 10 | // 11 | // TlInfoList output 12 | // 13 | 14 | %typemap(in, numinputs=0, noblock=1) Pylon::TlInfoList_t & { 15 | $1 = new Pylon::TlInfoList_t(); 16 | } 17 | 18 | %typemap(argout) Pylon::TlInfoList_t & { 19 | Py_DECREF($result); 20 | PyObject *tpl = PyTuple_New($1->size()); 21 | for (unsigned int i = 0; i < $1->size(); i++) { 22 | CTlInfo *ti = new CTlInfo((*$1)[i]); 23 | PyObject *item = SWIG_NewPointerObj( 24 | SWIG_as_voidptr(ti), 25 | SWIGTYPE_p_Pylon__CTlInfo, 26 | SWIG_POINTER_OWN 27 | ); 28 | PyTuple_SetItem(tpl, i, item); 29 | } 30 | $result = tpl; 31 | delete $1; 32 | } 33 | 34 | 35 | //////////////////////////////////////////////////////////////////////////////// 36 | // 37 | // DeviceInfoList output 38 | // 39 | 40 | %typemap(in, numinputs=0, noblock=1) Pylon::DeviceInfoList_t & { 41 | $1 = new DeviceInfoList_t(); 42 | } 43 | 44 | %typemap(argout) Pylon::DeviceInfoList_t & { 45 | Py_DECREF($result); 46 | PyObject *tpl = PyTuple_New($1->size()); 47 | for (unsigned int i = 0; i < $1->size(); i++) { 48 | CDeviceInfo *di = new CDeviceInfo((*$1)[i]); 49 | PyObject *item = SWIG_NewPointerObj( 50 | SWIG_as_voidptr(di), 51 | SWIGTYPE_p_Pylon__CDeviceInfo, 52 | SWIG_POINTER_OWN 53 | ); 54 | PyTuple_SetItem(tpl, i, item); 55 | } 56 | $result = tpl; 57 | delete $1; 58 | } 59 | 60 | // ensure the above typemap will not be applied to const references 61 | %typemap(argout, noblock=1) const Pylon::DeviceInfoList_t & {} 62 | 63 | // This out-typemap tries to downcast the TL to the specific implementation. 64 | // Currently the only TL with an extended interface is GigE. 65 | %typemap(out) Pylon::ITransportLayer* 66 | %{ 67 | if (0 == $1) 68 | { 69 | PyErr_SetString(PyExc_ValueError, "invalid TL specification"); 70 | SWIG_fail; 71 | } 72 | else 73 | { 74 | swig_type_info *outtype = $descriptor(Pylon::IGigETransportLayer*); 75 | void *outptr = dynamic_cast($1); 76 | if (!outptr) 77 | { 78 | outptr = $1; 79 | outtype = $descriptor(Pylon::ITransportLayer*); 80 | }; 81 | // Must not own TL object, since calling delete on it is forbidden 82 | // by the pylon API. The user has to call tl.Release(). 83 | $result = SWIG_NewPointerObj(outptr, outtype, 0); 84 | }; 85 | %} 86 | 87 | 88 | %include ; 89 | 90 | // now that the local typemaps are no longer needed, clear them. 91 | 92 | %typemap(in) Pylon::TlInfoList_t&; 93 | %typemap(argout) Pylon::TlInfoList_t&; 94 | %typemap(out) Pylon::ITransportLayer*; 95 | -------------------------------------------------------------------------------- /src/pylon/TlInfo.i: -------------------------------------------------------------------------------- 1 | %rename(TlInfo) Pylon::CTlInfo; 2 | %include ; 3 | -------------------------------------------------------------------------------- /src/pylon/TransportLayer.i: -------------------------------------------------------------------------------- 1 | %rename (TransportLayer) Pylon::ITransportLayer; 2 | %nodefaultdtor Pylon::ITransportLayer; 3 | %extend Pylon::ITransportLayer 4 | { 5 | PROP_GET(TlInfo) 6 | PROP_GET(NodeMap) 7 | 8 | %pythoncode %{ 9 | class InterfaceContext: 10 | def __init__(self, tl, iface_info): 11 | self.tl = tl 12 | self.iface_info = iface_info 13 | self.iface = None 14 | 15 | def __enter__(self): 16 | self.iface = self.tl.CreateInterface(self.iface_info) 17 | return self.iface 18 | 19 | def __exit__(self, type, value, traceback): 20 | self.tl.DestroyInterface(self.iface) 21 | 22 | def Interface(self, iface_info): 23 | return self.InterfaceContext(self, iface_info) 24 | 25 | class InterfaceNodeMapContext: 26 | def __init__(self, tl, iface_info): 27 | self.tl = tl 28 | self.iface_info = iface_info 29 | self.iface = None 30 | 31 | def __enter__(self): 32 | self.iface = self.tl.CreateInterface(self.iface_info) 33 | self.iface.Open() 34 | return self.iface.GetNodeMap() 35 | 36 | def __exit__(self, type, value, traceback): 37 | self.iface.Close() 38 | self.tl.DestroyInterface(self.iface) 39 | 40 | def InterfaceNodeMap(self, iface_info): 41 | return self.InterfaceNodeMapContext(self, iface_info) 42 | 43 | %} 44 | 45 | } 46 | 47 | //////////////////////////////////////////////////////////////////////////////// 48 | // 49 | // InterfaceInfoList output 50 | // 51 | 52 | %typemap(in, numinputs=0) (Pylon::InterfaceInfoList_t& list, bool addToList) 53 | { 54 | $1 = new Pylon::InterfaceInfoList_t(); 55 | $2 = false; 56 | } 57 | 58 | %typemap(argout) Pylon::InterfaceInfoList_t & 59 | { 60 | Py_DECREF($result); 61 | PyObject *tpl = PyTuple_New($1->size()); 62 | for (unsigned int i = 0; i < $1->size(); i++) 63 | { 64 | CInterfaceInfo *ii = new CInterfaceInfo((*$1)[i]); 65 | PyObject *item = SWIG_NewPointerObj( 66 | SWIG_as_voidptr(ii), 67 | SWIGTYPE_p_Pylon__CInterfaceInfo, 68 | SWIG_POINTER_OWN 69 | ); 70 | PyTuple_SetItem(tpl, i, item); 71 | } 72 | $result = tpl; 73 | delete $1; 74 | } 75 | 76 | %include ; 77 | 78 | %typemap(in) (Pylon::InterfaceInfoList_t& list, bool addToList); 79 | %typemap(argout) Pylon::InterfaceInfoList_t&; 80 | -------------------------------------------------------------------------------- /src/pylon/TypeMappings.i: -------------------------------------------------------------------------------- 1 | 2 | namespace Pylon 3 | { 4 | // Pylon's string definition 5 | typedef GENICAM_NAMESPACE::gcstring String_t; 6 | // Pylon's string list definition 7 | typedef GENICAM_NAMESPACE::gcstring_vector StringList_t; 8 | } 9 | 10 | //The string class shouldn't get wrapped 11 | %ignore String_t; 12 | %ignore StringList_t; 13 | 14 | #include 15 | 16 | // The exceptions are only imported from genicam into the pylon namespace. 17 | // We therefore want to reuse the wrapped types from genicam. 18 | 19 | %types( GENICAM_NAMESPACE::GenericException *, 20 | GENICAM_NAMESPACE::BadAllocException *, 21 | GENICAM_NAMESPACE::InvalidArgumentException *, 22 | GENICAM_NAMESPACE::OutOfRangeException *, 23 | GENICAM_NAMESPACE::PropertyException *, 24 | GENICAM_NAMESPACE::RuntimeException *, 25 | GENICAM_NAMESPACE::LogicalErrorException *, 26 | GENICAM_NAMESPACE::AccessException *, 27 | GENICAM_NAMESPACE::TimeoutException *, 28 | GENICAM_NAMESPACE::DynamicCastException *); 29 | 30 | %pythoncode %{ 31 | GenericException = pypylon.genicam.GenericException 32 | BadAllocException = pypylon.genicam.BadAllocException 33 | InvalidArgumentException = pypylon.genicam.InvalidArgumentException 34 | OutOfRangeException = pypylon.genicam.OutOfRangeException 35 | PropertyException = pypylon.genicam.PropertyException 36 | RuntimeException = pypylon.genicam.RuntimeException 37 | LogicalErrorException = pypylon.genicam.LogicalErrorException 38 | AccessException = pypylon.genicam.AccessException 39 | TimeoutException = pypylon.genicam.TimeoutException 40 | DynamicCastException = pypylon.genicam.DynamicCastException 41 | %} -------------------------------------------------------------------------------- /src/pylon/WaitObject.i: -------------------------------------------------------------------------------- 1 | 2 | %ignore WaitObjectEx; 3 | 4 | %ignore operator struct _WaitObjectPosix_t*; 5 | 6 | #ifdef _WIN32 7 | #define PYLON_WIN_BUILD 8 | %ignore Pylon::WaitObject::operator WaitObject_t() const; 9 | #else 10 | #define PYLON_UNIX_BUILD 11 | #endif 12 | 13 | %include 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/pylon/WaitObjects.i: -------------------------------------------------------------------------------- 1 | %ignore WaitObjectsImpl; 2 | %include ; -------------------------------------------------------------------------------- /src/pylon/_ImageFormatConverterParams.i: -------------------------------------------------------------------------------- 1 | %rename (ImageFormatConverterParams_Params) Basler_ImageFormatConverterParams::CImageFormatConverterParams_Params; 2 | %ignore CImageFormatConverterParams_ParamsData; 3 | %ignore InconvertibleEdgeHandlingEnumParameter; 4 | %ignore MonoConversionMethodEnumParameter; 5 | %ignore OutputBitAlignmentEnumParameter; 6 | %ignore OutputOrientationEnumParameter; 7 | 8 | %extend Basler_ImageFormatConverterParams::CImageFormatConverterParams_Params 9 | { 10 | GENICAM_EX_PROP(AdditionalLeftShift, GENAPI_NAMESPACE::IInteger); 11 | GENICAM_EX_PROP(Gamma, GENAPI_NAMESPACE::IFloat); 12 | GENICAM_EX_PROP(OutputPaddingX, GENAPI_NAMESPACE::IInteger); 13 | GENICAM_ENUM_PROP(InconvertibleEdgeHandling); 14 | GENICAM_ENUM_PROP(MonoConversionMethod); 15 | GENICAM_ENUM_PROP(OutputBitAlignment); 16 | GENICAM_ENUM_PROP(OutputOrientation); 17 | } 18 | 19 | %include ; 20 | -------------------------------------------------------------------------------- /src/pylondataprocessing/AcquisitionMode.i: -------------------------------------------------------------------------------- 1 | %rename(AcquisitionMode) Pylon::DataProcessing::EAcquisitionMode; 2 | 3 | %include ; 4 | -------------------------------------------------------------------------------- /src/pylondataprocessing/BuildersRecipe.i: -------------------------------------------------------------------------------- 1 | %rename(BuildersRecipe) Pylon::DataProcessing::CBuildersRecipe; 2 | 3 | %ignore GetAvailableVToolTypeIDs; 4 | %rename(GetAvailableVToolTypeIDs) GetAvailableVToolTypeIDs2; 5 | %ignore GetVToolIdentifiers; 6 | %rename(GetVToolIdentifiers) GetVToolIdentifiers2; 7 | %ignore GetInputNames; 8 | %rename(GetInputNames) GetInputNames2; 9 | %ignore GetConnectionIdentifiers; 10 | %rename(GetConnectionIdentifiers) GetConnectionIdentifiers2; 11 | 12 | %include ; 13 | 14 | %extend Pylon::DataProcessing::CBuildersRecipe { 15 | 16 | void GetAvailableVToolTypeIDs2(StringList_t& result) const 17 | { 18 | $self->GetAvailableVToolTypeIDs(result); 19 | } 20 | void GetVToolIdentifiers2(StringList_t& result) const 21 | { 22 | $self->GetVToolIdentifiers(result); 23 | } 24 | void GetInputNames2(StringList_t& result) const 25 | { 26 | $self->GetInputNames(result); 27 | } 28 | 29 | void GetConnectionIdentifiers2(StringList_t& result) const 30 | { 31 | $self->GetConnectionIdentifiers(result); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/pylondataprocessing/CircleF.i: -------------------------------------------------------------------------------- 1 | %rename(CircleF) Pylon::DataProcessing::SCircleF; 2 | %rename(_Center) Pylon::DataProcessing::SCircleF::Center; 3 | %copyctor Pylon::DataProcessing::SCircleF; 4 | 5 | %include ; 6 | 7 | %extend Pylon::DataProcessing::SCircleF { 8 | // When accessing substructs SWIG wraps these as pointers 9 | // This can cause crashes when accessing the substructs from returned 10 | // values, e.g. myvariant.ToCircleF().Center.X, when the returned object goes out of scope early. 11 | // This is a workaround for this problem. 12 | SAFE_NESTED_STRUCT_ACCESS(PointF2D, Center) 13 | 14 | %pythoncode %{ 15 | def __str__(self): 16 | result = "Center: ({0}); Radius = {1}".format(self.Center, self.Radius) 17 | return result 18 | %} 19 | } -------------------------------------------------------------------------------- /src/pylondataprocessing/EllipseF.i: -------------------------------------------------------------------------------- 1 | %rename(EllipseF) Pylon::DataProcessing::SEllipseF; 2 | %rename(_Center) Pylon::DataProcessing::SEllipseF::Center; 3 | %copyctor Pylon::DataProcessing::SEllipseF; 4 | 5 | %include ; 6 | 7 | %extend Pylon::DataProcessing::SEllipseF { 8 | // When accessing substructs SWIG wraps these as pointers 9 | // This can cause crashes when accessing the substructs from returned 10 | // values, e.g. myvariant.ToEllipseF().Center.X, when the returned object goes out of scope early. 11 | // This is a workaround for this problem. 12 | SAFE_NESTED_STRUCT_ACCESS(PointF2D, Center) 13 | 14 | %pythoncode %{ 15 | def __str__(self): 16 | result = "Center: ({0}); Radius1 = {1}; Radius2 = {2}; Rotation = {3} rad".format(self.Center, self.Radius1, self.Radius2, self.Rotation) 17 | return result 18 | %} 19 | } -------------------------------------------------------------------------------- /src/pylondataprocessing/EventObserver.i: -------------------------------------------------------------------------------- 1 | %rename(Recipe) Pylon::DataProcessing::CRecipe; 2 | %rename(EventData) Pylon::DataProcessing::CEventData; 3 | %rename(EventObserver) Pylon::DataProcessing::IEventObserver; 4 | %feature("director") Pylon::DataProcessing::IEventObserver; 5 | 6 | %rename(EventType) Pylon::DataProcessing::CEventData::eventType; 7 | %rename(Description) Pylon::DataProcessing::CEventData::description; 8 | %rename(EventClass) Pylon::DataProcessing::CEventData::eventClass; 9 | %rename(EventSourceName) Pylon::DataProcessing::CEventData::eventSourceName; 10 | 11 | // previous data processing version < v2.0.0 (pylon 7.4), in current versions 'events' is named 'pEvents' 12 | %typemap(directorin) (const Pylon::DataProcessing::CEventData* events, size_t numEvents) (PyObject* listObject) 13 | %{ 14 | listObject = PyList_New(numEvents); 15 | for (size_t i = 0; i < numEvents; ++i) 16 | { 17 | PyObject* eventObject = SWIG_NewPointerObj(SWIG_as_voidptr(new Pylon::DataProcessing::CEventData(events[i])), SWIGTYPE_p_Pylon__DataProcessing__CEventData, SWIG_POINTER_OWN); 18 | PyList_SetItem(listObject, i, eventObject); 19 | } 20 | $input = listObject; 21 | %} 22 | 23 | %typemap(directorin) (const Pylon::DataProcessing::CEventData* pEvents, size_t numEvents) (PyObject* listObject) 24 | %{ 25 | listObject = PyList_New(numEvents); 26 | for (size_t i = 0; i < numEvents; ++i) 27 | { 28 | PyObject* eventObject = SWIG_NewPointerObj(SWIG_as_voidptr(new Pylon::DataProcessing::CEventData(pEvents[i])), SWIGTYPE_p_Pylon__DataProcessing__CEventData, SWIG_POINTER_OWN); 29 | PyList_SetItem(listObject, i, eventObject); 30 | } 31 | $input = listObject; 32 | %} 33 | 34 | %extend Pylon::DataProcessing::CEventData { 35 | %pythoncode %{ 36 | def __str__(self): 37 | result = "EventType: {0}; Description = {1}; EventClass = {2}; EventSourceName = {3}".format(self.EventType, self.Description, self.EventClass, self.EventSourceName) 38 | return result 39 | %} 40 | } 41 | 42 | %include ; -------------------------------------------------------------------------------- /src/pylondataprocessing/LineF2D.i: -------------------------------------------------------------------------------- 1 | %rename(LineF2D) Pylon::DataProcessing::SLineF2D; 2 | %rename(_PointA) Pylon::DataProcessing::SLineF2D::PointA; 3 | %rename(_PointB) Pylon::DataProcessing::SLineF2D::PointB; 4 | %copyctor Pylon::DataProcessing::SLineF2D; 5 | 6 | %include ; 7 | 8 | %extend Pylon::DataProcessing::SLineF2D { 9 | // When accessing substructs SWIG wraps these as pointers 10 | // This can cause crashes when accessing the substructs from returned 11 | // values, e.g. myvariant.ToLineF2D().PointA.X, when the returned object goes out of scope early. 12 | // This is a workaround for this problem. 13 | SAFE_NESTED_STRUCT_ACCESS(PointF2D, PointA) 14 | SAFE_NESTED_STRUCT_ACCESS(PointF2D, PointB) 15 | 16 | %pythoncode %{ 17 | def __str__(self): 18 | result = "PointA: ({0}); PointB: ({1})".format(self.PointA,self.PointB) 19 | return result 20 | %} 21 | } -------------------------------------------------------------------------------- /src/pylondataprocessing/OutputObserver.i: -------------------------------------------------------------------------------- 1 | %rename(Recipe) Pylon::DataProcessing::CRecipe; 2 | %rename(OutputObserver) Pylon::DataProcessing::IOutputObserver; 3 | %feature("director") Pylon::DataProcessing::IOutputObserver; 4 | 5 | %include ; -------------------------------------------------------------------------------- /src/pylondataprocessing/PointF2D.i: -------------------------------------------------------------------------------- 1 | %rename(PointF2D) Pylon::DataProcessing::SPointF2D; 2 | %copyctor Pylon::DataProcessing::SPointF2D; 3 | 4 | %include ; 5 | 6 | %extend Pylon::DataProcessing::SPointF2D { 7 | %pythoncode %{ 8 | def __str__(self): 9 | result = "X = {0}; Y = {1}".format(self.X,self.Y) 10 | return result 11 | %} 12 | } 13 | -------------------------------------------------------------------------------- /src/pylondataprocessing/QueueMode.i: -------------------------------------------------------------------------------- 1 | %rename(QueueMode) Pylon::DataProcessing::EQueueMode; 2 | 3 | %include ; -------------------------------------------------------------------------------- /src/pylondataprocessing/RecipeFileFormat.i: -------------------------------------------------------------------------------- 1 | %rename(RecipeFileFormat) Pylon::DataProcessing::ERecipeFileFormat; 2 | 3 | %include ; -------------------------------------------------------------------------------- /src/pylondataprocessing/RectangleF.i: -------------------------------------------------------------------------------- 1 | %rename(RectangleF) Pylon::DataProcessing::SRectangleF; 2 | %rename(_Center) Pylon::DataProcessing::SRectangleF::Center; 3 | %copyctor Pylon::DataProcessing::SRectangleF; 4 | 5 | %include ; 6 | 7 | %extend Pylon::DataProcessing::SRectangleF { 8 | // When accessing substructs SWIG wraps these as pointers 9 | // This can cause crashes when accessing the substructs from returned 10 | // values, e.g. myvariant.ToRectangleF().Center.X, when the returned object goes out of scope early. 11 | // This is a workaround for this problem. 12 | SAFE_NESTED_STRUCT_ACCESS(PointF2D, Center) 13 | 14 | %pythoncode %{ 15 | def __str__(self): 16 | result = "Center: ({0}); Width = {1}; Height = {2}; Rotation = {3} rad".format(self.Center, self.Width, self.Height, self.Rotation) 17 | return result 18 | %} 19 | } -------------------------------------------------------------------------------- /src/pylondataprocessing/Region.i: -------------------------------------------------------------------------------- 1 | %rename(Region) Pylon::DataProcessing::CRegion; 2 | 3 | %ignore AttachUserBuffer; 4 | %ignore CopyRegion(const void*,size_t,Pylon::DataProcessing::ERegionType,uint32_t,uint32_t,int32_t,int32_t,uint32_t,uint32_t); 5 | %ignore GetBuffer; 6 | %ignore GetBufferConst; 7 | %rename(GetBuffer) GetBuffer2; 8 | 9 | %include ; 10 | 11 | %extend Pylon::DataProcessing::CRegion { 12 | 13 | // Since 'GetBuffer', 'GetMemoryView' 14 | // allocate memory, they must not be called without 15 | // the GIL being held. Therefore we have to tell SWIG not to release the GIL 16 | // when calling them (%nothread). 17 | 18 | %nothread GetBuffer; 19 | %nothread GetBuffer2; 20 | %nothread GetMemoryView; 21 | %nothread ToArray; 22 | 23 | PyObject * GetBuffer2() 24 | { 25 | const void * buf = $self->GetBufferConst(); 26 | size_t length = $self->GetDataSize(); 27 | return (buf) ? PyByteArray_FromStringAndSize((const char *) buf, length) : Py_None; 28 | } 29 | 30 | PyObject * GetMemoryView() 31 | { 32 | // need at least Python 3.3 for memory view 33 | %#if PY_VERSION_HEX >= 0x03030000 34 | if ($self->IsReadOnly()) 35 | { 36 | return PyMemoryView_FromMemory( 37 | (char*)const_cast($self->GetBufferConst()), 38 | $self->GetDataSize(), 39 | PyBUF_READ 40 | ); 41 | } 42 | else 43 | { 44 | return PyMemoryView_FromMemory( 45 | (char*)$self->GetBuffer(), 46 | $self->GetDataSize(), 47 | PyBUF_WRITE 48 | ); 49 | } 50 | %#else 51 | PyErr_SetString(PyExc_RuntimeError, "memory view not available"); 52 | return NULL; 53 | %#endif 54 | } 55 | 56 | PyObject * ToArray() 57 | { 58 | Pylon::DataProcessing::ERegionType regionType = $self->GetRegionType(); 59 | if (regionType == Pylon::DataProcessing::RegionType_RLE32) 60 | { 61 | const Pylon::DataProcessing::SRegionEntryRLE32* p = reinterpret_cast($self->GetBufferConst()); 62 | size_t elementCount = ($self->GetDataSize() / sizeof(Pylon::DataProcessing::SRegionEntryRLE32)); 63 | PyObject *listObject = PyList_New(elementCount); 64 | for (size_t i = 0; i < elementCount; ++i, ++p) 65 | { 66 | PyList_SetItem(listObject, i, SWIG_NewPointerObj(SWIG_as_voidptr(new Pylon::DataProcessing::SRegionEntryRLE32(*p)), SWIGTYPE_p_Pylon__DataProcessing__SRegionEntryRLE32, SWIG_POINTER_OWN)); 67 | } 68 | return listObject; 69 | } 70 | else 71 | { 72 | PyErr_SetString(PyExc_RuntimeError, "Region cannot be converted to an array."); 73 | return NULL; 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /src/pylondataprocessing/RegionEntry.i: -------------------------------------------------------------------------------- 1 | %rename(RegionEntryRLE32) Pylon::DataProcessing::SRegionEntryRLE32; 2 | 3 | %include ; 4 | 5 | %extend Pylon::DataProcessing::SRegionEntryRLE32 { 6 | 7 | SRegionEntryRLE32() 8 | { 9 | Pylon::DataProcessing::SRegionEntryRLE32* pResult = new Pylon::DataProcessing::SRegionEntryRLE32; 10 | pResult->StartX = 0; 11 | pResult->EndX = 0; 12 | pResult->Y = 0; 13 | return pResult; 14 | } 15 | 16 | SRegionEntryRLE32(int32_t startX, int32_t endX, int32_t y) 17 | { 18 | Pylon::DataProcessing::SRegionEntryRLE32* pResult = new Pylon::DataProcessing::SRegionEntryRLE32; 19 | pResult->StartX = startX; 20 | pResult->EndX = endX; 21 | pResult->Y = y; 22 | return pResult; 23 | } 24 | 25 | %pythoncode %{ 26 | def __str__(self): 27 | result = "StartX = {0}; EndX = {1}; Y = {2}".format(self.StartX, self.EndX, self.Y) 28 | return result 29 | %} 30 | } -------------------------------------------------------------------------------- /src/pylondataprocessing/RegionType.i: -------------------------------------------------------------------------------- 1 | %rename(RegionType) Pylon::DataProcessing::ERegionType; 2 | 3 | %include ; -------------------------------------------------------------------------------- /src/pylondataprocessing/TransformationData.i: -------------------------------------------------------------------------------- 1 | %rename(TransformationData) Pylon::DataProcessing::CTransformationData; 2 | 3 | %ignore CTransformationData(CTransformationData &&); 4 | 5 | %include ; 6 | 7 | %extend Pylon::DataProcessing::CTransformationData { 8 | %pythoncode %{ 9 | def __str__(self): 10 | resultList = [] 11 | for rowIndex in range(self.RowCount): 12 | if rowIndex != 0: 13 | resultList.append("\n") 14 | for columnIndex in range(self.ColumnCount): 15 | if columnIndex != 0: 16 | resultList.append(", ") 17 | resultList.append(str(self.GetEntry(columnIndex, rowIndex))) 18 | result = "".join(resultList) 19 | return result 20 | %} 21 | } 22 | -------------------------------------------------------------------------------- /src/pylondataprocessing/Update.i: -------------------------------------------------------------------------------- 1 | %rename(Update) Pylon::DataProcessing::CUpdate; 2 | 3 | %include ; -------------------------------------------------------------------------------- /src/pylondataprocessing/UpdateObserver.i: -------------------------------------------------------------------------------- 1 | %rename(Recipe) Pylon::DataProcessing::CRecipe; 2 | %rename(UpdateObserver) Pylon::DataProcessing::IUpdateObserver; 3 | %feature("director") Pylon::DataProcessing::IUpdateObserver; 4 | 5 | %include ; -------------------------------------------------------------------------------- /src/pylondataprocessing/VariantContainer.i: -------------------------------------------------------------------------------- 1 | %rename(VariantContainer) Pylon::DataProcessing::CVariantContainer; 2 | %rename(Variant) Pylon::DataProcessing::CVariant; 3 | 4 | %ignore begin; 5 | %ignore end; 6 | %ignore find; 7 | %ignore erase(const CVariantContainer::iterator& it); 8 | %ignore operator[](const String_t& key); 9 | %ignore operator++(); 10 | %ignore operator++(int); 11 | %ignore keyvalue_pair; 12 | %ignore iterator; 13 | %ignore CVariantContainer(CVariantContainer &&); 14 | 15 | %warnfilter(389) CVariantContainer; 16 | %warnfilter(383) CVariantContainer; 17 | 18 | %include ; 19 | 20 | //The VariantContainer is usually mapped to and from a python dictionary. The following extension should not be needed. 21 | %extend Pylon::DataProcessing::CVariantContainer { 22 | 23 | Pylon::DataProcessing::CVariant getValue(const Pylon::String_t& key) 24 | { 25 | Pylon::DataProcessing::CVariant v = $self->operator[](key); 26 | return v; 27 | } 28 | 29 | void setValue(const Pylon::String_t& key, Pylon::DataProcessing::CVariant& v) 30 | { 31 | $self->operator[](key) = v; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/pylondataprocessing/VariantContainerType.i: -------------------------------------------------------------------------------- 1 | %rename(VariantContainerType) Pylon::DataProcessing::EVariantContainerType; 2 | 3 | #if PYLON_DATAPROCESSING_VERSION_MAJOR >= 2 4 | %include ; 5 | #else 6 | /*! 7 | * \namespace Pylon 8 | * \brief The Pylon namespace 9 | */ 10 | namespace Pylon 11 | { 12 | /*! 13 | * \namespace Pylon::DataProcessing 14 | * \brief The DataProcessing namespace 15 | */ 16 | namespace DataProcessing 17 | { 18 | /*! 19 | \brief 20 | Lists the built-in variant container types. 21 | **/ 22 | enum EVariantContainerType 23 | { 24 | VariantContainerType_None = 0, //!< A basic data object without any container. 25 | VariantContainerType_Array = 1, //!< An array that may contain basic data objects. 26 | VariantContainerType_Unsupported = 2 //!< A container type that is not supported natively by this SDK yet. 27 | }; 28 | } 29 | } 30 | #endif 31 | -------------------------------------------------------------------------------- /src/pylondataprocessing/VariantDataType.i: -------------------------------------------------------------------------------- 1 | %rename(VariantDataType) Pylon::DataProcessing::EVariantDataType; 2 | 3 | %include ; -------------------------------------------------------------------------------- /tests/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore the xml files generated by genicam tests 2 | xml/ 3 | -------------------------------------------------------------------------------- /tests/all_emulated_tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import unittest 3 | import os 4 | 5 | def load_tests(loader, tests, pattern): 6 | thisdir = os.path.dirname(__file__) 7 | suites = [] 8 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir), pattern='nonexistent.py')) 9 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir, 'genicam_tests'), pattern='*test.py')) 10 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir, 'pylon_tests', 'emulated'), pattern='*test.py')) 11 | return unittest.TestSuite(suites) 12 | 13 | if __name__ == "__main__": 14 | unittest.main() -------------------------------------------------------------------------------- /tests/all_emulated_tests_with_pylondataprocessing.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import unittest 3 | import os 4 | 5 | def load_tests(loader, tests, pattern): 6 | thisdir = os.path.dirname(__file__) 7 | suites = [] 8 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir), pattern='nonexistent.py')) 9 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir, 'genicam_tests'), pattern='*test.py')) 10 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir, 'pylon_tests', 'emulated'), pattern='*test.py')) 11 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir, 'pylondataprocessing_tests'), pattern='*test.py')) 12 | return unittest.TestSuite(suites) 13 | 14 | if __name__ == "__main__": 15 | unittest.main() -------------------------------------------------------------------------------- /tests/all_genicam_tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import unittest 3 | import os 4 | 5 | def load_tests(loader, tests, pattern): 6 | suite = unittest.defaultTestLoader.discover(os.path.join(os.path.dirname(__file__),'genicam_tests'), pattern='*test.py') 7 | return suite 8 | 9 | if __name__ == "__main__": 10 | unittest.main() -------------------------------------------------------------------------------- /tests/all_pylon_emulated_tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import unittest 3 | import os 4 | 5 | def load_tests(loader, tests, pattern): 6 | thisdir = os.path.dirname(__file__) 7 | suites = [] 8 | suites.append(unittest.defaultTestLoader.discover( os.path.join(thisdir, 'pylon_tests', 'emulated'), pattern='*test.py')) 9 | return unittest.TestSuite(suites) 10 | 11 | if __name__ == "__main__": 12 | unittest.main() -------------------------------------------------------------------------------- /tests/all_pylondataprocessing_tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import unittest 3 | import os 4 | 5 | def load_tests(loader, tests, pattern): 6 | thisdir = os.path.dirname(__file__) 7 | suite = unittest.defaultTestLoader.discover( os.path.join(thisdir, 'pylondataprocessing_tests'), pattern='*test.py') 8 | return suite 9 | 10 | if __name__ == "__main__": 11 | unittest.main() -------------------------------------------------------------------------------- /tests/all_tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import unittest 3 | import os 4 | 5 | def load_tests(loader, tests, pattern): 6 | suite = unittest.defaultTestLoader.discover(os.path.dirname(__file__), pattern='*test.py') 7 | return suite 8 | 9 | if __name__ == "__main__": 10 | unittest.main() -------------------------------------------------------------------------------- /tests/all_utils_tests.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import unittest 3 | import os 4 | 5 | def load_tests(loader, tests, pattern): 6 | suite = unittest.defaultTestLoader.discover( os.path.join(thisdir, 'pylon_tests', 'utils'), pattern='*test.py') 7 | return suite 8 | 9 | if __name__ == "__main__": 10 | unittest.main() -------------------------------------------------------------------------------- /tests/genicam_tests/HelloWorld.xml: -------------------------------------------------------------------------------- 1 | 2 | 19 | 20 | 21 | Hello World! 22 | 23 | 24 | TheFloat 25 | 42 26 | 27 | 28 | TheInt 29 | 3.1415 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tests/genicam_tests/__init__.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import sys 4 | 5 | #We want to keep the genicam tests the same as the ones in the genicam repository. 6 | #So we can't change the code, but must work around its limitations. 7 | #We add the directory to the path to be able to do: 8 | # from genicamtestcase import GenicamTestCase 9 | #and to fake 10 | # from genicam import * 11 | sys.path.insert(0, os.path.dirname(__file__)) 12 | -------------------------------------------------------------------------------- /tests/genicam_tests/callbackhelper.py: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # (c) 2005 by Basler Vision Technologies 3 | # Section: Vision Components 4 | # Project: GenApiTest 5 | # Author: 6 | # $Header: 7 | # ----------------------------------------------------------------------------- 8 | 9 | from genicam import Register 10 | 11 | 12 | class CallbackObject(object): 13 | def __init__(self): 14 | self.m_Count = 0 15 | 16 | def Reset(self): 17 | self.m_Count = 0 18 | 19 | def Count(self): 20 | return self.m_Count 21 | 22 | def Callback(self, Node): 23 | self.m_Count += 1 24 | 25 | 26 | # ! Helper class to test callbacks 27 | class CallbackTestTarget(object): 28 | def __init__(self, node): 29 | self.m_Count = 0 30 | self.cb = Register(node.Node, self.Callback) 31 | 32 | # Reset the callback counter 33 | def Reset(self): 34 | self.m_Count = 0 35 | 36 | # the callback function to be registers 37 | def Callback(self, node): 38 | self.m_Count += 1 39 | 40 | # true if the callback has fired exactly once 41 | # If true Reset() is called implicitely */ 42 | def HasFiredOnce(self): 43 | if self.m_Count == 1: 44 | self.Reset() 45 | return True 46 | else: 47 | print("WARNING : CCallbackTestTarget::HasFiredOnce : Count = ", self.Count()) 48 | return False 49 | 50 | # true if the callback has nof fired 51 | def HasNotFired(self): 52 | if self.m_Count == 0: 53 | return True 54 | else: 55 | print("WARNING : CCallbackTestTarget::HasNotFired : Count = ", self.Count()) 56 | return False 57 | 58 | # Tells the number of callbacks, 59 | 60 | def Count(self): 61 | return self.m_Count 62 | -------------------------------------------------------------------------------- /tests/genicam_tests/error_test.py: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # (c) 2005 by Basler Vision Technologies 3 | # Section: Vision Components 4 | # Project: GenApiTest 5 | # Author: 6 | # $Header: 7 | # ----------------------------------------------------------------------------- 8 | 9 | from genicam import * 10 | import unittest 11 | from genicamtestcase import GenicamTestCase 12 | 13 | 14 | class ErrorTestSuite(GenicamTestCase): 15 | def test_Basics(self): 16 | # added element 17 | # if(GenApiSchemaVersion == v1_0) 18 | # return; 19 | 20 | """[ GenApiTest@ErrorTestSuite_TestBasics.xml|gxml 21 | 22 | 23 | Error 24 | 42 25 | 26 | 27 | 28 | 29 | 0 30 | 31 | 32 | A really awful error has happened 33 | -1 34 | 35 | 0 36 | 37 | 38 | 39 | Error 40 | 41 | 0 42 | 43 | 44 | 1 45 | 46 | 0 47 | 48 | 49 | 50 | """ 51 | 52 | Camera = CNodeMapRef() 53 | Camera._LoadXMLFromFile("GenApiTest", "ErrorTestSuite_TestBasics") 54 | 55 | Value = Camera.GetNode("Value") 56 | self.assertTrue(bool(Value)) 57 | 58 | Error = Camera.GetNode("Error") 59 | self.assertTrue(bool(Error)) 60 | 61 | EnumValue = Camera.GetNode("EnumValue") 62 | self.assertTrue(bool(EnumValue)) 63 | 64 | # No error 65 | Value.Value = 17 66 | 67 | # error 68 | Error.Value = "Ahrrgs" 69 | with self.assertRaises(RuntimeException): 70 | Value.Value = 17 71 | with self.assertRaises(RuntimeException): 72 | EnumValue.SetIntValue(1) 73 | 74 | # error suppressed 75 | Value.SetValue(17, False) 76 | EnumValue.SetIntValue(1, False) 77 | 78 | 79 | if __name__ == "__main__": 80 | # import sys;sys.argv = ['', 'Test.testName'] 81 | unittest.main() 82 | -------------------------------------------------------------------------------- /tests/genicam_tests/genicam.py: -------------------------------------------------------------------------------- 1 | """ 2 | Legacy support module enabling the user to "import genicam" 3 | 4 | This module simply re-imports from pypylon.genicam... 5 | """ 6 | 7 | from warnings import warn 8 | 9 | warn("importing from 'genicam' is deprecated. Import from 'pypylon.genicam' instead.", DeprecationWarning) 10 | 11 | from pypylon.genicam import * 12 | -------------------------------------------------------------------------------- /tests/genicam_tests/genicamtestcase.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 03.08.2015 3 | 4 | @author: TMoeller 5 | ''' 6 | import snipper 7 | import inspect 8 | import unittest 9 | from genicam import * 10 | import os 11 | 12 | CNodeMapRef__LoadXMLFromFile = CNodeMapRef._LoadXMLFromFile 13 | 14 | 15 | def _LoadXMLFromFile(self, vendor, model): 16 | return CNodeMapRef__LoadXMLFromFile(self, os.path.join("xml", vendor, model) + ".xml") 17 | 18 | 19 | class GenicamTestCase(unittest.TestCase): 20 | def __init__(self, methodName='runTest'): 21 | unittest.TestCase.__init__(self, methodName=methodName) 22 | if "GENAPISCHEMAVERSION" in os.environ: 23 | self.GenApiSchemaVersion = os.environ["GENAPISCHEMAVERSION"] 24 | else: 25 | self.GenApiSchemaVersion = "v1_1" 26 | 27 | @classmethod 28 | def setUpClass(cls): 29 | super(GenicamTestCase, cls).setUpClass() 30 | # run snipper on current test 31 | snipper.createXMLSnippet(inspect.getsource(cls)) 32 | CNodeMapRef._LoadXMLFromFile = _LoadXMLFromFile 33 | 34 | @classmethod 35 | def tearDownClass(cls): 36 | CNodeMapRef._LoadXMLFromFile = CNodeMapRef__LoadXMLFromFile 37 | super(GenicamTestCase, cls).tearDownClass() 38 | 39 | 40 | CDFHeader = """ 41 | 58 | """ 59 | CDFFooter = """""" 60 | -------------------------------------------------------------------------------- /tests/genicam_tests/helloworld.py: -------------------------------------------------------------------------------- 1 | from genicam import CNodeMapRef, GenericException, IsReadable 2 | import sys 3 | 4 | 5 | def main(): 6 | try: 7 | XMLFileName = "HelloWorld.xml" 8 | 9 | Camera = CNodeMapRef() 10 | Camera._LoadXMLFromFile(XMLFileName) 11 | 12 | theNode = Camera._GetNode("TheNode") 13 | print(type(theNode)) 14 | 15 | theInt = Camera.GetNode("TheInt") 16 | print(type(theInt)) 17 | 18 | nodes = Camera._GetNodes() 19 | for n in nodes: 20 | print(n.ToString()) 21 | 22 | theFloat = Camera.GetNode("TheFloat") 23 | 24 | print(theNode.ToString()) 25 | print(theInt.ToString()) 26 | print(theInt.Node.GetPropertyNames()) 27 | print(IsReadable(theNode)) 28 | 29 | print(theFloat.GetIntAlias()) 30 | print(theInt.GetFloatAlias()) 31 | 32 | print(Camera.DeviceInfo) 33 | ver, build = Camera.DeviceInfo.GetGenApiVersion() 34 | print(ver.Major) 35 | print(ver.Minor) 36 | print(ver.SubMinor) 37 | 38 | return 0 39 | except GenericException as e: 40 | print("Error ", e.GetDescription()) 41 | 42 | return -1 43 | 44 | 45 | if __name__ == "__main__": 46 | sys.exit(main()) 47 | -------------------------------------------------------------------------------- /tests/genicam_tests/poll_test.py: -------------------------------------------------------------------------------- 1 | # ----------------------------------------------------------------------------- 2 | # (c) 2005 by Basler Vision Technologies 3 | # Section: Vision Components 4 | # Project: GenApiTest 5 | # Author: 6 | # $Header: 7 | # ----------------------------------------------------------------------------- 8 | 9 | from genicam import * 10 | import unittest 11 | from genicamtestcase import GenicamTestCase 12 | from callbackhelper import CallbackObject 13 | 14 | 15 | class PollTestSuite(GenicamTestCase): 16 | def test_Polling_Integer(self): 17 | """[ GenApiTest@PollTestSuite_TestPolling_Integer.xml|gxml 18 | 19 | 20 | Register 21 | 22 | 23 | 24 |
0x0f00
25 | 4 26 | RW 27 | Port 28 | 1000 29 | Unsigned 30 | LittleEndian 31 |
32 | 33 | 34 | 35 | """ 36 | 37 | Camera = CNodeMapRef() 38 | Camera._LoadXMLFromFile("GenApiTest", "PollTestSuite_TestPolling_Integer") 39 | Node = Camera.GetNode("Register") 40 | 41 | self.assertEqual(1000, Node.Node.GetPollingTime()) 42 | 43 | Value = Camera.GetNode("Value") 44 | 45 | self.assertEqual(-1, Value.Node.GetPollingTime()) 46 | 47 | CallBackTarget = CallbackObject() 48 | Register(Node.Node, CallBackTarget.Callback) 49 | Register(Value.Node, CallBackTarget.Callback) 50 | 51 | Camera._Poll(500) 52 | self.assertEqual(0, CallBackTarget.Count()) 53 | 54 | Camera._Poll(500) 55 | self.assertEqual(2, CallBackTarget.Count()) 56 | 57 | def test_Polling_Register(self): 58 | """[ GenApiTest@PollTestSuite_TestPolling_Register.xml|gxml 59 | 60 | 61 |
0x0f00
62 | 4 63 | RW 64 | Port 65 | 1000 66 |
67 | 68 | 69 | 70 | """ 71 | 72 | Camera = CNodeMapRef() 73 | Camera._LoadXMLFromFile("GenApiTest", "PollTestSuite_TestPolling_Register") 74 | 75 | Node = Camera.GetNode("Register") 76 | 77 | self.assertEqual(1000, Node.Node.GetPollingTime()) 78 | 79 | CallBackTarget = CallbackObject() 80 | Register(Node.Node, CallBackTarget.Callback) 81 | 82 | Camera._Poll(500) 83 | self.assertEqual(0, CallBackTarget.Count()) 84 | 85 | Camera._Poll(500) 86 | self.assertEqual(1, CallBackTarget.Count()) 87 | 88 | Camera._Poll(500) 89 | self.assertEqual(1, CallBackTarget.Count()) 90 | 91 | Camera._Poll(500) 92 | self.assertEqual(2, CallBackTarget.Count()) 93 | 94 | 95 | if __name__ == "__main__": 96 | # import sys;sys.argv = ['', 'Test.testName'] 97 | unittest.main() 98 | -------------------------------------------------------------------------------- /tests/genicam_tests/snipper.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 03.08.2015 3 | 4 | @author: TMoeller 5 | ''' 6 | 7 | import sys 8 | import re 9 | import os 10 | import errno 11 | 12 | 13 | def mkdir_p(path): 14 | try: 15 | os.makedirs(path) 16 | except OSError as exc: # Python >2.5 17 | if exc.errno == errno.EEXIST and os.path.isdir(path): 18 | pass 19 | else: 20 | raise 21 | 22 | 23 | def createXMLSnippet(file_content): 24 | # parse template file extract comment and 25 | # spit out xml file 26 | 27 | header = """ 28 | 43 | """ 44 | 45 | footer = "\n" 46 | 47 | start_rule = re.compile("^\\s*\"\"\"\\[?\\s*(\\S+)@(\\S+)\\|(\\S+)") 48 | end_rule = re.compile("^\\s*\"\"\"") 49 | 50 | in_snippet = False 51 | out_file = None 52 | for l in file_content.splitlines(): 53 | m_s = start_rule.match(l) 54 | m_e = end_rule.match(l) 55 | if m_s: 56 | in_snippet = True 57 | vendor_name, model_name, option = m_s.groups() 58 | file_path = os.path.join("xml", os.path.join(vendor_name, model_name)) 59 | mkdir_p(os.path.dirname(file_path)) 60 | out_file = open(file_path, "w") 61 | out_file.write(header.format(ModelName=model_name, VendorName=vendor_name)) 62 | print("Create Snippet ", file_path) 63 | elif in_snippet and m_e: 64 | in_snippet = False 65 | out_file.write(footer) 66 | out_file.close() 67 | out_file = None 68 | elif in_snippet: 69 | out_file.write(l) 70 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/__init__.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import sys 4 | 5 | #adding this dir to the path allows: 6 | # from pylonemutestcase import PylonEmuTestCase 7 | #THis is no clean solution, but works for now 8 | sys.path.insert(0, os.path.dirname(__file__)) 9 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/barcode01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/tests/pylon_tests/emulated/barcode01.png -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/call_test.py: -------------------------------------------------------------------------------- 1 | from pylonemutestcase import PylonEmuTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class CallTestSuite(PylonEmuTestCase): 7 | # Tests that you can set the GainRaw parameter of the camera 8 | def test_gain_raw(self): 9 | cam = self.create_first() 10 | cam.Open() 11 | 12 | # Set GainRaw to min value (192) 13 | cam.GainRaw.Value = cam.GainRaw.Min 14 | self.assertEqual(192, cam.GainRaw.Value) 15 | 16 | # Set GainRaw to max value (1023) 17 | cam.GainRaw.Value = cam.GainRaw.Max 18 | self.assertEqual(1023, cam.GainRaw.Value) 19 | 20 | # Set GainRaw to 500 21 | cam.GainRaw.Value = 500 22 | self.assertEqual(500, cam.GainRaw.Value) 23 | 24 | cam.Close() 25 | 26 | # Tests that you can set the Height parameter of the camera 27 | def test_height(self): 28 | cam = self.create_first() 29 | cam.Open() 30 | 31 | cam.Height.Value = cam.Height.Min 32 | self.assertEqual(1, cam.Height.Value) 33 | 34 | cam.Height.Value = cam.Height.Max 35 | self.assertEqual(4096, cam.Height.Value) 36 | 37 | cam.Height.Value = 500 38 | self.assertEqual(500, cam.Height.Value) 39 | 40 | cam.Close() 41 | 42 | # Tests that you can set the Width parameter of the camera 43 | def test_width(self): 44 | cam = self.create_first() 45 | cam.Open() 46 | 47 | cam.Width.Value = cam.Width.Min 48 | self.assertEqual(1, cam.Width.Value) 49 | 50 | cam.Width.Value = cam.Width.Max 51 | self.assertEqual(4096, cam.Width.Value) 52 | 53 | cam.Width.Value = 500 54 | self.assertEqual(500, cam.Width.Value) 55 | cam.Close() 56 | 57 | # Tests that you can set the ExposureTimeRaw parameter of the camera 58 | def test_exposure_time_raw(self): 59 | cam = self.create_first() 60 | cam.Open() 61 | 62 | cam.ExposureTimeRaw.Value = cam.ExposureTimeRaw.Min 63 | self.assertEqual(100, cam.ExposureTimeRaw.Value) 64 | 65 | cam.ExposureTimeRaw.Value = cam.ExposureTimeRaw.Max 66 | self.assertEqual(3000000, cam.ExposureTimeRaw.Value) 67 | 68 | cam.ExposureTimeRaw.Value = 1000 69 | self.assertEqual(1000, cam.ExposureTimeRaw.Value) 70 | 71 | cam.Close() 72 | 73 | # Tests that an emulated camera has no hardware interface 74 | def test_has_hardware_interface(self): 75 | cam = self.create_first() 76 | cam.Open() 77 | 78 | self.assertFalse(cam.IsUsb()) 79 | self.assertFalse(cam.IsCameraLink()) 80 | self.assertFalse(cam.IsGigE()) 81 | 82 | cam.Close() 83 | 84 | 85 | if __name__ == "__main__": 86 | # import sys;sys.argv = ['', 'Test.testName'] 87 | unittest.main() 88 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/grabresultdata_test.py: -------------------------------------------------------------------------------- 1 | from pylonemutestcase import PylonEmuTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class GrabResultDataTestSuite(PylonEmuTestCase): 7 | def test_emu_grabresultdata(self): 8 | camera = self.create_first() 9 | 10 | camera.Open() 11 | grabResult = camera.GrabOne(1000) 12 | camera.Close() 13 | 14 | self.assertTrue(grabResult.GrabSucceeded()) 15 | self.assertEqual(0, grabResult.GetErrorCode()) 16 | self.assertEqual(pylon.PayloadType_Image, grabResult.GetPayloadType()) 17 | self.assertEqual(pylon.PixelType_Mono8, grabResult.GetPixelType()) 18 | self.assertEqual(1024, grabResult.GetWidth()) 19 | self.assertEqual(1040, grabResult.GetHeight()) 20 | 21 | self.assertEqual(0, grabResult.GetOffsetX()) 22 | self.assertEqual(0, grabResult.GetOffsetY()) 23 | self.assertEqual(0, grabResult.GetPaddingX()) 24 | self.assertEqual(0, grabResult.GetPaddingY()) 25 | self.assertEqual(1024 * 1040, grabResult.GetImageSize()) 26 | 27 | 28 | if __name__ == "__main__": 29 | unittest.main() 30 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/import_test.py: -------------------------------------------------------------------------------- 1 | from pylonemutestcase import PylonEmuTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class ImportTestSuite(PylonEmuTestCase): 7 | # These are only "mounted" into the pylon namespace. So we ensure these are available here also 8 | def test_import_exceptions(self): 9 | from pypylon.pylon import GenericException; 10 | from pypylon.pylon import InvalidArgumentException; 11 | from pypylon.pylon import BadAllocException; 12 | from pypylon.pylon import OutOfRangeException; 13 | from pypylon.pylon import PropertyException; 14 | from pypylon.pylon import RuntimeException; 15 | from pypylon.pylon import LogicalErrorException; 16 | from pypylon.pylon import AccessException; 17 | from pypylon.pylon import TimeoutException; 18 | from pypylon.pylon import DynamicCastException; 19 | 20 | 21 | if __name__ == "__main__": 22 | # import sys;sys.argv = ['', 'Test.testName'] 23 | unittest.main() 24 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/instantcamera_test.py: -------------------------------------------------------------------------------- 1 | from pylonemutestcase import PylonEmuTestCase 2 | from pypylon import pylon 3 | import numpy 4 | import unittest 5 | 6 | 7 | class InstantCameraTestSuite(PylonEmuTestCase): 8 | def test_open_device(self): 9 | cam = pylon.InstantCamera() 10 | self.assertFalse(cam.IsOpen()) 11 | cam = self.create_first() 12 | cam.Open() 13 | self.assertTrue(cam.IsOpen()) 14 | cam.Close() 15 | self.assertFalse(cam.IsOpen()) 16 | 17 | def test_attach(self): 18 | cam = pylon.InstantCamera() 19 | self.assertFalse(cam.IsPylonDeviceAttached()) 20 | dev = pylon.TlFactory.GetInstance().CreateFirstDevice(self.device_filter[0]) 21 | cam.Attach(dev) 22 | cam.Open() 23 | self.assertTrue(cam.IsPylonDeviceAttached()) 24 | cam.DetachDevice() 25 | self.assertFalse(cam.IsPylonDeviceAttached()) 26 | 27 | def test_destroy_device(self): 28 | cam = self.create_first() 29 | cam.Open() 30 | cam.DestroyDevice() 31 | self.assertFalse(cam.IsPylonDeviceAttached()) 32 | self.assertFalse(cam.IsOpen()) 33 | 34 | def test_grab_one(self): 35 | cam = self.create_first() 36 | cam.Open() 37 | self.assertTrue(cam.GrabOne(1000)) 38 | result = cam.GrabOne(1000) 39 | actual = list(result.Array[0:20, 0]) 40 | expected = [actual[0] + i for i in range(20)] 41 | self.assertEqual(actual, expected) 42 | cam.Close() 43 | 44 | def test_grabbing(self): 45 | cam = self.create_first() 46 | cam.Open() 47 | self.assertFalse(cam.IsGrabbing()) 48 | cam.StartGrabbing() 49 | self.assertTrue(cam.IsGrabbing()) 50 | i = 0 51 | while (i < 10): 52 | # Wait for an image and then retrieve it. A timeout of 5000 ms is used. 53 | grabResult = cam.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) 54 | # Image grabbed successfully? 55 | if grabResult.GrabSucceeded(): 56 | # Access the image data. 57 | self.assertEqual(1024, grabResult.Width) 58 | self.assertEqual(1040, grabResult.Height) 59 | img = grabResult.Array 60 | grabResult.Release() 61 | self.assertTrue(cam.IsGrabbing()) 62 | i = i + 1 63 | cam.StopGrabbing() 64 | self.assertFalse(cam.IsGrabbing()) 65 | cam.Close() 66 | 67 | def test_has_hardware_interface(self): 68 | cam = self.create_first() 69 | cam.Open() 70 | self.assertFalse(cam.IsUsb()) 71 | self.assertFalse(cam.IsCameraLink()) 72 | self.assertFalse(cam.IsGigE()) 73 | 74 | cam.Close() 75 | 76 | ####################################################### 77 | # Can't test Eventhandlers with Emulated Cameras # 78 | # Can't test Softwaretrigger with Emulated Cameras # 79 | ####################################################### 80 | 81 | 82 | if __name__ == "__main__": 83 | unittest.main() 84 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/instantcameraparams_test.py: -------------------------------------------------------------------------------- 1 | from pylonemutestcase import PylonEmuTestCase 2 | from pypylon import pylon 3 | import time 4 | import unittest 5 | from sys import platform 6 | 7 | 8 | class InstantCameraTestSuite(PylonEmuTestCase): 9 | def test_params_set(self): 10 | 11 | # Do not choose a high value (> 15) for priority since that would require 12 | # admin privileges. 13 | if platform == 'linux': 14 | priority_for_test = 0 15 | else: 16 | priority_for_test = 15 17 | 18 | camera = pylon.InstantCamera() 19 | camera.MaxNumBuffer.Value = 20 20 | camera.MaxNumQueuedBuffer.Value = 40 21 | camera.MaxNumGrabResults.Value = 700 22 | camera.ChunkNodeMapsEnable.Value = False 23 | camera.StaticChunkNodeMapPoolSize.Value = 1 24 | camera.GrabCameraEvents.Value = True 25 | camera.MonitorModeActive.Value = True 26 | camera.InternalGrabEngineThreadPriorityOverride.Value = True 27 | camera.InternalGrabEngineThreadPriority.Value = priority_for_test 28 | camera.GrabLoopThreadUseTimeout.Value = True 29 | camera.GrabLoopThreadTimeout.Value = 10000 30 | camera.GrabLoopThreadPriorityOverride.Value = True 31 | camera.GrabLoopThreadPriority.Value = priority_for_test 32 | camera.OutputQueueSize.Value = 10 33 | 34 | self.assertEqual(20, camera.MaxNumBuffer.Value) 35 | self.assertEqual(40, camera.MaxNumQueuedBuffer.Value) 36 | self.assertEqual(700, camera.MaxNumGrabResults.Value) 37 | self.assertFalse(camera.ChunkNodeMapsEnable.Value) 38 | self.assertEqual(1, camera.StaticChunkNodeMapPoolSize.Value) 39 | self.assertTrue(camera.GrabCameraEvents.Value) 40 | self.assertTrue(camera.MonitorModeActive.Value) 41 | self.assertTrue(camera.InternalGrabEngineThreadPriorityOverride.Value) 42 | self.assertEqual(priority_for_test, camera.InternalGrabEngineThreadPriority.Value) 43 | self.assertTrue(camera.GrabLoopThreadUseTimeout.Value) 44 | self.assertEqual(10000, camera.GrabLoopThreadTimeout.Value) 45 | self.assertTrue(camera.GrabLoopThreadPriorityOverride.Value) 46 | self.assertEqual(priority_for_test, camera.GrabLoopThreadPriority.Value) 47 | self.assertEqual(10, camera.OutputQueueSize.Value) 48 | 49 | def test_variable_params(self): 50 | camera = self.create_first() 51 | camera.Open() 52 | camera.StartGrabbing() 53 | 54 | self.assertEqual(10, camera.NumQueuedBuffers.Value) 55 | 56 | #Busy waiting to work around a bug in python 3.4 that allows sleep to be interrupted 57 | #https://bugs.python.org/issue32057 58 | timeout = time.time() + 2 59 | while time.time() < timeout and camera.NumReadyBuffers.Value == 0: 60 | time.sleep(0.1) 61 | 62 | self.assertGreater(camera.NumReadyBuffers.Value, 0) 63 | self.assertEqual(0, camera.NumEmptyBuffers.Value) 64 | camera.Close() 65 | 66 | camera.MaxNumQueuedBuffer.Value = 5 67 | camera.Open() 68 | camera.StartGrabbing() 69 | self.assertEqual(5, camera.NumEmptyBuffers.Value) 70 | camera.Close() 71 | 72 | 73 | if __name__ == "__main__": 74 | unittest.main() 75 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/little_boxes.gendc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/tests/pylon_tests/emulated/little_boxes.gendc -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/loadandsave_test.py: -------------------------------------------------------------------------------- 1 | from pylonemutestcase import PylonEmuTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class LoadAndSaveTestSuite(PylonEmuTestCase): 7 | def test_load_and_save(self): 8 | nodeFile = "NodeMap.pfs" 9 | 10 | # Create an instant camera object with the camera device found first. 11 | camera = self.create_first() 12 | camera.Open() 13 | # Print the model name of the camera. 14 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 15 | 16 | # featurePersistence = pylon.FeaturePersistence() 17 | 18 | print("Saving camera's node map to file...") 19 | print(nodeFile) 20 | 21 | # Save the content of the camera's node map into the file. 22 | pylon.FeaturePersistence.Save(nodeFile, camera.GetNodeMap()) 23 | 24 | # Just for demonstration, read the content of the file back to the camera's node map with enabled validation. 25 | print("Reading file back to camera's node map...") 26 | pylon.FeaturePersistence.Load(nodeFile, camera.GetNodeMap(), True) 27 | # Close the camera. 28 | camera.Close() 29 | 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/pylonemutestcase.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import sys 4 | num = 3 5 | os.environ["PYLON_CAMEMU"] = "%d" % num 6 | from pypylon import pylon 7 | 8 | def get_class_and_filter(): 9 | device_class = "BaslerCamEmu" 10 | di = pylon.DeviceInfo() 11 | di.SetDeviceClass(device_class) 12 | return device_class, [di] 13 | 14 | 15 | class PylonEmuTestCase(unittest.TestCase): 16 | num_dev = num 17 | device_class, device_filter = get_class_and_filter() 18 | 19 | def create_first(self): 20 | tlf = pylon.TlFactory.GetInstance() 21 | return pylon.InstantCamera(tlf.CreateFirstDevice(self.device_filter[0])) 22 | 23 | 24 | -------------------------------------------------------------------------------- /tests/pylon_tests/emulated/version_test.py: -------------------------------------------------------------------------------- 1 | from pylonemutestcase import PylonEmuTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class VersionInfoTestSuite(PylonEmuTestCase): 7 | # Tests that you can get proper version info 8 | def test_version_get(self): 9 | cam = self.create_first() 10 | cam.Open() 11 | 12 | v = cam.GetSfncVersion() 13 | 14 | # camemu has sfnc version 0.0.0.0 15 | self.assertEqual(0, v.getMajor()) 16 | self.assertEqual(0, v.getMinor()) 17 | self.assertEqual(0, v.getSubminor()) 18 | self.assertEqual(0, v.getBuild()) 19 | 20 | cam.Close() 21 | 22 | # Tests that you can compare version info 23 | def test_version_compare(self): 24 | v0 = pylon.VersionInfo(2, 2, 2) 25 | v1 = pylon.VersionInfo(2, 2, 1) 26 | v0_1 = pylon.VersionInfo(2, 2, 2) 27 | 28 | self.assertGreater(v0, v1) 29 | self.assertLess(v1, v0) 30 | self.assertEqual(v0, v0_1) 31 | 32 | # Tests that version info has repr 33 | def test_version_repr(self): 34 | cam = self.create_first() 35 | cam.Open() 36 | 37 | v = cam.GetSfncVersion() 38 | sfnc_version_repr = v.__repr__() 39 | self.assertEqual("", sfnc_version_repr) 40 | 41 | 42 | if __name__ == "__main__": 43 | # import sys;sys.argv = ['', 'Test.testName'] 44 | unittest.main() 45 | -------------------------------------------------------------------------------- /tests/pylon_tests/gigE/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | #adding this dir to the path allows: 5 | # from pylonemutestcase import PylonEmuTestCase 6 | #THis is no clean solution, but works for now 7 | sys.path.insert(0, os.path.dirname(__file__)) 8 | -------------------------------------------------------------------------------- /tests/pylon_tests/gigE/call_test.py: -------------------------------------------------------------------------------- 1 | from pylongigetestcase import PylonTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class CallTestSuite(PylonTestCase): 7 | # Tests that you can set the GainRaw parameter of the camera 8 | def test_Gain(self): 9 | cam = self.create_first() 10 | cam.Open() 11 | 12 | # Set GainRaw to min value (192) 13 | cam.GainRaw.Value = cam.GainRaw.Max 14 | self.assertEqual(cam.GainRaw.Max, cam.GainRaw.Max) 15 | 16 | # Set GainRaw to max value (1023) 17 | cam.GainRaw.Value = cam.GainRaw.Max 18 | self.assertEqual(cam.GainRaw.Max, cam.GainRaw.Value) 19 | 20 | cam.Close() 21 | 22 | # Tests that you can set the Height parameter of the camera 23 | def test_Height(self): 24 | cam = self.create_first() 25 | cam.Open() 26 | 27 | cam.Height.Value = cam.Height.Min 28 | self.assertEqual(cam.Height.Min, cam.Height.Value) 29 | 30 | cam.Height.Value = cam.Height.Max 31 | self.assertEqual(cam.Height.Max, cam.Height.Value) 32 | 33 | cam.Height.Value = 500 34 | self.assertEqual(500, cam.Height.Value) 35 | 36 | cam.Close() 37 | 38 | # Tests that you can set the Width parameter of the camera 39 | def test_Width(self): 40 | cam = self.create_first() 41 | cam.Open() 42 | 43 | cam.Width.Value = cam.Width.Min 44 | self.assertEqual(cam.Width.Min, cam.Width.Value) 45 | 46 | cam.Width.Value = cam.Width.Max 47 | self.assertEqual(cam.Width.Max, cam.Width.Value) 48 | 49 | # Tests that an emulated camera has no hardware interface 50 | def test_hasHardwareInterface(self): 51 | cam = self.create_first() 52 | cam.Open() 53 | 54 | self.assertFalse(cam.IsUsb()) 55 | self.assertFalse(cam.IsCameraLink()) 56 | self.assertTrue(cam.IsGigE()) 57 | 58 | cam.Close() 59 | 60 | 61 | if __name__ == "__main__": 62 | unittest.main() 63 | -------------------------------------------------------------------------------- /tests/pylon_tests/gigE/chunkimage_test.py: -------------------------------------------------------------------------------- 1 | from pylongigetestcase import PylonTestCase 2 | from pypylon import pylon 3 | from pypylon import genicam 4 | import unittest 5 | 6 | 7 | class ChunkImageTestSuite(PylonTestCase): 8 | countOfImagesToGrab = 5 9 | 10 | def test_grab_chunk_image(self): 11 | 12 | camera = self.create_first() 13 | 14 | # Open the camera. 15 | camera.Open() 16 | 17 | camera.StaticChunkNodeMapPoolSize.Value = camera.MaxNumBuffer.Value 18 | 19 | if genicam.IsWritable(camera.ChunkModeActive): 20 | camera.ChunkModeActive.Value = True 21 | else: 22 | self.fail() 23 | 24 | # Enable time stamp chunks. 25 | camera.ChunkSelector.Value = "Timestamp" 26 | camera.ChunkEnable.Value = True 27 | 28 | # Enable CRC checksum chunks. 29 | camera.ChunkSelector.Value = "PayloadCRC16" 30 | camera.ChunkEnable.Value = True 31 | 32 | camera.StartGrabbingMax(self.countOfImagesToGrab) 33 | 34 | while camera.IsGrabbing(): 35 | 36 | # Wait for an image and then retrieve it. A timeout of 5000 ms is used. 37 | # RetrieveResult calls the image event handler's OnImageGrabbed method. 38 | grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) 39 | 40 | # Check to see if a buffer containing chunk data has been received. 41 | if pylon.PayloadType_ChunkData != grabResult.PayloadType: 42 | self.fail() 43 | 44 | # Since we have activated the CRC Checksum feature, we can check 45 | # the integrity of the buffer first. 46 | # Note: Enabling the CRC Checksum feature is not a prerequisite for using 47 | # chunks. Chunks can also be handled when the CRC Checksum feature is deactivated. 48 | if grabResult.HasCRC() and grabResult.CheckCRC() == False: 49 | self.fail() 50 | 51 | if not genicam.IsReadable(grabResult.ChunkTimestamp): 52 | self.fail() 53 | 54 | camera.ChunkModeActive.Value = False 55 | 56 | 57 | if __name__ == "__main__": 58 | unittest.main() 59 | -------------------------------------------------------------------------------- /tests/pylon_tests/gigE/loadandsave_test.py: -------------------------------------------------------------------------------- 1 | from pylongigetestcase import PylonTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class LoadAndSaveTestSuite(PylonTestCase): 7 | def test_load_and_save(self): 8 | nodeFile = "NodeMap.pfs" 9 | 10 | # Create an instant camera object with the camera device found first. 11 | camera = self.create_first() 12 | camera.Open() 13 | # Print the model name of the camera. 14 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 15 | 16 | # featurePersistence = pylon.FeaturePersistence() 17 | 18 | print("Saving camera's node map to file...") 19 | print(nodeFile) 20 | 21 | # Save the content of the camera's node map into the file. 22 | pylon.FeaturePersistence.Save(nodeFile, camera.GetNodeMap()) 23 | 24 | # Just for demonstration, read the content of the file back to the camera's node map with enabled validation. 25 | print("Reading file back to camera's node map...") 26 | pylon.FeaturePersistence.Load(nodeFile, camera.GetNodeMap(), True) 27 | # Close the camera. 28 | camera.Close() 29 | 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /tests/pylon_tests/gigE/pylongigetestcase.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from pypylon import pylon 3 | 4 | def get_class_and_filter(): 5 | device_class = "BaslerGigE" 6 | di = pylon.DeviceInfo() 7 | di.SetDeviceClass(device_class) 8 | return device_class, [di] 9 | 10 | class PylonTestCase(unittest.TestCase): 11 | device_class, device_filter = get_class_and_filter() 12 | 13 | def create_first(self): 14 | tlf = pylon.TlFactory.GetInstance() 15 | return pylon.InstantCamera(tlf.CreateFirstDevice(self.device_filter[0])) 16 | -------------------------------------------------------------------------------- /tests/pylon_tests/usb/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | 4 | #adding this dir to the path allows: 5 | # from pylonemutestcase import PylonEmuTestCase 6 | #THis is no clean solution, but works for now 7 | sys.path.insert(0, os.path.dirname(__file__)) 8 | -------------------------------------------------------------------------------- /tests/pylon_tests/usb/call_test.py: -------------------------------------------------------------------------------- 1 | from pylonusbtestcase import PylonTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class CallTestSuite(PylonTestCase): 7 | # Tests that you can set the Gain parameter of the camera 8 | def test_gain(self): 9 | cam = self.create_first() 10 | cam.Open() 11 | 12 | # Set Gain to min value 13 | cam.Gain.Value = cam.Gain.Min 14 | self.assertEqual(cam.Gain.Min, cam.Gain.Value) 15 | 16 | # Set Gain to max value 17 | cam.Gain.Value = cam.Gain.Max 18 | self.assertEqual(cam.Gain.Max, cam.Gain.Value) 19 | 20 | cam.Close() 21 | 22 | # Tests that you can set the Height parameter of the camera 23 | def test_height(self): 24 | cam = self.create_first() 25 | cam.Open() 26 | 27 | cam.Height.Value = cam.Height.Min 28 | self.assertEqual(cam.Height.Min, cam.Height.Value) 29 | 30 | cam.Height.Value = cam.Height.Max 31 | self.assertEqual(cam.Height.Max, cam.Height.Value) 32 | 33 | cam.Height.Value = 500 34 | self.assertEqual(500, cam.Height.Value) 35 | 36 | cam.Close() 37 | 38 | # Tests that you can set the Width parameter of the camera 39 | def test_width(self): 40 | cam = self.create_first() 41 | cam.Open() 42 | 43 | cam.Width.Value = cam.Width.Min 44 | self.assertEqual(cam.Width.Min, cam.Width.Value) 45 | 46 | cam.Width.Value = cam.Width.Max 47 | self.assertEqual(cam.Width.Max, cam.Width.Value) 48 | 49 | # Tests that you can set the ExposureTime parameter of the camera 50 | def test_exposure_time(self): 51 | cam = self.create_first() 52 | cam.Open() 53 | 54 | cam.ExposureTime.Value = cam.ExposureTime.Min 55 | self.assertEqual(cam.ExposureTime.Min, cam.ExposureTime.Value) 56 | 57 | cam.ExposureTime.Value = cam.ExposureTime.Max 58 | self.assertEqual(cam.ExposureTime.Max, cam.ExposureTime.Value) 59 | 60 | cam.ExposureTime.Value = 1000 61 | self.assertEqual(1000, cam.ExposureTime.Value) 62 | 63 | cam.Close() 64 | 65 | # Tests that a usb camera only has a usb hardware interface 66 | def test_hardware_interface(self): 67 | cam = self.create_first() 68 | cam.Open() 69 | 70 | self.assertTrue(cam.IsUsb()) 71 | self.assertFalse(cam.IsCameraLink()) 72 | self.assertFalse(cam.IsGigE()) 73 | 74 | cam.Close() 75 | 76 | 77 | if __name__ == "__main__": 78 | unittest.main() 79 | -------------------------------------------------------------------------------- /tests/pylon_tests/usb/chunkimage_test.py: -------------------------------------------------------------------------------- 1 | from pylonusbtestcase import PylonTestCase 2 | from pypylon import pylon 3 | from pypylon import genicam 4 | import unittest 5 | 6 | 7 | class ChunkImageTestSuite(PylonTestCase): 8 | countOfImagesToGrab = 5 9 | 10 | # sample Grab_ChunkImage as test 11 | def test_grab_chunk_image(self): 12 | 13 | # Only look for usb cameras 14 | info = pylon.DeviceInfo() 15 | info.SetDeviceClass("BaslerUsb") 16 | 17 | # Create an instant camera object with the first found camera device that matches the specified device class. 18 | camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice(info)) 19 | 20 | # Open the camera. 21 | camera.Open() 22 | 23 | camera.StaticChunkNodeMapPoolSize.Value = camera.MaxNumBuffer.Value 24 | 25 | if genicam.IsWritable(camera.ChunkModeActive): 26 | camera.ChunkModeActive.Value = True 27 | else: 28 | self.fail() 29 | 30 | # Enable time stamp chunks. 31 | camera.ChunkSelector.Value = "Timestamp" 32 | camera.ChunkEnable.Value = True 33 | 34 | # Enable CRC checksum chunks. 35 | camera.ChunkSelector.Value = "PayloadCRC16" 36 | camera.ChunkEnable.Value = True 37 | 38 | camera.StartGrabbingMax(self.countOfImagesToGrab) 39 | 40 | while camera.IsGrabbing(): 41 | 42 | # Wait for an image and then retrieve it. A timeout of 5000 ms is used. 43 | # RetrieveResult calls the image event handler's OnImageGrabbed method. 44 | grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) 45 | 46 | # Check to see if a buffer containing chunk data has been received. 47 | if pylon.PayloadType_ChunkData != grabResult.PayloadType: 48 | self.fail() 49 | 50 | # Since we have activated the CRC Checksum feature, we can check 51 | # the integrity of the buffer first. 52 | # Note: Enabling the CRC Checksum feature is not a prerequisite for using 53 | # chunks. Chunks can also be handled when the CRC Checksum feature is deactivated. 54 | if grabResult.HasCRC() and grabResult.CheckCRC() == False: 55 | self.fail() 56 | 57 | if not genicam.IsReadable(grabResult.ChunkTimestamp): 58 | self.fail() 59 | 60 | camera.ChunkModeActive.Value = False 61 | 62 | 63 | if __name__ == "__main__": 64 | unittest.main() 65 | -------------------------------------------------------------------------------- /tests/pylon_tests/usb/decompression_test.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | from numpy.testing import assert_array_equal 4 | 5 | from pylonusbtestcase import PylonTestCase 6 | from pypylon import pylon, genicam 7 | 8 | 9 | class GrabTestSuite(PylonTestCase): 10 | def setUp(self): 11 | super().setUp() 12 | 13 | self.camera = pylon.InstantCamera( 14 | pylon.TlFactory.GetInstance().CreateFirstDevice() 15 | ) 16 | self.camera.Open() 17 | self.camera.ExposureTime.Value = self.camera.ExposureTime.Min 18 | 19 | self.camera.PixelFormat.Value = "Mono8" 20 | self.camera.TestPattern.Value = "Testimage1" 21 | 22 | self.camera.ImageCompressionMode.Value = "Off" 23 | with self.camera.GrabOne(10000) as compressed_image: 24 | self.reference_array = compressed_image.Array 25 | 26 | try: 27 | self.camera.ImageCompressionMode.Value = "BaslerCompressionBeyond" 28 | except (genicam.RuntimeException, genicam.InvalidArgumentException): 29 | self.camera.Close() 30 | self.skipTest("camera does not support baser compression beyond") 31 | 32 | self.camera.ImageCompressionRateOption.Value = "Lossless" 33 | self.camera.BslImageCompressionRatio.Value = 100.0 34 | 35 | def tearDown(self): 36 | self.camera.Close() 37 | super().tearDown() 38 | 39 | def test_grab_compressed(self): 40 | decompressor = pylon.ImageDecompressor() 41 | 42 | descriptor = self.camera.BslImageCompressionBCBDescriptor.GetAll() 43 | decompressor.SetCompressionDescriptor(descriptor) 44 | 45 | with self.camera.GrabOne(10000) as compressed_image: 46 | payload = compressed_image.GetBuffer() 47 | decompressed_image = decompressor.DecompressImage(payload) 48 | decompressed_array = decompressed_image.Array 49 | 50 | assert_array_equal(self.reference_array, decompressed_array) 51 | 52 | self.camera.Close() 53 | 54 | def test_decompress_image(self): 55 | decompressor = pylon.ImageDecompressor() 56 | 57 | descriptor = self.camera.BslImageCompressionBCBDescriptor.GetAll() 58 | decompressor.SetCompressionDescriptor(descriptor) 59 | 60 | with self.camera.GrabOne(10000) as compressed_image: 61 | decompressed_image = decompressor.DecompressImage(compressed_image) 62 | decompressed_array = decompressed_image.Array 63 | 64 | assert_array_equal(self.reference_array, decompressed_array) 65 | 66 | self.camera.Close() 67 | 68 | 69 | if __name__ == "__main__": 70 | unittest.main() 71 | -------------------------------------------------------------------------------- /tests/pylon_tests/usb/loadandsave_test.py: -------------------------------------------------------------------------------- 1 | from pylonusbtestcase import PylonTestCase 2 | from pypylon import pylon 3 | import unittest 4 | 5 | 6 | class LoadAndSaveTestSuite(PylonTestCase): 7 | def test_load_and_save(self): 8 | nodeFile = "NodeMap.pfs" 9 | 10 | # Create an instant camera object with the camera device found first. 11 | camera = self.create_first() 12 | camera.Open() 13 | # Print the model name of the camera. 14 | print("Using device ", camera.GetDeviceInfo().GetModelName()) 15 | 16 | # featurePersistence = pylon.FeaturePersistence() 17 | 18 | print("Saving camera's node map to file...") 19 | print(nodeFile) 20 | 21 | # Save the content of the camera's node map into the file. 22 | pylon.FeaturePersistence.Save(nodeFile, camera.GetNodeMap()) 23 | 24 | # Just for demonstration, read the content of the file back to the camera's node map with enabled validation. 25 | print("Reading file back to camera's node map...") 26 | pylon.FeaturePersistence.Load(nodeFile, camera.GetNodeMap(), True) 27 | # Close the camera. 28 | camera.Close() 29 | 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /tests/pylon_tests/usb/pylonusbtestcase.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | from pypylon import pylon 3 | 4 | def get_class_and_filter(): 5 | device_class = "BaslerUsb" 6 | di = pylon.DeviceInfo() 7 | di.SetDeviceClass(device_class) 8 | return device_class, [di] 9 | 10 | class PylonTestCase(unittest.TestCase): 11 | device_class, device_filter = get_class_and_filter() 12 | 13 | def create_first(self): 14 | tlf = pylon.TlFactory.GetInstance() 15 | return pylon.InstantCamera(tlf.CreateFirstDevice(self.device_filter[0])) 16 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/__init__.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import os 3 | import sys 4 | 5 | sys.path.insert(0, os.path.dirname(__file__)) 6 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/circlef_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class CircleFTestSuite(PylonDataProcessingTestCase): 6 | def test_init(self): 7 | testee1 = pylondataprocessing.CircleF() 8 | self.assertEqual(testee1.Center.X, 0.0) 9 | self.assertEqual(testee1.Center.Y, 0.0) 10 | self.assertEqual(testee1.Radius, 0.0) 11 | testee2 = pylondataprocessing.CircleF(1.2, 3.4, 5.6) 12 | self.assertEqual(testee2.Center.X, 1.2) 13 | self.assertEqual(testee2.Center.Y, 3.4) 14 | self.assertEqual(testee2.Radius, 5.6) 15 | testee3 = pylondataprocessing.CircleF(pylondataprocessing.PointF2D(1.22, 3.42), 5.62) 16 | self.assertEqual(testee3.Center.X, 1.22) 17 | self.assertEqual(testee3.Center.Y, 3.42) 18 | self.assertEqual(testee3.Radius, 5.62) 19 | testee4 = pylondataprocessing.CircleF(testee3) 20 | self.assertEqual(testee4.Center.X, 1.22) 21 | self.assertEqual(testee4.Center.Y, 3.42) 22 | self.assertEqual(testee4.Radius, 5.62) 23 | #Center returns _Center with a reference to its parent added 24 | #_Center holds a pointer to the C++ member SCircleF::Center 25 | #CircleF must not be released while using _Center 26 | self.assertEqual(testee4.Center.X, testee4._Center.X) 27 | testee4.Center.Y = 1234.5 28 | self.assertEqual(testee4.Center.Y, 1234.5) 29 | 30 | def test_str(self): 31 | testee = pylondataprocessing.CircleF(1.2, 3.4, 5.6) 32 | self.assertEqual(str(testee), "Center: (X = 1.2; Y = 3.4); Radius = 5.6") 33 | 34 | if __name__ == "__main__": 35 | unittest.main() 36 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/ellipsef_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class EllipseFTestSuite(PylonDataProcessingTestCase): 6 | def test_init(self): 7 | testee1 = pylondataprocessing.EllipseF() 8 | self.assertEqual(testee1.Center.X, 0.0) 9 | self.assertEqual(testee1.Center.Y, 0.0) 10 | self.assertEqual(testee1.Radius1, 0.0) 11 | self.assertEqual(testee1.Radius2, 0.0) 12 | self.assertEqual(testee1.Rotation, 0.0) 13 | testee2 = pylondataprocessing.EllipseF(1.2, 3.4, 5.6, 7.8, 9.0) 14 | self.assertEqual(testee2.Center.X, 1.2) 15 | self.assertEqual(testee2.Center.Y, 3.4) 16 | self.assertEqual(testee2.Radius1, 5.6) 17 | self.assertEqual(testee2.Radius2, 7.8) 18 | self.assertEqual(testee2.Rotation, 9.0) 19 | testee3 = pylondataprocessing.EllipseF(pylondataprocessing.PointF2D(1.22, 3.42), 5.62, 7.82, 9.02) 20 | self.assertEqual(testee3.Center.X, 1.22) 21 | self.assertEqual(testee3.Center.Y, 3.42) 22 | self.assertEqual(testee3.Radius1, 5.62) 23 | self.assertEqual(testee3.Radius2, 7.82) 24 | self.assertEqual(testee3.Rotation, 9.02) 25 | testee4 = pylondataprocessing.EllipseF(1.2, 3.4, 5.6, 7.8) 26 | self.assertEqual(testee4.Center.X, 1.2) 27 | self.assertEqual(testee4.Center.Y, 3.4) 28 | self.assertEqual(testee4.Radius1, 5.6) 29 | self.assertEqual(testee4.Radius2, 7.8) 30 | self.assertEqual(testee4.Rotation, 0.0) 31 | testee5 = pylondataprocessing.EllipseF(pylondataprocessing.PointF2D(1.22, 3.42), 5.62, 7.82) 32 | self.assertEqual(testee5.Center.X, 1.22) 33 | self.assertEqual(testee5.Center.Y, 3.42) 34 | self.assertEqual(testee5.Radius1, 5.62) 35 | self.assertEqual(testee5.Radius2, 7.82) 36 | self.assertEqual(testee5.Rotation, 0.0) 37 | testee6 = pylondataprocessing.EllipseF(testee5) 38 | self.assertEqual(testee6.Center.X, 1.22) 39 | self.assertEqual(testee6.Center.Y, 3.42) 40 | self.assertEqual(testee6.Radius1, 5.62) 41 | self.assertEqual(testee6.Radius2, 7.82) 42 | self.assertEqual(testee6.Rotation, 0.0) 43 | #Center returns _Center with a reference to its parent added 44 | #_Center holds a pointer to the C++ member SEllipseF::Center 45 | #EllipseF must not be released while using _Center 46 | self.assertEqual(testee6.Center.X, testee6._Center.X) 47 | testee6.Center.Y = 1234.5 48 | self.assertEqual(testee6.Center.Y, 1234.5) 49 | 50 | def test_str(self): 51 | testee = pylondataprocessing.EllipseF(1.2, 3.4, 5.6, 7.8, 9.0) 52 | self.assertEqual(str(testee), "Center: (X = 1.2; Y = 3.4); Radius1 = 5.6; Radius2 = 7.8; Rotation = 9.0 rad") 53 | 54 | if __name__ == "__main__": 55 | unittest.main() 56 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/genericoutputobserver_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | from pypylon import genicam 4 | import unittest 5 | 6 | class GenericOutputObserverTestSuite(PylonDataProcessingTestCase): 7 | def test_init(self): 8 | testee1 = pylondataprocessing.GenericOutputObserverResult() 9 | self.assertEqual(testee1.Update, pylondataprocessing.Update()) 10 | self.assertEqual(testee1.UserProvidedID, 0) 11 | self.assertTrue(type(testee1.Container) is dict) 12 | self.assertTrue(type(testee1.GetContainer()) is dict) #do not use 13 | 14 | testee2 = pylondataprocessing.GenericOutputObserver() 15 | self.assertFalse(testee2.GetWaitObject().Wait(0)) 16 | self.assertEqual(testee2.GetNumResults(), 0) 17 | self.assertTrue(type(testee2.RetrieveFullResult().Container) is dict) 18 | self.assertTrue(type(testee2.RetrieveResult()) is dict) 19 | self.assertEqual(len(testee2.RetrieveFullResult().Container), 0) 20 | self.assertEqual(len(testee2.RetrieveResult()), 0) 21 | testee2.Clear() 22 | 23 | def test_push(self): 24 | inputData = {"Image" : pylondataprocessing.Variant(pylondataprocessing.VariantDataType_PylonImage)} 25 | testee1 = pylondataprocessing.GenericOutputObserver() 26 | testee1.OutputDataPush(pylondataprocessing.Recipe(), inputData, pylondataprocessing.Update(), 892); 27 | self.assertTrue(testee1.GetWaitObject().Wait(0)) 28 | self.assertEqual(testee1.GetNumResults(), 1) 29 | testee2 = testee1.RetrieveFullResult() 30 | self.assertFalse(testee1.GetWaitObject().Wait(0)) 31 | self.assertEqual(testee1.GetNumResults(), 0) 32 | self.assertTrue(type(testee2.Container) is dict) 33 | self.assertEqual(len(testee2.Container), 1) 34 | self.assertEqual(testee2.UserProvidedID, 892) 35 | self.assertFalse(testee2.Update.IsValid()) 36 | testee1.OutputDataPush(pylondataprocessing.Recipe(), inputData, pylondataprocessing.Update(), 892); 37 | self.assertTrue(testee1.GetWaitObject().Wait(0)) 38 | self.assertEqual(testee1.GetNumResults(), 1) 39 | testee3 = testee1.RetrieveResult() 40 | self.assertFalse(testee1.GetWaitObject().Wait(0)) 41 | self.assertEqual(testee1.GetNumResults(), 0) 42 | self.assertEqual(testee3, inputData) 43 | testee1.OutputDataPush(pylondataprocessing.Recipe(), inputData, pylondataprocessing.Update(), 892); 44 | self.assertTrue(testee1.GetWaitObject().Wait(0)) 45 | self.assertTrue(testee1.WaitObject.Wait(0)) 46 | self.assertEqual(testee1.GetNumResults(), 1) 47 | self.assertEqual(testee1.NumResults, 1) 48 | testee1.Clear() 49 | self.assertFalse(testee1.GetWaitObject().Wait(0)) 50 | self.assertEqual(testee1.GetNumResults(), 0) 51 | 52 | if __name__ == "__main__": 53 | unittest.main() 54 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/linef2d_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class LineF2DTestSuite(PylonDataProcessingTestCase): 6 | def test_init(self): 7 | testee1 = pylondataprocessing.LineF2D() 8 | self.assertEqual(testee1.PointA.X, 0.0) 9 | self.assertEqual(testee1.PointA.Y, 0.0) 10 | self.assertEqual(testee1.PointB.X, 0.0) 11 | self.assertEqual(testee1.PointB.Y, 0.0) 12 | testee2 = pylondataprocessing.LineF2D(1.2, 3.4, 5.6, 7.8) 13 | self.assertEqual(testee2.PointA.X, 1.2) 14 | self.assertEqual(testee2.PointA.Y, 3.4) 15 | self.assertEqual(testee2.PointB.X, 5.6) 16 | self.assertEqual(testee2.PointB.Y, 7.8) 17 | testee3 = pylondataprocessing.LineF2D(pylondataprocessing.PointF2D(1.22, 3.42), pylondataprocessing.PointF2D(5.62, 7.82)) 18 | self.assertEqual(testee3.PointA.X, 1.22) 19 | self.assertEqual(testee3.PointA.Y, 3.42) 20 | self.assertEqual(testee3.PointB.X, 5.62) 21 | self.assertEqual(testee3.PointB.Y, 7.82) 22 | testee4 = pylondataprocessing.LineF2D(testee3) 23 | self.assertEqual(testee4.PointA.X, 1.22) 24 | self.assertEqual(testee4.PointA.Y, 3.42) 25 | self.assertEqual(testee4.PointB.X, 5.62) 26 | self.assertEqual(testee4.PointB.Y, 7.82) 27 | #PointA returns _PointA with a reference to its parent added 28 | #_PointA holds a pointer to the C++ member SLineF2D::PointA 29 | #LineF2D must not be released while using _PointA 30 | self.assertEqual(testee4.PointA.X, testee4._PointA.X) 31 | self.assertEqual(testee4.PointB.X, testee4._PointB.X) 32 | testee4.PointB.Y = 1234.5 33 | self.assertEqual(testee4.PointB.Y, 1234.5) 34 | 35 | 36 | def test_str(self): 37 | testee = pylondataprocessing.LineF2D(1.2, 3.4, 5.6, 7.8) 38 | self.assertEqual(str(testee), "PointA: (X = 1.2; Y = 3.4); PointB: (X = 5.6; Y = 7.8)") 39 | 40 | if __name__ == "__main__": 41 | unittest.main() 42 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/pointf2d_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class PointF2DTestSuite(PylonDataProcessingTestCase): 6 | def test_init(self): 7 | testee1 = pylondataprocessing.PointF2D() 8 | self.assertEqual(testee1.X, 0.0) 9 | self.assertEqual(testee1.Y, 0.0) 10 | testee2 = pylondataprocessing.PointF2D(1.2, 3.4) 11 | self.assertEqual(testee2.X, 1.2) 12 | self.assertEqual(testee2.Y, 3.4) 13 | testee3 = pylondataprocessing.PointF2D(testee2) 14 | self.assertEqual(testee3.X, 1.2) 15 | self.assertEqual(testee3.Y, 3.4) 16 | 17 | def test_str(self): 18 | testee = pylondataprocessing.PointF2D(1.2, 3.4) 19 | self.assertEqual(str(testee), "X = 1.2; Y = 3.4") 20 | 21 | if __name__ == "__main__": 22 | unittest.main() 23 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/pylondataprocessingtestcase.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 11.09.2023 3 | 4 | ''' 5 | import unittest 6 | from pypylon import pylondataprocessing 7 | 8 | class PylonDataProcessingTestCase(unittest.TestCase): 9 | pass 10 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/queuemode_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class QueueModeTestSuite(PylonDataProcessingTestCase): 6 | def test_presence(self): 7 | self.assertEqual(pylondataprocessing.QueueMode_Unlimited, 0) 8 | self.assertEqual(pylondataprocessing.QueueMode_DropOldest, 1) 9 | self.assertEqual(pylondataprocessing.QueueMode_DropNewest, 2) 10 | self.assertEqual(pylondataprocessing.QueueMode_Blocking, 3) 11 | 12 | if __name__ == "__main__": 13 | unittest.main() 14 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/recipe_test1.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/tests/pylondataprocessing_tests/recipe_test1.tif -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/recipe_test2.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/tests/pylondataprocessing_tests/recipe_test2.tif -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/recipe_test3.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/basler/pypylon/ef333ee565650b6f9c5da81f6456b3e134b99357/tests/pylondataprocessing_tests/recipe_test3.tif -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/recipefileformat_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | from pypylon import pylon 4 | import unittest 5 | 6 | class RecipeFileFormatTestSuite(PylonDataProcessingTestCase): 7 | def test_presence(self): 8 | if pylondataprocessing.GetVersion() >= pylon.VersionInfo(3,1,0): 9 | self.assertEqual(pylondataprocessing.RecipeFileFormat_JsonDefault, 1) 10 | self.assertEqual(pylondataprocessing.RecipeFileFormat_JsonCompressedBinaryData, 2) 11 | 12 | if __name__ == "__main__": 13 | unittest.main() 14 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/rectanglef_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class RectangleFTestSuite(PylonDataProcessingTestCase): 6 | def test_init(self): 7 | testee1 = pylondataprocessing.RectangleF() 8 | self.assertEqual(testee1.Center.X, 0.0) 9 | self.assertEqual(testee1.Center.Y, 0.0) 10 | self.assertEqual(testee1.Width, 0.0) 11 | self.assertEqual(testee1.Height, 0.0) 12 | self.assertEqual(testee1.Rotation, 0.0) 13 | testee2 = pylondataprocessing.RectangleF(1.2, 3.4, 5.6, 7.8, 9.0) 14 | self.assertEqual(testee2.Center.X, 1.2) 15 | self.assertEqual(testee2.Center.Y, 3.4) 16 | self.assertEqual(testee2.Width, 5.6) 17 | self.assertEqual(testee2.Height, 7.8) 18 | self.assertEqual(testee2.Rotation, 9.0) 19 | testee3 = pylondataprocessing.RectangleF(pylondataprocessing.PointF2D(1.22, 3.42), 5.62, 7.82, 9.02) 20 | self.assertEqual(testee3.Center.X, 1.22) 21 | self.assertEqual(testee3.Center.Y, 3.42) 22 | self.assertEqual(testee3.Width, 5.62) 23 | self.assertEqual(testee3.Height, 7.82) 24 | self.assertEqual(testee3.Rotation, 9.02) 25 | testee4 = pylondataprocessing.RectangleF(1.2, 3.4, 5.6, 7.8) 26 | self.assertEqual(testee4.Center.X, 1.2) 27 | self.assertEqual(testee4.Center.Y, 3.4) 28 | self.assertEqual(testee4.Width, 5.6) 29 | self.assertEqual(testee4.Height, 7.8) 30 | self.assertEqual(testee4.Rotation, 0.0) 31 | testee5 = pylondataprocessing.RectangleF(pylondataprocessing.PointF2D(1.22, 3.42), 5.62, 7.82) 32 | self.assertEqual(testee5.Center.X, 1.22) 33 | self.assertEqual(testee5.Center.Y, 3.42) 34 | self.assertEqual(testee5.Width, 5.62) 35 | self.assertEqual(testee5.Height, 7.82) 36 | self.assertEqual(testee5.Rotation, 0.0) 37 | testee6 = pylondataprocessing.RectangleF(testee5) 38 | self.assertEqual(testee6.Center.X, 1.22) 39 | self.assertEqual(testee6.Center.Y, 3.42) 40 | self.assertEqual(testee6.Width, 5.62) 41 | self.assertEqual(testee6.Height, 7.82) 42 | self.assertEqual(testee6.Rotation, 0.0) 43 | #Center returns _Center with a reference to its parent added 44 | #_Center holds a pointer to the C++ member SRectangleF::Center 45 | #RectangleF must not be released while using _Center 46 | self.assertEqual(testee6.Center.X, testee6._Center.X) 47 | testee6.Center.Y = 1234.5 48 | self.assertEqual(testee6.Center.Y, 1234.5) 49 | 50 | 51 | def test_str(self): 52 | testee = pylondataprocessing.RectangleF(1.2, 3.4, 5.6, 7.8, 9.0) 53 | self.assertEqual(str(testee), "Center: (X = 1.2; Y = 3.4); Width = 5.6; Height = 7.8; Rotation = 9.0 rad") 54 | 55 | if __name__ == "__main__": 56 | unittest.main() 57 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/regionentry_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class RegionEntryTestSuite(PylonDataProcessingTestCase): 6 | def test_init_RegionEntryRLE32(self): 7 | testee1 = pylondataprocessing.RegionEntryRLE32() 8 | self.assertEqual(testee1.StartX, 0.0) 9 | self.assertEqual(testee1.EndX, 0.0) 10 | self.assertEqual(testee1.Y, 0.0) 11 | testee2 = pylondataprocessing.RegionEntryRLE32(10, 30, 40) 12 | self.assertEqual(testee2.StartX, 10) 13 | self.assertEqual(testee2.EndX, 30) 14 | self.assertEqual(testee2.Y, 40) 15 | 16 | def test_str(self): 17 | testee = pylondataprocessing.RegionEntryRLE32(10, 30, 40) 18 | self.assertEqual(str(testee), "StartX = 10; EndX = 30; Y = 40") 19 | 20 | if __name__ == "__main__": 21 | unittest.main() 22 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/regiontype_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | from pypylon import genicam 4 | import unittest 5 | 6 | class RegionTypeTestSuite(PylonDataProcessingTestCase): 7 | def test_presence(self): 8 | self.assertEqual(pylondataprocessing.RegionType_Undefined, -1) 9 | self.assertEqual(pylondataprocessing.RegionType_RLE32, 6291457) 10 | 11 | def test_IsValid(self): 12 | self.assertTrue(pylondataprocessing.IsValidRegionType(pylondataprocessing.RegionType_RLE32)) 13 | self.assertFalse(pylondataprocessing.IsValidRegionType(pylondataprocessing.RegionType_Undefined)) 14 | 15 | def test_BitPerRegionElement(self): 16 | self.assertEqual(pylondataprocessing.BitPerRegionElement(pylondataprocessing.RegionType_RLE32), 3 * 32) 17 | try: 18 | pylondataprocessing.BitPerRegionElement(pylondataprocessing.RegionType_Undefined) 19 | except genicam.InvalidArgumentException as e: 20 | self.assertTrue(str(e).startswith("Invalid region type passed.")) 21 | 22 | def test_ComputeRegionSize(self): 23 | self.assertEqual(pylondataprocessing.ComputeRegionSize(pylondataprocessing.RegionType_RLE32, 10), 3 * 4 * 10) 24 | try: 25 | pylondataprocessing.ComputeRegionSize(pylondataprocessing.RegionType_Undefined, 10) 26 | except genicam.InvalidArgumentException as e: 27 | self.assertTrue(str(e).startswith("Invalid region type passed.")) 28 | 29 | if __name__ == "__main__": 30 | unittest.main() 31 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/transformationdata_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class TransformationDataTestSuite(PylonDataProcessingTestCase): 6 | def checkAllZero(self, testee): 7 | for rowIndex in range(testee.RowCount): 8 | for columnIndex in range(testee.ColumnCount): 9 | self.assertEqual(testee.GetEntry(columnIndex, rowIndex), 0.0) 10 | 11 | def test_init(self): 12 | testee1 = pylondataprocessing.TransformationData() 13 | self.assertEqual(testee1.GetColumnCount(), 0) 14 | self.assertEqual(testee1.GetRowCount(), 0) 15 | self.assertEqual(testee1.ColumnCount, 0) 16 | self.assertEqual(testee1.RowCount, 0) 17 | self.assertEqual(testee1.IsValid(), False) 18 | testee2 = pylondataprocessing.TransformationData(3,2) 19 | self.assertEqual(testee2.GetColumnCount(), 3) 20 | self.assertEqual(testee2.GetRowCount(), 2) 21 | self.assertEqual(testee2.ColumnCount, 3) 22 | self.assertEqual(testee2.RowCount, 2) 23 | self.assertEqual(testee2.IsValid(), True) 24 | self.checkAllZero(testee2) 25 | 26 | def test_reset_and_set(self): 27 | testee = pylondataprocessing.TransformationData() 28 | testee.Reset(3,2) 29 | self.assertEqual(testee.GetColumnCount(), 3) 30 | self.assertEqual(testee.GetRowCount(), 2) 31 | self.assertEqual(testee.ColumnCount, 3) 32 | self.assertEqual(testee.RowCount, 2) 33 | self.assertEqual(testee.IsValid(), True) 34 | self.checkAllZero(testee) 35 | testee.SetEntry(0,0,1.2) 36 | self.assertEqual(testee.GetEntry(0, 0), 1.2) 37 | testee.Reset(4,3) 38 | self.assertEqual(testee.GetColumnCount(), 4) 39 | self.assertEqual(testee.GetRowCount(), 3) 40 | self.assertEqual(testee.ColumnCount, 4) 41 | self.assertEqual(testee.RowCount, 3) 42 | self.assertEqual(testee.IsValid(), True) 43 | self.checkAllZero(testee) 44 | testValue = 1.1 45 | for rowIndex in range(testee.RowCount): 46 | for columnIndex in range(testee.ColumnCount): 47 | testee.SetEntry(columnIndex, rowIndex, testValue) 48 | testValue += 1.0 49 | self.assertEqual(testValue, 13.1) 50 | testValue = 1.1 51 | for rowIndex in range(testee.RowCount): 52 | for columnIndex in range(testee.ColumnCount): 53 | self.assertEqual(testee.GetEntry(columnIndex, rowIndex), testValue) 54 | testValue += 1.0 55 | self.assertEqual(testValue, 13.1) 56 | 57 | 58 | 59 | def test_str(self): 60 | testee = pylondataprocessing.TransformationData(3,2) 61 | testValue = 1.1 62 | for rowIndex in range(testee.RowCount): 63 | for columnIndex in range(testee.ColumnCount): 64 | testee.SetEntry(columnIndex, rowIndex, testValue) 65 | testValue += 1.0 66 | self.assertEqual(testValue, 7.1) 67 | self.assertEqual(str(testee), "1.1, 2.1, 3.1\n4.1, 5.1, 6.1") 68 | 69 | if __name__ == "__main__": 70 | unittest.main() 71 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/update_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | from pypylon import genicam 4 | import unittest 5 | 6 | class UpdateTestSuite(PylonDataProcessingTestCase): 7 | def test_init(self): 8 | testee1 = pylondataprocessing.Update() 9 | testee2 = pylondataprocessing.Update() 10 | testee3 = pylondataprocessing.Update(testee2) 11 | self.assertFalse(testee1.IsValid()) 12 | self.assertEqual(testee1.GetNumPrecedingUpdates(), 0) 13 | self.assertFalse(testee1.HasBeenTriggeredBy(testee2)) 14 | #invalid updates, you can get valid updates only from a running recipe. 15 | self.assertTrue(testee1 == testee2) 16 | self.assertFalse(testee1 != testee2) 17 | self.assertFalse(testee1 < testee2) 18 | try: 19 | testee1.GetPrecedingUpdate(0) 20 | except genicam.RuntimeException as e: 21 | self.assertTrue(str(e).startswith("This update is invalid. Cannot get preceding updates.")) 22 | 23 | if __name__ == "__main__": 24 | unittest.main() 25 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/variantcontainer_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | #note the variant container is converted to a python dictionary when using a Recipe 6 | #TODO: solve SWIG problems and remove the VariantContainer 7 | class VariantContainerTestSuite(PylonDataProcessingTestCase): 8 | def test_init(self): 9 | testee = pylondataprocessing.VariantContainer() 10 | 11 | if __name__ == "__main__": 12 | unittest.main() 13 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/variantcontainertest_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | #note the variant container is converted to a python dictionary when using a Recipe 6 | #TODO: solve SWIG problems and remove the VariantContainer 7 | class VariantContainerTestSuite(PylonDataProcessingTestCase): 8 | def test_init(self): 9 | testee = pylondataprocessing.VariantContainer() 10 | 11 | if __name__ == "__main__": 12 | unittest.main() 13 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/variantcontainertype.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class VariantContainerTypeTestSuite(PylonDataProcessingTestCase): 6 | def test_presence(self): 7 | self.assertEqual(pylondataprocessing.VariantContainerType_None, 0) 8 | self.assertEqual(pylondataprocessing.VariantContainerType_Array, 1) 9 | self.assertEqual(pylondataprocessing.VariantContainerType_Unsupported, 2) 10 | 11 | if __name__ == "__main__": 12 | unittest.main() 13 | -------------------------------------------------------------------------------- /tests/pylondataprocessing_tests/variantdatatype_test.py: -------------------------------------------------------------------------------- 1 | from pylondataprocessingtestcase import PylonDataProcessingTestCase 2 | from pypylon import pylondataprocessing 3 | import unittest 4 | 5 | class VariantDataTypeTestSuite(PylonDataProcessingTestCase): 6 | def test_presence(self): 7 | self.assertEqual(pylondataprocessing.VariantDataType_Int64, 1) 8 | self.assertEqual(pylondataprocessing.VariantDataType_UInt64, 2) 9 | self.assertEqual(pylondataprocessing.VariantDataType_Boolean, 3) 10 | self.assertEqual(pylondataprocessing.VariantDataType_String, 4) 11 | self.assertEqual(pylondataprocessing.VariantDataType_Float, 5) 12 | self.assertEqual(pylondataprocessing.VariantDataType_PylonImage, 6) 13 | self.assertEqual(pylondataprocessing.VariantDataType_Region, 8) 14 | self.assertEqual(pylondataprocessing.VariantDataType_TransformationData, 9) 15 | self.assertEqual(pylondataprocessing.VariantDataType_Composite, 7) 16 | self.assertEqual(pylondataprocessing.VariantDataType_PointF2D, 10) 17 | self.assertEqual(pylondataprocessing.VariantDataType_LineF2D, 11) 18 | self.assertEqual(pylondataprocessing.VariantDataType_RectangleF, 12) 19 | self.assertEqual(pylondataprocessing.VariantDataType_CircleF, 13) 20 | self.assertEqual(pylondataprocessing.VariantDataType_EllipseF, 14) 21 | self.assertEqual(pylondataprocessing.VariantDataType_None, 0) 22 | 23 | if __name__ == "__main__": 24 | unittest.main() 25 | -------------------------------------------------------------------------------- /tests/testCoverage.bat: -------------------------------------------------------------------------------- 1 | del /F /S htmlcov 2 | del .coverage 3 | del pylon\gigE\.coverage 4 | del pylon\emulated\.coverage 5 | del pylon\usb\.coverage 6 | del ..\samples\.coverage 7 | 8 | for %%f in (genicam\*test.py) do ( 9 | "C:\Program Files\Python35\Scripts\coverage.exe" run -a -L --source=pypylon --branch %%f 10 | ) 11 | cd pylon\emulated\ 12 | for %%f in (*test.py) do ( 13 | "C:\Program Files\Python35\Scripts\coverage.exe" run -a -L --source=pypylon --branch -m unittest %%f 14 | ) 15 | cd ..\gigE\ 16 | for %%f in (*test.py) do ( 17 | "C:\Program Files\Python35\Scripts\coverage.exe" run -a -L --source=pypylon --branch -m unittest %%f 18 | ) 19 | cd ..\usb\ 20 | for %%f in (pylon\usb\*test.py) do ( 21 | "C:\Program Files\Python35\Scripts\coverage.exe" run -a -L --source=pypylon --branch -m unittest %%f 22 | ) 23 | cd ..\..\..\samples 24 | for %%f in (*.py) do ( 25 | "C:\Program Files\Python35\Scripts\coverage.exe" run -a -L --source=pypylon --branch %%f 26 | ) 27 | cd ..\tests\ 28 | "C:\Program Files\Python35\Scripts\coverage.exe" combine -a .coverage pylon\gigE\.coverage 29 | "C:\Program Files\Python35\Scripts\coverage.exe" combine -a .coverage pylon\usb\.coverage 30 | "C:\Program Files\Python35\Scripts\coverage.exe" combine -a .coverage pylon\emulated\.coverage 31 | "C:\Program Files\Python35\Scripts\coverage.exe" combine -a .coverage ..\samples\.coverage 32 | "C:\Program Files\Python35\Scripts\coverage.exe" html 33 | pause --------------------------------------------------------------------------------