C++ 프로그래머 가이드#
pylon을 처음 사용하시는 경우, Basler에서는 먼저 ‘pylon C++ 프로그래머 가이드’의 ‘시작하기’ 섹션을 읽어보며 pylon C++ API에 익숙해지실 것을 권장합니다.
정보
이 항목의 모든 정보는 모든 blaze 및 Smart blaze 카메라 모델에 적용됩니다. 간결함을 위해 모든 모델을 지칭할 때 "blaze"를 사용합니다.
C++ 프로그래밍 예제#
To open the folder containing the programming samples for blaze cameras, press the Win key, go to the Basler folder, and choose blaze Samples. A File Explorer window opens. The C++ programming samples are located in the cpp folder.
The C++ samples are located in the /opt/pylon/share/pylon/Samples/blaze/cpp folder.
샘플 빌드 전제 조건#
- Visual Studio 2017 or above
- Optional: OpenCV library
- Optional: Point Cloud Library (PCL)
- Optional: Boost libraries
- CMake 3.3 or above
- Optional: Aravis
On an Ubuntu system, you can install the prerequisites by issuing the following command:
Info
There is no Debian package available for the Aravis library. Aravis must be built from sources instead.
샘플을 만드는 방법#
정보
샘플을 빌드하기 전에, 샘플이 들어 있는 폴더를 읽기 및 쓰기 권한이 있는 원하는 위치로 복사하십시오.
CMake는 C++ 샘플을 빌드하기 위한 빌드 시스템으로 사용됩니다.
Windows#
- Start Visual Studio.
- On the start page, choose the Open Folder or Open a local folder option, and navigate to the folder you copied the samples to.
- Open the cpp subfolder and click the Select Folder button.
Visual Studio runs CMake in the background. It will take a moment until you can build the samples by selecting Build All in the Build menu.
When you don't want to use Visual Studio's CMake integration, you can use the cmake-gui tool to generate Visual Studio solution and project files that you can open with Visual Studio.
If there is no CMake >= 3.3 installed, download a CMake Windows installer from the CMake website. Launch the .msi installer and follow the instructions.
To generate Visual Studio project and solution files for the blaze samples:
- Start cmake-gui.
- Click the Browse Source… button, and navigate to the folder you copied the samples to.
- Open the cpp folder by clicking the Select folder button.
- Specify a folder where the binaries will be built by clicking the Browse Build… button and choosing or creating a folder of your choice.
Basler advises against choosing the root folder of the source tree, i.e., the folder this document is located in. Common practice is to create a subfolder (e.g., namedbuild). - Click the Configure button.
A dialog opens. - Choose the desired Visual Studio version and platform.
Make sure that the selected platform (x86 or x64) matches the architecture that the OpenCV and PCL libraries are built for. - Click the Finish button to close the dialog.
The configuration procedure starts. - Once the configuration procedure has succeeded, click the Generate button to create the Visual Studio project and solution files.
The files will be generated in the build folder that you specified earlier. - Navigate to that build folder and open the .sln file.
Now, you can build the samples by selecting Build All in the Build menu.
샘플을 빌드하거나 실행하는 데 문제가 발생하면 ‘문제 해결’ 항목을 참조하십시오.
Linux#
샘플을 빌드하려면 셸을 열고, 샘플을 복사한 폴더로 이동하십시오. 그런 다음 cpp 하위 폴더로 이동한 후 다음 명령을 실행하십시오:
CMake가 pylon SDK를 찾지 못하는 경우, pylon SDK와 pylon Supplementary Package for blaze 가 올바르게 설치되었는지 확인하십시오.
/opt/pylon 이외의 위치에 소프트웨어를 설치한 경우, PYLON_ROOT 환경 변수가 pylon 및 보조 패키지를 설치한 폴더로 설정되어 있는지 확인하십시오.
예:
CMake가 OpenCV 라이브러리나 PCL을 찾지 못하는 경우, OpenCV 라이브러리와 PCL용 개발 패키지가 설치되어 있는지 확인하십시오.
샘플을 빌드하거나 실행하는 데 문제가 발생하면 ‘문제 해결’ 항목을 참조하십시오.
OpenCV 라이브러리 설치#
Windows#
GitHub에서 OpenCV를 다운로드할 수 있습니다.
사용하려는 Visual Studio 버전과 호환되는 OpenCV 라이브러리 버전을 다운로드해야 합니다. 적합한 사전 컴파일된 버전이 없는 경우, 애플리케이션 빌드에 사용할 Visual Studio 버전을 사용하여 소스 코드로부터 OpenCV를 직접 빌드해야 합니다.
CMake가 OpenCV를 찾지 못하면, OpenCV_DIR 변수를 OpenCVConfig.cmake 파일이 있는 폴더로 설정하십시오.
예제
- Open the CMakeSettings.json file (CMake -> Change CMake Settings -> blazeCppSamples).
- Add the following to the cmakeCommandArgs list:
-DOpenCV_DIR=\"C:\\Program Files\\OpenCV\\build\\x64\\vc16\\lib\"
- Open the CMake Settings dialog (Project -> CMakeSettings for blazeCppSamples).
- Enter the following in the CMake command arguments field:
-DOpenCV_DIR="C:\Program Files\OpenCV\build\x64\vc16\lib" - Press Ctrl S to save the changes.


Before you can access the OpenCV_DIR in the CMake GUI, make sure that the Grouped check box is deselected in the CMake GUI.
PATH 환경 변수에 OpenCV 추가하기#
OpenCV를 추가해야 합니다. bin 디렉터리를 PATH 환경 변수에 추가합니다.
- 다음 버튼을 누르세요 Win 키를 누르십시오.
- "환경"이라고 입력하세요.
- 계정의 환경 변수 편집을 클릭하세요.
- '환경 변수…' 버튼을 클릭합니다.
- '사용자 변수 ' 영역에서 'Path'를 선택합니다.
- ‘편집’ 버튼을 클릭하세요.
- '새로 만들기'를 클릭합니다.
- OpenCV가 설치된 경로를 입력하세요(예: C:\Program Files\OpenCV\build\x64\vc16\bin).
- OK를 클릭합니다.
Linux#
CMake가 OpenCV 라이브러리를 찾지 못하면, libopencv 개발 패키지를 설치하거나 소스 코드에서 OpenCV 라이브러리를 직접 빌드해야 합니다.
Ubuntu 시스템에서는 다음 명령을 실행하여 libopencv 개발 패키지를 설치할 수 있습니다:
소스 코드에서 OpenCV 라이브러리를 빌드하여 비표준 위치에 설치할 경우, OpenCV_DIR CMake 변수를 사용하여 다음의 위치를 지정할 수 있습니다. OpenCVConfig.cmake 파일이 있는 위치.
예:
포인트 클라우드 라이브러리 설치#
Windows#
GitHub에서 ‘ Windows ’용 PCL 올인원 설치 프로그램을 다운로드할 수 있습니다.
사용하려는 Visual Studio 버전과 호환되는 PCL 버전을 다운로드해야 합니다.
CMake가 PCL을 찾지 못하면 다음을 설정하십시오. PCL_DIR 변수를 다음을 포함하는 폴더로 PCLConfig.cmake 파일.
예제
- Open the CMakeSettings.json file (CMake -> Change CMake Settings -> blazeCppSamples)
- Add the following to the
cmakeCommandArgslist:-DPCL_DIR=\"C:\\Program Files\\PCL 1.9.1\\cmake\"
- Open the CMake Settings dialog (Project -> CMakeSettings for blazeCppSamples).
- Enter the following in the CMake command arguments field:
-DPCL_DIR="C:\Program Files\PCL 1.12.1\cmake" - Press Ctrl S to save the changes.
- Open the CMake Settings dialog (Project -> CMakeSettings for blazeCppSamples).
- Enter the following in the CMake command arguments field:
-DPCL_DIR="C:\Program Files\PCL 1.14.0\cmake" - Press Ctrl S to save the changes.

Before you can access the PCL_DIR in the CMake GUI, make sure that the Grouped check box is deselected in the CMake GUI.
PCL 올인원 설치 프로그램을 사용하여 PCL을 설치하면, 설치 프로그램이 PCL 추가 작업을 자동으로 처리합니다. bin 디렉터리를 PATH 환경 변수. 다른 설치 방법을 사용하는 경우, 다음을 추가해야 합니다. bin 디렉터리를 PATH 환경 변수를 직접 설정하십시오.
PCL 올인원 설치 프로그램은 다음을 설치합니다. OpenNI2.dll ~로 %ProgramFiles%\OpenNI2\Redist 폴더. 런타임 시에는 ‘ DLL ’가 필요합니다. 이 폴더를 다음 중 한 곳에 추가하십시오. PATH 환경 변수를 설정하거나, 다음을 복사하여 OpenNI2.dll PCL 바이너리가 있는 폴더로, 예를 들어, %ProgamFiles%\PCL 1.13.0\bin.
Linux#
CMake가 PCL 라이브러리를 찾지 못하면, libpcl 개발 패키지를 설치하거나 소스 코드에서 PCL 라이브러리를 직접 빌드해야 합니다.
Ubuntu 시스템에서는 다음 명령을 실행하여 libpcl 개발 패키지를 설치할 수 있습니다:
소스 코드에서 PCL을 빌드하여 비표준 위치에 설치할 경우, PCL_DIR CMake 변수를 사용하여 다음의 위치를 지정할 수 있습니다. PCLConfig.cmake 파일이 있는 위치입니다.
예:
참고
시스템에 설치된 PCL(Point Cloud Library) 및 VTK 라이브러리의 버전에 따라 Point Cloud Library(PCL)를 사용하는 샘플이 중단될 수 있습니다. 이 중단 현상은 PCL이 3D 시각화를 위해 사용하는 VTK 라이브러리의 버그로 인해 발생합니다.
출처: https://github.com/PointCloudLibrary/pcl/issues/5237
해결 방법: PCL 1.13.1에는 VTK 버그를 우회하는 수정 사항이 포함되어 있습니다.
PCL을 1.13.1 이상으로 업데이트하십시오. 필요한 경우, Linux 배포판에서 제공하는 PCL 라이브러리를 제거하고 소스 코드( GitHub에서 다운로드 가능)를 사용하여 PCL 1.13.1 이상 버전을 빌드하십시오.
Boost 라이브러리 설치#
Windows#
소스 코드를 통해 Point Cloud Library(PCL)를 빌드했거나, 위에서 설명한 대로 올인원 설치 프로그램을 사용하여 설치한 경우, PCL 빌드에 사용된 Boost 라이브러리가 blaze 샘플을 빌드할 때도 자동으로 사용됩니다.
사용 가능한 PCL 라이브러리가 없지만 Boost 라이브러리가 필요한 Blaze 샘플을 빌드하려는 경우, 소스 코드에서 Boost 라이브러리를 직접 빌드하거나, 예를 들어 sourceforge.net에서 다운로드할 수 있는 미리 빌드된 바이너리를 사용하여 설치해야 합니다. 사용 중인 Visual Studio 버전과 애플리케이션을 빌드할 아키텍처에 적합한 설치 프로그램을 다운로드하십시오.
CMake가 설치된 Boost 라이브러리를 감지하지 못하는 경우, 다음을 설정해야 합니다. Boost_DIR CMake 변수. 이 변수는 다음이 포함된 디렉터리를 가리켜야 합니다. BoostConfig.cmake 파일.
예제
- Open the CMakeSettings.json file (CMake -> Change CMake Settings -> blazeCppSamples).
- Add the following to the
cmakeCommandArgslist:-DBoost_DIR=\"C:\\local\\boost_1_84_0\\lib64-msvc-14.1\\cmake\\Boost-1.84.0\"
- Open the CMake Settings dialog (Project -> CMakeSettings for blazeCppSamples).
- Enter the following in the CMake command arguments field:
-DBoost_DIR="C:\local\boost_1_84_0\lib64-msvc-14.2\cmake\Boost-1.84.0" - Press Ctrl S to save the changes.
- Open the CMake Settings dialog (Project -> CMakeSettings for blazeCppSamples).
- Enter the following in the CMake command arguments field:
-DBoost_DIR="C:\local\boost_1_84_0\lib64-msvc-14.3\cmake\Boost-1.84.0" - Press Ctrl S to save the changes.

Before you can access the Boost_DIR in the CMake GUI, make sure that the Advanced check box is selected and the Grouped check box is deselected in the CMake GUI.
Linux#
CMake가 Boost 라이브러리를 찾지 못하면, libboost 개발 패키지를 설치하거나 소스 코드를 통해 Boost 라이브러리를 빌드해야 합니다.
Ubuntu 시스템에서는 다음 명령을 실행하여 libboost 개발 패키지를 설치할 수 있습니다:
샘플 목록#
- FirstSample: Blaze 카메라 작동 방법에 대한 개요를 제공하며, 3D 포인트 클라우드 데이터를 추출하는 방법에 중점을 둡니다. pylon을 사용하여 그랩 루프를 구현하는 다양한 방법에 대해 자세히 알아보려면 다음 pylon C++ 샘플 모음의 예제를 참조하십시오:
- Grab_전략
- Grab_UsingBufferFactory
- Grab_UsingGrabLoopThread
- ParametrizeCamera: 카메라 매개변수에 접근하는 방법을 설명합니다.
- DeviceRemovalHandling: 장치 제거를 감지하고 처리하는 방법을 설명합니다.
- GrabDepthMap: 그레이스케일 이미지로 표현된 3D 정보를 제공하는 깊이 맵을 추출하고 해석하는 방법을 설명합니다.
- ConvertPointCloud2DepthMap: 3D 포인트 클라우드와 깊이 맵을 동시에 처리하려면, 3D 포인트 클라우드에서 깊이 맵을 추출하는 방법을 보여주는 예제를 참조하십시오. 이 예제에서는 깊이 맵에 무지개 색상 매핑을 적용하는 방법도 설명합니다.
- ShowPointCloud_PCL: Point Cloud Library(PCL)를 사용하여 Basler blaze 카메라로 캡처한 포인트 클라우드를 시각화하는 방법을 보여줍니다.
- ConvertAndFilter_PCL: ShowPointCloud와 유사합니다. 3D 포인트 클라우드에 PCL 필터를 적용하는 방법을 보여줍니다.
- SavePointCloud: GrabSingleImage 편의 메서드와 포인트 클라우드를 .pcd 텍스트 파일로 저장하는 방법을 설명합니다.
- SaveAndLoadPointCloudUsingPCL: PCL을 사용하여 포인트 클라우드를 파일에 더 효율적으로 저장하는 방법을 보여줍니다. 또한 이 예제에서는 파일에서 포인트 클라우드를 불러오는 방법도 보여줍니다.
- FeatureDumper: 모든 카메라 매개변수와 해당 속성을 나열합니다. GenApi 사용법에 대한 심화 예제 역할을 합니다.
- 왜곡 보정: 사용자 정의 보정 데이터를 사용하기 위해 왜곡 보정 기능을 비활성화하는 방법을 설명합니다.
- 외부 변환: 포인트 클라우드에서 주 평면을 탐지하는 방법과, 외부 변환을 계산하여 카메라에 전달하는 방법을 설명합니다.
- MultiCam/ColorAndDepth/ColorAndDepthPtp: Basler blaze 카메라와 Basler GigE 컬러 카메라 모두에서 이미지를 캡처하고, 이미지 및 깊이 데이터에 접근하는 방법을 보여줍니다. 이 카메라들은 ‘ PTP ’ 및 ‘ Synchronous Free Run ’ 기능을 사용하여 동기화됩니다.
- MultiCam/ColorAndDepth/Calibration: Basler GigE 컬러 카메라와 Basler blaze 카메라로 구성된 시스템의 보정 방법을 설명합니다.
- MultiCam/ColorAndDepth/ColorAndDepthFusion: Basler GigE 컬러 카메라와 Basler blaze에서 얻은 데이터를 어떻게 융합하여 컬러 포인트 클라우드를 생성할 수 있는지 보여줍니다.
- MultiCam/ColorAndDepth/RgbdCamera: ~와 유사한 색상 및 깊이 융합, 이 예제는 Basler Blaze 및 Basler GigE 컬러 카메라의 데이터를 어떻게 결합하여 컬러 포인트 클라우드를 생성할 수 있는지 보여줍니다. 이 예제는
RgbdCamera2D 컬러 카메라와 블레이즈를 결합하고, 두 카메라를 하나의 RGB-D 카메라처럼 연동할 수 있게 해주는 클래스입니다. 결합된 두 카메라는 ‘ PTP (IEEE1588)’ 및 ‘ Synchronous Free Run ’ 기능을 사용하여 동기식으로 트리거됩니다. 이 클래스의 소스 코드는RgbdCamera클래스는 동일한 폴더에 있습니다. 자신의 애플리케이션에서 RgbdCamera 클래스를 사용하려면 RgbdCamera.h 및 RgbdCamera.cpp 파일을 프로젝트에 추가하십시오. 또한 Multicam/MultiCamHelper 폴더에 있는 .h 및 .cpp 파일도 함께 추가해야 합니다. - MultiCam/DepthFusion/보정: 여러 대의 Basler blaze 카메라로 구성된 시스템을 보정하는 방법을 설명합니다.
- MultiCam/DepthFusion/DepthFusion: 여러 대의 카메라에서 얻은 깊이 데이터를 병합하여 융합된 포인트 클라우드를 표시하는 방법을 설명합니다.
- MultiCam/MultiChannel/MultiChannelFreeRun: 여러 대의 블레이즈 카메라의 광원이 서로 간섭하지 않도록 동시에 작동시키는 방법을 보여줍니다. 카메라들은 프리 런 모드로 작동합니다.
- MultiCam/MultiChannel/MultiChannelSwTrigger: 여러 대의 블레이즈 카메라를 각 카메라의 광원이 서로 간섭하지 않도록 동시에 작동시키는 방법을 설명합니다. 이 카메라들은 소프트웨어 트리거를 사용하여 작동됩니다.
- MultiCam/SynchronousFreeRun/SynchronousFreeRun: ‘ PTP ’ 클럭 동기화 및 ‘ Synchronous Free Run ’ 기능을 활용하여 여러 대의 블레이즈 카메라가 서로 광원의 간섭을 일으키지 않고 동시에 작동하도록 하는 방법을 보여줍니다.
- MultiCam/MultiCamHelper: 이 라이브러리는 네트워크 시간 동기화( PTP , IEEE1588)를 사용하여 여러 대의 카메라 시계를 쉽게 동기화하고, 여러 대의 카메라에서 이미지를 동기적으로 캡처할 수 있도록 해주는 편의 클래스를 제공합니다. 이 라이브러리는 ‘ Synchronous Free Run ’ 기능을 사용하여 여러 대의 카메라에서 이미지를 획득하는 모든 샘플에서 사용됩니다. 프로젝트에 이 라이브러리를 추가하려면, 이 폴더에 있는 .h 및 .cpp 파일을 프로젝트에 포함시키기만 하면 됩니다.
- Aravis/BasicSample: (Linux 전용) 오픈소스 Aravis 라이브러리를 사용하여 블레이즈 카메라를 구성하고 데이터를 수집하는 방법을 보여줍니다.
- Aravis/PointCloudSample: (Linux 전용) Aravis 라이브러리를 사용하여 수집한 데이터로부터 3D 좌표(즉, 포인트 클라우드)를 계산하는 방법을 보여줍니다. 또한 이 예제는 OpenCV를 사용하여 포인트 클라우드를 저장하고 시각화하는 방법도 보여줍니다.
애플리케이션 구축 방법#
Windows#
Visual Studio 솔루션 사용#
Refer to the Common Settings for Building Applications with pylon section of the pylon C++ Programmer's Guide to learn how to set up a project for building applications using pylon.
Refer to the Common Settings for Building Applications with pylon section of the pylon C++ Programmer's Guide to learn how to set up a project for building applications using pylon.
CMake 사용법#
pylon Supplementary Package for blaze 에는 다음이 포함되어 있습니다. Findpylon.cmake pylon의 설치 위치와 pylon Supplementary Package for blaze 을 확인하는 데 사용되는 모듈입니다. find 모듈은 다음을 내보냅니다. pylon::pylon CMake 타깃. 이 타깃을 다음의 인수로 전달하십시오. target_link_libraries, 그러면 CMake가 포함 경로, 라이브러리 경로 등을 자동으로 설정해 줍니다.
기본적인 CMakeLists.txt CMake 파일은 다음과 같이 보일 수 있습니다:
project (hello)
# Locate the CMake find module for pylon ...
# for Unix system. All other OS PYLON_ROOT will be empty
list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_ROOT})
# for Windows system. All other OS PYLON_DEV_DIR will be empty
list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_DEV_DIR})
find_package(pylon 7.1 REQUIRED)
add_executable(hello helloworld.cpp)
target_link_libraries(hello pylon::pylon)
project (hello)
# Locate the CMake find module for pylon ...
find_path(pylon_cmake Findpylon.cmake
HINTS "$ENV{PYLON_DEV_DIR}/lib/cmake"
"$ENV{ProgramFiles}/Basler/pylon 7/Development/lib/cmake"
"$ENV{ProgramFiles}/Basler/pylon 6/Development/lib/cmake"
)
# ... and extend the CMake module path accordingly.
list(APPEND CMAKE_MODULE_PATH ${pylon_cmake})
# Locate pylon.
find_package(pylon 6.2 REQUIRED)
add_executable(hello helloworld.cpp)
target_link_libraries(hello pylon::pylon)
Linux#
CMake 사용법#
project (hello)
# Locate the CMake find module for pylon ...
# for Unix system. All other OS PYLON_ROOT will be empty
list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_ROOT})
# for Windows system. All other OS PYLON_DEV_DIR will be empty
list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_DEV_DIR})
find_package(pylon 7.1 REQUIRED)
add_executable(hello helloworld.cpp)
target_link_libraries(hello pylon::pylon)
project (hello)
# Locate the CMake find module for pylon ...
find_path(pylon_cmake Findpylon.cmake
HINTS "/opt/pylon/lib/cmake"
)
# ... and extend the CMake module path accordingly.
list(APPEND CMAKE_MODULE_PATH ${pylon_cmake})
# Locate pylon.
find_package(pylon 6.2 REQUIRED)
add_executable(hello helloworld.cpp)
target_link_libraries(hello pylon::pylon)
Make 파일 사용#
pylon을 사용하여 애플리케이션을 빌드할 때 컴파일러 및 링커 설정을 조정하는 방법은 pylon C++ 프로그래머 가이드의 “pylon을 사용한 애플리케이션 빌드를 위한 공통 설정” 섹션을 참조하십시오.
블레이즈 카메라를 위한 즉석 카메라 강좌#
pylon은 카메라 장치에 접근하기 위한 다양한 유형의 클래스를 제공합니다. 저수준의 IPylon 기기들 중에는 소위 Instant Camera 카메라를 위한 편리한 고수준 API를 제공하는 클래스들.
The Pylon::CInstantCamera 이 클래스는 블레이즈(blaze) 카메라를 포함한 모든 바슬러(Basler) 카메라에 대한 범용적인 접근 기능을 제공합니다.
The Pylon::CBaslerUniversalInstantCamera 클래스는 제네릭을 상속합니다. Pylon::CInstantCamera IntelliSense/코드 완성 기능을 통해 카메라 매개변수를 쉽게 설정하고 가져올 수 있도록 해주는 매개변수 액세서 객체 클래스.
The Pylon::CBaslerUniversalInstantCamera 이 클래스는 모든 Blaze 카메라 기능에 대한 매개변수 액세서리를 제공하지는 않습니다. 따라서 ` pylon Supplementary Package for blaze `에는 Pylon::CBlazeInstantCamera 클래스. Basler는 대신 Basler blaze 카메라와 함께 해당 클래스를 사용할 것을 권장합니다.
만약 다음을 선택하신다면 CBaslerUniversalInstantCamera ... 대신 class CBlazeInstantCamera 클래스에서도 블레이즈 카메라가 제공하는 모든 카메라 매개변수를 설정하고 가져올 수 있습니다. 만약 해당 클래스에서 액세서 객체를 제공하지 않는다면, CBaslerUniversalInstantCamera 클래스에서는 소위 제네릭 매개변수 접근 에서 설명한 대로 매개변수의 이름을 사용하여 매개변수에 접근하기 위해 일반 매개변수 액세스 섹션 pylon C++ 프로그래머 가이드.
예:
using namespace Pylon;
GenApi::INodeMap& nodemap = camera.GetNodeMap();
CIntegerParameter filterStrength(nodemap, "FilterStrength" );
std::cout << "Filter strength: " << filterStrength.GetValue() << std::endl;
blaze 카메라 켜기 및 접속하기#
블레이즈 카메라 객체를 생성하고 여는 데는 세 단계가 필요합니다:
- 접근하려는 카메라에 대한 카메라 객체를 생성합니다.
일반적으로 다음의 인스턴스를 생성해야 합니다.Pylon::CBlazeInstantCamera클래스. - 화재 관련 정보를 등록하십시오.
Pylon::CBlazeDefaultConfiguration기본 구성을 적용하는 구성 이벤트 핸들러.
다음 문서를 참조하십시오. 카메라 구성 핸들러 등록 화재 구성 이벤트 핸들러 클래스에 대한 자세한 내용은 해당 섹션을 참조하십시오. - 애플리케이션에서
Open()카메라 장치와 연결을 설정하는 방법.
다음 예시는 이 세 단계를 보여줍니다:
#include <pylon/PylonIncludes.h>
using namespace Pylon;
// ....
// Before using any pylon methods, the pylon runtime must be initialized.
PylonInitialize();
try {
// 1: Create a camera object for the first available blaze camera.
CBlazeInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice(
CDeviceInfo().SetDeviceClass(BaslerGenTlBlazeDeviceClass))
);
// 2. Register the default configuration.
camera.RegisterConfiguration(
new CBlazeDefaultConfiguration,
RegistrationMode_ReplaceAll,
Cleanup_Delete);
// 3. Open the camera, i.e., establish a connection to the camera device.
camera.Open();
// Use the camera.
std::cout << "Connected to camera "
<< camera.GetDeviceInfo().GetFriendlyName() << std::endl;
// .....
// Close the connection.
camera.Close();
} catch (const GenICam::GenericException& e) {
std::cerr << "Exception occurred: " << std::endl
<< e.GetDescription() << std::endl;
}
// Releases all pylon resources.
PylonTerminate();
오류가 발생할 경우, 다음에서 상속받은 예외는 GenICam::GenericException 던져진다.
일반적인 오류 상황:
- 화재 감지 카메라가 발견되지 않았습니다: The
CreateFirstDevice()함수가 예외를 발생시킵니다. - 카메라를 열 수 없는 경우(예: Blaze Viewer와 같은 다른 애플리케이션에서 이미 카메라가 열려 있는 경우):
Open()이 메서드는 예외를 발생시킵니다.
다음 소절에서는 카메라 객체를 생성하고 여는 방법에 대한 보다 자세한 정보를 제공합니다.
사용 가능한 첫 번째 blaze 카메라에 대한 카메라 객체 생성하기#
다음 명령을 사용하여 Pylon::CTlFactory::CreateFristDevice() 사용 가능한 첫 번째 카메라에 대한 카메라 객체를 생성하는 메서드입니다. 블레이즈 카메라의 경우, 다음을 방지하기 위해 항상 파일론(pylon) 장치 클래스 식별자를 지정해야 합니다. CreateFirstDevice() 시스템에 연결되거나 네트워크를 통해 접근할 수 있는 다른 유형의 카메라를 위한 카메라 클래스를 생성하는 것:
CBlazeInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice(
CDeviceInfo().SetDeviceClass(BaslerGenTlBlazeDeviceClass)));
);
Blaze 카메라가 발견되지 않으면, 카메라와 사용자의 네트워크 어댑터 IP 구성 설정을 확인하십시오. 네트워크 설정에 대한 자세한 내용은 ‘네트워크 구성’ 항목을 참조하십시오.
특정 블레이즈 카메라용 카메라 객체 생성하기#
'pylon C++ 프로그래머 가이드' 의 '고급 주제' 섹션에 있는 '특정 카메라 생성' 항목에서는 특정 카메라를 선택하는 방법에 대한 정보를 제공합니다.
특정 블레이즈 카메라(예: 일련번호를 지정하는 방식)를 열려면, 블레이즈 카메라용 파이론(pylon) 장치 클래스 식별자를 전달하는 것 외에도 CreateFirstDevice(), 추가 속성을 지정할 수 있습니다.
다음 코드 예제는 일련번호를 사용하여 블레이즈 카메라를 여는 방법을 보여줍니다.
CBlazeInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice(
CDeviceInfo()
.SetDeviceClass(BaslerGenTlBlazeDeviceClass)
.SetSerialNumber("23298299")
));
사용자가 지정한 이름으로 블레이즈 카메라를 열려면 다음 명령어를 사용하십시오:
CBlazeInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice(
CDeviceInfo()
.SetDeviceClass(BaslerGenTlBlazeDeviceClass)
.SetUserDefinedName("MyCamera")));
사용자 정의 이름
다음 방법을 사용하여 카메라에 사용자 정의 이름을 지정할 수 있습니다. DeviceUserID 매개변수. 이 작업은 Blaze Viewer, Pylon( IP Configurator) 또는 pylon API 에서 수행할 수 있습니다:
IP 주소를 사용하여 장치 생성하기
현재는 다음을 사용하여 카메라 IP 주소를 지정할 수 없습니다. CreateFirstDevice() 함수. 그 이유는 현재 Pylon::CDeviceInfo() 이 클래스에는 카메라의 IP 주소에 대한 정보가 전혀 포함되어 있지 않습니다.
특정 IP 주소를 가진 카메라를 생성하거나 열려면, 먼저 모든 카메라를 열거하고, 반환된 목록을 순회하며 각 카메라를 차례로 연 후에야 IP 주소 및 기타 네트워크 관련 정보를 조회할 수 있습니다. 이 절차는 ‘blaze 카메라 열거’ 섹션에 설명되어 있습니다.
원하는 블레이즈 카메라를 찾을 수 없는 경우, 속성에 올바른 값이 설정되어 있는지 확인하고, 카메라 및 네트워크 어댑터의 IP 구성 설정을 점검하십시오. 네트워크 설정에 대한 자세한 내용은 ‘네트워크 구성’ 항목을 참조하십시오.
화재 감지 카메라 열거하기#
다음 코드 예제는 연결된 모든 Blaze 카메라 목록을 가져오는 방법을 보여줍니다. 목록의 각 요소에 대해 카메라를 열고, 일부 카메라 매개변수 값을 출력합니다.
#include <pylon/PylonIncludes.h>
#include <ostream>
using namespace Pylon;
// ....
// Before using any pylon methods, the pylon runtime must be initialized.
PylonInitialize();
// ....
// Enumerate all blaze cameras.
CTlFactory& TlFactory = CTlFactory::GetInstance();
DeviceInfoList_t lstDevices;
DeviceInfoList_t filter;
filter.push_back(CDeviceInfo().SetDeviceClass(BaslerGenTlBlazeDeviceClass));
TlFactory.EnumerateDevices(lstDevices, filter);
if (!lstDevices.empty()) {
DeviceInfoList_t::const_iterator it;
for (it = lstDevices.begin(); it != lstDevices.end(); ++it) {
std::cout << it->GetFullName();
// Open camera, i.e., establish a connection to the camera device.
CBlazeInstantCamera camera(CTlFactory::GetInstance().CreateDevice(*it));
camera.RegisterConfiguration(
new CBlazeDefaultConfiguration,
RegistrationMode_ReplaceAll, Cleanup_Delete);
camera.Open();
// Print out some information.
std::cout << "Connected to camera "
<< camera.GetDeviceInfo().GetFriendlyName() << std::endl;
std::cout << "IP Address: "
<< camera.GevCurrentIPAddress.GetValue() << std::endl;
std::cout << "User-defined name: "
<< camera.DeviceUserID.GetValue() << std::endl;
std::cout << "Serial Number: "
<< camera.DeviceSerialNumber.GetValue() << std::endl;
} // The connection will be closed automatically when leaving the scope here.
else {
std::cerr << "No devices found!" << std::endl;
}
카메라 구성 핸들러 등록#
pylon 인스턴트 카메라 클래스를 사용하면 특정 이벤트 발생 시(예: Open() 메서드가 호출됩니다.
pylon Supplementary Package for blaze 에는 다음이 포함됩니다. Pylon::CBlazeDefaultConfiguration 클래스. Basler는 이 구성 정보를 해당 클래스의 각 인스턴스에 대해 항상 등록할 것을 권장합니다. CBlazeInstantCamera 사용자가 생성하는 클래스.
camera.RegisterConfiguration(
new CBlazeDefaultConfiguration,
RegistrationMode_ReplaceAll, Cleanup_Delete);
The CBlazeDefaultConfiguration::OnOpened() 이 메서드는 데이터 스트림에 깊이, 강도 및 신뢰도 정보가 포함되도록 구성합니다. 깊이 정보는 포인트 클라우드 형태로 전송됩니다. 포인트 클라우드에는 각 센서 픽셀에 대한 3D 좌표가 포함됩니다. 이 CBlazeDefaultConfiguration::OnOpened() 이 메서드는 또한 카메라를 이른바 ‘자유 실행 모드’로 전환합니다. 자유 실행 모드에서는 데이터 수집이 시작된 후 소프트웨어나 하드웨어 트리거 없이도 카메라가 지속적으로 데이터를 스트리밍합니다.
기본 구성이 등록되어 있다면, CBlazeDefaultConfiguration::OnOpened() 이 메서드는 다음을 통해 자동으로 호출됩니다. CBlazeInstantCamera::Open().
The CBlazeDefaultConfiguration class는 헤더 전용 클래스입니다. 다음 파일을 열어 코드를 확인할 수 있습니다. BlazeDefaultConfiguration.h Pylon SDK의 includes 폴더에 있는 파일:
- Windows:
%Program Files%\pylon\Development\include\pylon - Linux:
/opt/pylon/include/pylon
여러 개의 구성 이벤트 핸들러 클래스를 등록할 수 있습니다.
다음 예제는 추가 설정을 적용하는 구성 이벤트 핸들러를 등록하는 방법을 보여줍니다:
class MyConfigurationHandler : public CBlazeConfigurationEventHandler
{
public:
// Sets exposure time to minimum possible value.
void OnOpened(CBlazeInstantCamera& camera) override
{
camera.ExposureTime.SetToMinimum();
}
};
// ....
// Register the default configuration first.
camera.RegisterConfiguration(
new CBlazeDefaultConfiguration,
RegistrationMode_ReplaceAll, Cleanup_Delete);
// Then, register additional configuration event handlers.
camera.RegisterConfiguration(
new MyConfigurationHandler,
RegistrationMode_Append, Cleanup_Delete);
// ....
camera.Open(); // Configurations will be applied.
pylon 카메라 이벤트 핸들러 클래스에 대한 자세한 내용은 『 pylon C++ 프로그래머 가이드 』의 “인스턴트 카메라 이벤트 핸들러 기초” 섹션을 참조하십시오.
원하는 설정을 적용하기 위해 구성 이벤트 핸들러를 제공할 필요는 없습니다. 대신, CBlazeInstantCamera::Open() 메서드.
카메라 매개변수 값을 설정하고 가져오는 방법에 대한 정보는 ‘매개변수 액세스’ 섹션을 참조하십시오.
카메라 연결하기#
카메라 객체를 생성하고 구성 이벤트 핸들러를 등록한 후, 다음을 호출하여 카메라와의 연결이 설정됩니다. CBlazeInstantCamera::Open() 메서드.
연결은 다음까지 유지됩니다. CBlazeInstantCamera::Close() 메서드가 호출됩니다. 의 소멸자는 CBlazeInstantCamera 자동으로 호출합니다 Close() 명시적으로 호출되지 않은 경우.
카메라는 주기적으로 하트비트 요청을 수신하지 못하면 연결을 종료합니다. 애플리케이션이 충돌하거나 디버거에 의해 중단될 경우 하트비트 요청이 누락될 수 있습니다. 자세한 내용은 “애플리케이션 디버깅 및 GigE Vision 하트비트 제어” 섹션을 참조하십시오.
매개변수 액세스#
pylon API 를 사용하여 카메라 매개변수에 접근하는 방법을 익히려면, pylon C++ 프로그래머 가이드의 ‘매개변수 접근’ 섹션을 참조하십시오.
pylon C++ 예제인 Parametrize_NativeParameterAccess와 Parametrize_GenericParameterAccess는 pylon을 사용하여 카메라 매개변수에 접근하는 일반적인 방법을 보여줍니다.
다음 코드 예제는 다음을 사용하여 Blaze 고유의 자주 사용되는 카메라 매개변수를 설정하고 가져오는 방법을 보여줍니다. CBlazeInstantCamera 클래스.
// Include files to use the pylon API
#include <pylon/PylonIncludes.h>
#include <pylon/BlazeInstantCamera.h>
// Namespaces for using the pylon API and the blaze camera parameters
using namespace Pylon;
using namespace BlazeCameraParams_Params;
// ...
// Set the operating mode of the camera. The choice you make here
// affects the working range of the camera, i.e., the Minimum Working
// Range and Maximum Working Range parameters.
OperatingModeEnums oldOperatingMode = camera.OperatingMode.GetValue();
camera.OperatingMode.SetValue(OperatingMode_LongRange);
// Exposure time of the camera. If the operating mode is changed, the
// exposure time is set to the recommended default value.
camera.ExposureTime.SetValue(750); // us
// Enable and configure image filtering.
// The spatial noise filter uses the values of neighboring pixels to
// filter out noise in an image.
camera.SpatialFilter.SetValue(true);
// The temporal noise filter uses the values of the same pixel at
// different points in time to filter out noise in an image.
camera.TemporalFilter.SetValue(true);
camera.TemporalFilterStrength.SetValue(220);
// The outlier removal removes pixels that differ significantly from
// their local environment.
camera.OutlierRemoval.SetValue(true);
// Some properties have restrictions.
// We use API functions that automatically perform value corrections.
// Alternatively, you can use GetInc() / GetMin() / GetMax() to make sure you
// set a valid value.
camera.ConfidenceThreshold.SetValue(321, IntegerValueCorrection_Nearest);
// Not all functions are available in older cameras.
// Therefore, we must use "Try" functions that only perform the action
// when parameters are writable. Otherwise, we would get an exception.
camera.MultiCameraChannel.TrySetValue(1);
std::cout << "Operating Mode : "
<< camera.OperatingMode.GetValue() << std::endl;
std::cout << "Exposure Time : "
<< camera.ExposureTime.GetValue() << std::endl;
std::cout << "Spatial Filter : "
<< camera.SpatialFilter.GetValue() << std::endl;
std::cout << "Temporal Filter : "
<< camera.TemporalFilter.GetValue() << std::endl;
std::cout << "Temporal Filter Strength : "
<< camera.TemporalFilterStrength.GetValue() << std::endl;
std::cout << "Outlier Removal : "
<< camera.OutlierRemoval.GetValue() << std::endl;
std::cout << "Confidence Threshold : "
<< camera.ConfidenceThreshold.GetValue() << std::endl;
if (camera.MultiCameraChannel.IsReadable())
std::cout << "Multi-Camera Channel : "
<< camera.MultiCameraChannel.GetValue() << std::endl;
// Restore the old operating mode.
camera.OperatingMode.SetValue(oldOperatingMode);
// Close the camera.
camera.Close();
Blaze Viewer에는 ‘문서’ 창이 제공됩니다. ‘기능’ 창에서 카메라 매개변수를 선택하면, ‘문서’ 창에 선택한 매개변수에 대한 정보와 함께 해당 카메라 매개변수의 값을 가져오고 설정하는 방법을 보여주는 C++ 및 C# 코드 예제가 표시됩니다.
데이터 수집#
pylon API 를 사용하여 데이터를 수집하는 방법에 대해 자세히 알아보려면, ‘pylon C++ 프로그래머 가이드 ’의 ‘이미지 캡처’ 섹션을 참조하십시오.
pylon은 캡처된 이미지를 GrabResults라는 데이터 구조로 표현합니다. 2D 카메라로 획득한 GrabResults에는 단일 회색조 이미지 또는 컬러 이미지가 포함됩니다.
blaze 카메라로 캡처된 GrabResult에는 여러 구성 요소가 포함되어 있습니다. 기본적으로 각 GrabResult에는 휘도 이미지, 신뢰도 맵 및 깊이 정보가 저장됩니다.
Range 컴포넌트에 설정된 픽셀 형식에 따라, 깊이 데이터는 2D 깊이 맵 또는 3D 포인트 클라우드로 표현될 수 있습니다. 기본적으로 깊이 데이터는 포인트 클라우드로 표현됩니다.
뎁스 맵을 사용하려면 Range 컴포넌트의 픽셀 형식을 다음과 같이 설정하십시오. PixelFormat_Coord3D_16C:
// Enable depth maps by enabling the Range component and setting the
// appropriate pixel format.
camera.ComponentSelector.SetValue(ComponentSelector_Range);
camera.ComponentEnable.SetValue(true);
camera.PixelFormat.SetValue(PixelFormat_Coord3D_C16);
포인트 클라우드를 사용하려면 Range 컴포넌트의 픽셀 형식을 다음과 같이 설정하십시오. PixelFormat_Coord3D_ABC32f:
// Enable point clouds by enabling the Range component and setting the
// appropriate pixel format.
camera.ComponentSelector.SetValue(ComponentSelector_Range);
camera.ComponentEnable.SetValue(true);
camera.PixelFormat.SetValue(PixelFormat_Coord3D_ABC32f);
다음 내용을 참조하십시오. Component Selector 및 Pixel Format 주제를 참조하십시오.
정보
카메라가 깊이 정보를 포인트 클라우드와 깊이 맵의 형태로 동시에 전송하도록 하는 것은 불가능합니다.
'측정 결과 처리' 항목에서는 깊이 맵을 바탕으로 포인트 클라우드를 계산하는 방법을 설명합니다.
이 변환 과정은 블레이즈 카메라용 GrabDepthMap C++ 프로그래밍 예제에서도 확인할 수 있습니다.
포인트 클라우드에서 깊이 맵을 추출하는 방법은 Blaze 카메라용 ConvertPointCloud2DepthMap C++ 프로그래밍 예제에서 확인할 수 있습니다.
그랩 루프#
pylon은 그랩 루프를 설정하는 다양한 방식을 지원하며, 메모리 버퍼를 처리하는 여러 가지 전략을 제공합니다.
자세한 내용은 ‘pylon C++ 프로그래머 가이드’의 ‘이미지 캡처’ 섹션을 참조하십시오.
다음 코드 조각은 일반적인 그랩 루프를 보여줍니다:
#include <pylon/PylonIncludes.h>
#include <pylon/BlazeInstantCamera.h>
using namespace Pylon;
using namespace BlazeCameraParams_Params;
// ....
PylonInitialize();
CBlazeInstantCamera camera(CTlFactory::GetInstance().CreateFirstDevice(
CDeviceInfo().SetDeviceClass(BaslerGenTlBlazeDeviceClass)));
camera.RegisterConfiguration(
new CBlazeDefaultConfiguration, RegistrationMode_ReplaceAll, Cleanup_Delete);
camera.Open();
size_t nBuffersGrabbed= 0;
// This smart pointer will receive the grab result data.
CGrabResultPtr ptrGrabResult;
camera.StartGrabbing();
while (camera.IsGrabbing() && nBuffersGrabbed < 10) {
// Wait for an image and then retrieve it. A timeout of 1000 ms is used.
camera.RetrieveResult(1000, ptrGrabResult, TimeoutHandling_ThrowException);
// Data grabbed successfully?
if (ptrGrabResult->GrabSucceeded()) {
nBuffersGrabbed++;
// Access the data.
// ....
} else {
// Error handling
std::cerr << "Grab error occurred: " << ptrGrabResult->GetErrorDescription() << std::endl;
}
}
// Clean-up
camera.StopGrabbing();
camera.Close();
컴포넌트에 접근하기#
GrabResult의 개별 구성 요소에 접근하려면 다음을 사용할 수 있습니다. Pylon::CPylonDataContainer 및 Pylon::CPylonDataComponent 클래스. 컨테이너는 하나 이상의 컴포넌트를 포함할 수 있습니다. 컨테이너를 사용하여 컴포넌트의 개수를 조회하거나 특정 컴포넌트를 가져올 수 있습니다. 컨테이너 내의 각 컴포넌트는 실제 데이터(예: 수심 값)와 해당 메타데이터를 포함하고 있습니다.
다음 명령을 사용하여 Pylon::CGrabResultData::GetDataContainer() GrabResult의 CPylonDataContainer. microDisplay의 Pylon::CPylonDataContainer::GetDataComponent() 컴포넌트의 인덱스를 지정하여 해당 컴포넌트에 접근하는 방법.
pylon이 여러 구성 요소를 포함하는 GrabResults에 대한 액세스를 제공하는 방법에 대한 자세한 내용은 pylon C++ 프로그래머 가이드의 ‘고급 주제’ 섹션에 있는 ‘다중 구성 요소 Grab 결과’ 항목을 참조하십시오.
예:
#pragma pack(push, 1)
struct Point
{
float x;
float y;
float z;
};
#pragma pack(pop)
// ...
// By registering the CBlazeDefaultConfiguration, depth, intensity, and confidence data will be delivered.
// Depth data is represented as point clouds.
camera.RegisterConfiguration(new CBlazeDefaultConfiguration, RegistrationMode_ReplaceAll, Cleanup_Delete);
camera.Open();
//....
if (ptrGrabResult->GrabSucceeded())
{
// Get access to the container.
auto container = ptrGrabResult->GetDataContainer();
// Access the container's components.
// Iterate through all components in the container.
for (size_t i = 0; i < container.GetDataComponentCount(); ++i)
{
// Get one component from the container.
const Pylon::CPylonDataComponent component = container.GetDataComponent(i);
if ( !component.IsValid() )
continue;
// Is this the intensity component?
if ( component.GetComponentType() == Pylon::ComponentType_Intensity )
{
const Pylon::EPixelType pixelType = component.GetPixelType();
// Get a pointer to the pixel data.
const void* pPixels = component.GetData();
// Process intensity values here (pixel data).
// [...]
}
}
auto rangeComponent = container.GetDataComponent(0);
auto intensityComponent = container.GetDataComponent(1);
auto confidenceComponent = container.GetDataComponent(2);
// Retrieve the 3D coordinates corresponding to the center pixel.
const auto width = rangeComponent.GetWidth();
const auto height = rangeComponent.GetHeight();
const uint32_t u = (int)(0.5 * width);
const uint32_t v = (int)(0.5 * height);
auto pPoint =
reinterpret_cast<const Point*>(rangeComponent.GetData()) + u + v * width;
uint16_t* pIntensity =
(uint16_t*)intensityComponent.GetData() + v * width + u;
uint16_t* pConfidence
= (uint16_t*)confidenceComponent.GetData() + v * width + u;
if (pPoint->z != 0)
std::cout << "x=" << pPoint->x
<< " y=" << pPoint->y
<< " z=" << pPoint->z << "\n";
else
std::cout << "x= n/a y= n/a z= n/a\n";
std::cout << " intensity=" << *pIntensity
<< " confidence=" << *pConfidence << "\n";
}
else
{
// Error handling
std::cerr << "Grab error occurred: " << ptrGrabResult->GetErrorDescription() << std::endl;
}
다음 항목 사용 ComponentSelector 및 ComponentEnable 카메라 매개변수를 통해 개별 구성 요소를 활성화하거나 비활성화할 수 있습니다. 블레이즈 카메라의 경우, 컨테이너 내 구성 요소의 순서는 항상 다음과 같습니다:
- Range
- 강도
- 신뢰도
예를 들어, ‘범위’ 및 ‘신뢰도’ 구성 요소가 활성화되어 있고 ‘강도’ 구성 요소가 비활성화된 경우, container.GetDataComponent(0) Range 컴포넌트를 가져오고 container.GetDataComponent(1) Confidence 컴포넌트를 반환합니다. 다음을 액세스하려고 하면 container.GetDataComponent(2) Intensity 컴포넌트를 비활성화하면 컨테이너에 컴포넌트가 두 개만 남게 되므로 오류가 발생합니다.
애플리케이션에서 그랩 결과를 처리하는 부분이 어떤 컴포넌트가 나타날지 미리 알 수 없는 경우, 컨테이너를 순회하며 다음을 사용하여 각 컴포넌트의 유형을 확인하는 등, 더 일반적인 방식으로 컴포넌트에 접근해야 합니다. CPylonDataComponent::GetComponentType() 메서드.
예:
camera.RetrieveResult(1000, ptrGrabResult, TimeoutHandling_ThrowException);
// Data grabbed successfully?
if (ptrGrabResult->GrabSucceeded()) {
// Access the data.
auto container = ptrGrabResult->GetDataContainer();
CPylonDataComponent rangeComponent;
CPylonDataComponent intensityComponent;
CPylonDataComponent confidenceComponent;
// Iterate through all components in the container.
for (size_t i = 0; i < container.GetDataComponentCount(); ++i) {
const Pylon::CPylonDataComponent component = container.GetDataComponent(i);
if (!component.IsValid())
continue;
switch (component.GetComponentType())
{
case ComponentType_Intensity:
intensityComponent = component;
break;
case ComponentType_Confidence:
confidenceComponent = component;
break;
case ComponentType_Range:
rangeComponent = component;
break;
}
}
if (rangeComponent.IsValid()) {
const auto width = rangeComponent.GetWidth();
const auto height = rangeComponent.GetHeight();
// Process depth data.
}
if (intensityComponent.IsValid()) {
// Process intensity image.
}
if (confidenceComponent.IsValid())
{
// Process confidence data.
}
}
심도 데이터 해석#
'측정 결과 처리' 항목에서는 Range 구성 요소에 저장된 깊이 데이터의 형식에 대한 정보를 제공합니다.
애플리케이션 디버깅 및 GigE Vision 하트비트 제어#
blaze 카메라와 같은 GigE Vision 카메라는, 카메라를 제어하는 애플리케이션이 여전히 실행 중인지 확인할 수 있도록 애플리케이션이 주기적으로 카메라에 접속해야 합니다. 따라서 전송 계층은 주기적으로 카메라에 네트워크 요청(하트비트)을 보냅니다. 카메라가 카메라의 하트비트 타임아웃 설정에 지정된 시간 내에 이러한 하트비트를 수신하지 못하면, 연결이 끊어진 것으로 간주하고 연결을 종료합니다. 즉, 더 이상 애플리케이션의 명령을 수신하지 않게 됩니다. 하트비트 타임아웃의 기본값은 3000 ms입니다.
애플리케이션을 디버깅하다가 중단점에 도달하면, 디버거는 하트비트를 전송하는 스레드를 포함한 모든 스레드의 실행을 일시 중지합니다. 애플리케이션이 일시 중지된 상태이거나 코드를 한 단계씩 실행하는 동안 카메라가 연결을 끊는 것을 방지하기 위해, 전송 계층은 하트비트 타임아웃을 자동으로 연장합니다(pylon 7.1 이상을 사용하는 경우 1시간으로, 그 외의 경우 5분으로 연장됩니다). pylon 7.1 이상을 사용하는 경우, 애플리케이션이 종료되거나 충돌하면 카메라와의 연결이 자동으로 끊어집니다.
Pylon 7.0 이하 버전 사용 시 재연결 문제
애플리케이션이 카메라와의 연결을 제대로 종료하지 않은 상태에서 종료되거나 강제 종료될 경우, 카메라는 하트비트 타임아웃이 만료될 때까지 연결 상태를 유지합니다. 하트비트 타임아웃이 만료되기 전까지는 카메라가 추가적인 연결 시도를 거부합니다. 애플리케이션을 다시 시작하거나 카메라에 대한 액세스를 요청하는 다른 애플리케이션을 실행하면, 기기가 현재 사용 중이라는 오류 메시지가 표시됩니다.
이는 일반적으로 디버거를 사용하여 애플리케이션을 중지하거나 애플리케이션이 예기치 않게 종료될 때 발생합니다. 카메라를 다시 열려면 타임아웃이 종료될 때까지 기다리거나, 일시적으로 카메라를 네트워크에서 분리해야 합니다.
이 문제를 해결하려면, 디버거의 제어 하에서 애플리케이션이 실행될 때 다음과 같은 이름의 환경 변수를 설정하여 하트비트 타임아웃의 자동 조정을 무시할 수 있습니다. GEV_HEARTBEAT_TIMEOUT 원하는 타임아웃 값(밀리초 단위)으로 설정합니다. 또는, 다음 예시와 같이 ` pylon API `를 사용하여 애플리케이션에서 하트비트 타임아웃을 설정할 수도 있습니다. DeviceRemovalHandling 예제 프로그램.