From 882887bb25680d752376f4113daed0e4180a16e9 Mon Sep 17 00:00:00 2001 From: builder Date: Fri, 17 Jun 2022 09:58:41 +0000 Subject: [PATCH] Update HDevelop samples to SDK 2.6.1 --- .clang-format | 96 ----- .clang-tidy | 399 ------------------ LICENSE | 29 -- README.md | 175 ++++---- continuous-integration/linux/build.sh | 54 --- continuous-integration/linux/lint.sh | 43 -- .../platform-dependent/ubuntu-18.04/setup.sh | 33 -- .../platform-dependent/ubuntu-20.04/setup.sh | 32 -- continuous-integration/linux/setup.sh | 31 -- .../SurfaceMatchingCreateModel.hdev | 148 +++++++ .../SurfaceMatchingCreateModelFromFile.hdev | 116 +++++ .../SurfaceMatchingFindModel.hdev | 224 ++++++++++ .../SurfaceMatchingFindModelFromFile.hdev | 173 ++++++++ .../Basic/FileFormats/ReadPLY.hdev | 74 ++++ source/Camera/Advanced/CaptureHDRLoop.hdev | 153 +++++++ source/Camera/Basic/Capture.hdev | 78 ++++ source/Camera/Basic/CaptureHDR.hdev | 83 ++++ .../Basic/CaptureHDRCompleteSettings.hdev | 104 +++++ source/Camera/Basic/CaptureSavePLY.hdev | 89 ++++ .../Basic/ConnectToSerialNumberCamera.hdev | 34 ++ .../QuerySettingsAndParameters.hdev | 104 +++++ .../get_first_available_zivid_device.hdvp | 36 ++ .../Procedures/get_zivid_sample_data_dir.hdvp | 34 ++ .../convert_intrinsics_opencv_to_halcon.py | 8 +- source/SampleUtils/yaml_settings_to_json.py | 31 ++ source/cpp/CMakeLists.txt | 47 --- .../CaptureViaGenICam/CaptureViaGenICam.cpp | 125 ------ .../Basic/CaptureViaZivid/CaptureViaZivid.cpp | 154 ------- source/cpp/README.md | 16 - source/cpp/cmake/CompilerOptions.cmake | 79 ---- source/cpp/cmake/FindHDevEngine.cmake | 64 --- source/cpp/cmake/FindHalcon.cmake | 84 ---- .../Camera/Basic/CaptureViaGenICam/App.config | 6 - .../CaptureViaGenICam/CaptureViaGenICam.cs | 127 ------ .../CaptureViaGenICam.csproj | 77 ---- .../Properties/AssemblyInfo.cs | 36 -- .../Camera/Basic/CaptureViaZivid/App.config | 6 - .../Basic/CaptureViaZivid/CaptureViaZivid.cs | 154 ------- .../CaptureViaZivid/CaptureViaZivid.csproj | 77 ---- .../Properties/AssemblyInfo.cs | 36 -- .../SurfaceMatchingCreateModel.hdev | 151 ------- .../SurfaceMatchingCreateModelFromFile.hdev | 118 ------ .../SurfaceMatchingFindModel.hdev | 227 ---------- .../SurfaceMatchingFindModelFromFile.hdev | 176 -------- .../Basic/FileFormats/ReadPLY.hdev | 78 ---- source/hdev/Camera/Basic/Capture.hdev | 83 ---- source/hdev/Camera/Basic/CaptureHDR.hdev | 88 ---- .../Basic/CaptureHDRCompleteSettings.hdev | 108 ----- source/hdev/Camera/Basic/CaptureHDRLoop.hdev | 157 ------- source/hdev/Camera/Basic/CaptureSavePLY.hdev | 93 ---- .../Basic/ConnectToSerialNumberCamera.hdev | 37 -- .../hdev/Camera/Basic/YAMLSettingsToJSON.py | 33 -- .../QuerySettingsAndParameters.hdev | 108 ----- .../get_first_available_zivid_device.hdvp | 34 -- .../Procedures/get_zivid_sample_data_dir.hdvp | 32 -- 55 files changed, 1573 insertions(+), 3419 deletions(-) delete mode 100644 .clang-format delete mode 100644 .clang-tidy delete mode 100644 LICENSE delete mode 100644 continuous-integration/linux/build.sh delete mode 100644 continuous-integration/linux/lint.sh delete mode 100644 continuous-integration/linux/platform-dependent/ubuntu-18.04/setup.sh delete mode 100644 continuous-integration/linux/platform-dependent/ubuntu-20.04/setup.sh delete mode 100644 continuous-integration/linux/setup.sh create mode 100644 source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev create mode 100644 source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev create mode 100644 source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev create mode 100644 source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev create mode 100644 source/Applications/Basic/FileFormats/ReadPLY.hdev create mode 100644 source/Camera/Advanced/CaptureHDRLoop.hdev create mode 100644 source/Camera/Basic/Capture.hdev create mode 100644 source/Camera/Basic/CaptureHDR.hdev create mode 100644 source/Camera/Basic/CaptureHDRCompleteSettings.hdev create mode 100644 source/Camera/Basic/CaptureSavePLY.hdev create mode 100644 source/Camera/Basic/ConnectToSerialNumberCamera.hdev create mode 100644 source/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev create mode 100644 source/Procedures/get_first_available_zivid_device.hdvp create mode 100644 source/Procedures/get_zivid_sample_data_dir.hdvp rename source/{python => SampleUtils}/convert_intrinsics_opencv_to_halcon.py (98%) create mode 100644 source/SampleUtils/yaml_settings_to_json.py delete mode 100644 source/cpp/CMakeLists.txt delete mode 100644 source/cpp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cpp delete mode 100644 source/cpp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cpp delete mode 100644 source/cpp/README.md delete mode 100644 source/cpp/cmake/CompilerOptions.cmake delete mode 100644 source/cpp/cmake/FindHDevEngine.cmake delete mode 100644 source/cpp/cmake/FindHalcon.cmake delete mode 100644 source/csharp/Camera/Basic/CaptureViaGenICam/App.config delete mode 100644 source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cs delete mode 100644 source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.csproj delete mode 100644 source/csharp/Camera/Basic/CaptureViaGenICam/Properties/AssemblyInfo.cs delete mode 100644 source/csharp/Camera/Basic/CaptureViaZivid/App.config delete mode 100644 source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cs delete mode 100644 source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.csproj delete mode 100644 source/csharp/Camera/Basic/CaptureViaZivid/Properties/AssemblyInfo.cs delete mode 100644 source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev delete mode 100644 source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev delete mode 100644 source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev delete mode 100644 source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev delete mode 100644 source/hdev/Applications/Basic/FileFormats/ReadPLY.hdev delete mode 100644 source/hdev/Camera/Basic/Capture.hdev delete mode 100644 source/hdev/Camera/Basic/CaptureHDR.hdev delete mode 100644 source/hdev/Camera/Basic/CaptureHDRCompleteSettings.hdev delete mode 100644 source/hdev/Camera/Basic/CaptureHDRLoop.hdev delete mode 100644 source/hdev/Camera/Basic/CaptureSavePLY.hdev delete mode 100644 source/hdev/Camera/Basic/ConnectToSerialNumberCamera.hdev delete mode 100644 source/hdev/Camera/Basic/YAMLSettingsToJSON.py delete mode 100644 source/hdev/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev delete mode 100644 source/hdev/Procedures/get_first_available_zivid_device.hdvp delete mode 100644 source/hdev/Procedures/get_zivid_sample_data_dir.hdvp diff --git a/.clang-format b/.clang-format deleted file mode 100644 index 7f3f20c..0000000 --- a/.clang-format +++ /dev/null @@ -1,96 +0,0 @@ -Language: Cpp -AccessModifierOffset: -4 -AlignAfterOpenBracket: Align -AlignConsecutiveAssignments: false -AlignConsecutiveDeclarations: false -AlignEscapedNewlines: Right -AlignOperands: true -AlignTrailingComments: true -AllowAllParametersOfDeclarationOnNextLine: false -AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: true -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: true -AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterReturnType: None -AlwaysBreakBeforeMultilineStrings: false -AlwaysBreakTemplateDeclarations: true -BinPackArguments: false -BinPackParameters: false -BraceWrapping: - AfterCaseLabel: true - AfterClass: true - AfterControlStatement: true - AfterEnum: true - AfterFunction: true - AfterNamespace: true - AfterStruct: true - AfterUnion: true - AfterExternBlock: true - BeforeCatch: true - BeforeElse: true - IndentBraces: false - SplitEmptyFunction: false - SplitEmptyRecord: false - SplitEmptyNamespace: false -BreakBeforeBinaryOperators: NonAssignment -BreakBeforeBraces: Custom -BreakBeforeInheritanceComma: false -BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: true -BreakConstructorInitializers: BeforeComma -BreakStringLiterals: false -ColumnLimit: 120 -CommentPragmas: '' -CompactNamespaces: false -ConstructorInitializerAllOnOneLineOrOnePerLine: false -ConstructorInitializerIndentWidth: 4 -ContinuationIndentWidth: 4 -Cpp11BracedListStyle: false -DerivePointerAlignment: false -DisableFormat: false -FixNamespaceComments: true -ForEachMacros: [] -IncludeCategories: - - Regex: '^"(Zivid)/' - Priority: 3 - - Regex: '^"(boost)/' - Priority: 2 - - Regex: '.*' - Priority: 1 -IncludeIsMainRegex: '(Test)?$' -IndentCaseLabels: true -IndentPPDirectives: AfterHash -IndentWidth: 4 -IndentWrappedFunctionNames: false -KeepEmptyLinesAtTheStartOfBlocks: false -MacroBlockBegin: '' -MacroBlockEnd: '' -MaxEmptyLinesToKeep: 1 -NamespaceIndentation: All -PenaltyBreakAssignment: 2 -PenaltyBreakBeforeFirstCallParameter: 200 -PenaltyBreakComment: 300 -PenaltyBreakFirstLessLess: 120 -PenaltyBreakString: 1000 -PenaltyExcessCharacter: 1000000 -PenaltyReturnTypeOnItsOwnLine: 200 -PointerAlignment: Right -RawStringFormats: [] -ReflowComments: false -SortIncludes: true -SortUsingDeclarations: true -SpaceAfterCStyleCast: false -SpaceAfterTemplateKeyword: false -SpaceBeforeAssignmentOperators: true -SpaceBeforeParens: Never -SpaceInEmptyParentheses: false -SpacesBeforeTrailingComments: 1 -SpacesInAngles: false -SpacesInContainerLiterals: false -SpacesInCStyleCastParentheses: false -SpacesInParentheses: false -SpacesInSquareBrackets: false -Standard: Cpp11 -TabWidth: 4 -UseTab: Never diff --git a/.clang-tidy b/.clang-tidy deleted file mode 100644 index b392f1f..0000000 --- a/.clang-tidy +++ /dev/null @@ -1,399 +0,0 @@ -Checks: > - *, - -fuchsia-*, - -llvm-header-guard, - -cppcoreguidelines-macro-usage, - -google-runtime-references, - -modernize-use-nodiscard, - -modernize-use-trailing-return-type, - -cppcoreguidelines-avoid-magic-numbers, - -readability-magic-numbers, - -cppcoreguidelines-pro-type-union-access, -WarningsAsErrors: '*' -HeaderFilterRegex: '.*' -AnalyzeTemporaryDtors: false -CheckOptions: - - key: cert-dcl59-cpp.HeaderFileExtensions - value: h,hh,hpp,hxx - - key: cert-err09-cpp.CheckThrowTemporaries - value: '1' - - key: cert-err61-cpp.CheckThrowTemporaries - value: '1' - - key: cert-oop11-cpp.IncludeStyle - value: llvm - - key: cppcoreguidelines-pro-bounds-constant-array-index.GslHeader - value: '' - - key: cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle - value: '1' - - key: google-build-namespaces.HeaderFileExtensions - value: h,hh,hpp,hxx - - key: google-global-names-in-headers.HeaderFileExtensions - value: h - - key: google-readability-braces-around-statements.ShortStatementLines - value: '2' - - key: google-readability-function-size.BranchThreshold - value: '4294967295' - - key: google-readability-function-size.LineThreshold - value: '4294967295' - - key: google-readability-function-size.StatementThreshold - value: '800' - - key: google-readability-namespace-comments.ShortNamespaceLines - value: '10' - - key: google-readability-namespace-comments.SpacesBeforeComments - value: '2' - - key: misc-argument-comment.StrictMode - value: '0' - - key: misc-assert-side-effect.AssertMacros - value: assert - - key: misc-assert-side-effect.CheckFunctionCalls - value: '0' - - key: misc-dangling-handle.HandleClasses - value: 'std::basic_string_view;std::experimental::basic_string_view' - - key: misc-definitions-in-headers.HeaderFileExtensions - value: ',h,hh,hpp,hxx' - - key: misc-definitions-in-headers.UseHeaderFileExtension - value: '1' - - key: misc-misplaced-widening-cast.CheckImplicitCasts - value: '1' - - key: misc-move-constructor-init.IncludeStyle - value: llvm - - key: misc-sizeof-expression.WarnOnSizeOfCompareToConstant - value: '1' - - key: misc-sizeof-expression.WarnOnSizeOfConstant - value: '1' - - key: misc-sizeof-expression.WarnOnSizeOfThis - value: '1' - - key: misc-string-constructor.LargeLengthThreshold - value: '8388608' - - key: misc-string-constructor.WarnOnLargeLength - value: '1' - - key: misc-suspicious-enum-usage.StrictMode - value: '0' - - key: misc-suspicious-missing-comma.MaxConcatenatedTokens - value: '5' - - key: misc-suspicious-missing-comma.RatioThreshold - value: '0.200000' - - key: misc-suspicious-missing-comma.SizeThreshold - value: '5' - - key: misc-suspicious-string-compare.StringCompareLikeFunctions - value: '' - - key: misc-suspicious-string-compare.WarnOnImplicitComparison - value: '1' - - key: misc-suspicious-string-compare.WarnOnLogicalNotComparison - value: '0' - - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries - value: '1' - - key: modernize-loop-convert.MaxCopySize - value: '16' - - key: modernize-loop-convert.MinConfidence - value: risky - - key: modernize-loop-convert.NamingStyle - value: camelBack - - key: modernize-pass-by-value.IncludeStyle - value: llvm - - key: modernize-replace-auto-ptr.IncludeStyle - value: llvm - - key: modernize-use-auto.RemoveStars - value: '1' - - key: modernize-use-default-member-init.UseAssignment - value: '0' - - key: modernize-use-emplace.ContainersWithPushBack - value: '::std::vector;::std::list;::std::deque' - - key: modernize-use-emplace.SmartPointers - value: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' - - key: modernize-use-nullptr.NullMacros - value: 'NULL' - - key: modernize-use-transparent-functors.SafeMode - value: '0' - - key: performance-faster-string-find.StringLikeClasses - value: 'std::basic_string' - - key: performance-for-range-copy.WarnOnAllAutoCopies - value: '0' - - key: performance-inefficient-string-concatenation.StrictMode - value: '0' - - key: performance-type-promotion-in-math-fn.IncludeStyle - value: llvm - - key: readability-braces-around-statements.ShortStatementLines - value: '2' - - key: readability-function-size.BranchThreshold - value: '4294967295' - - key: readability-function-size.LineThreshold - value: '4294967295' - - key: readability-function-size.StatementThreshold - value: '800' - - key: readability-identifier-naming.AbstractClassCase - value: CamelCase - - key: readability-identifier-naming.AbstractClassPrefix - value: '' - - key: readability-identifier-naming.AbstractClassSuffix - value: '' - - key: readability-identifier-naming.ClassCase - value: CamelCase - - key: readability-identifier-naming.ClassConstantCase - value: camelBack - - key: readability-identifier-naming.ClassConstantPrefix - value: '' - - key: readability-identifier-naming.ClassConstantSuffix - value: '' - - key: readability-identifier-naming.ClassMemberCase - value: camelBack - - key: readability-identifier-naming.ClassMemberPrefix - value: '' - - key: readability-identifier-naming.ClassMemberSuffix - value: '' - - key: readability-identifier-naming.ClassMethodCase - value: camelBack - - key: readability-identifier-naming.ClassMethodPrefix - value: '' - - key: readability-identifier-naming.ClassMethodSuffix - value: '' - - key: readability-identifier-naming.ClassPrefix - value: '' - - key: readability-identifier-naming.ClassSuffix - value: '' - - key: readability-identifier-naming.ConstantCase - value: camelBack - - key: readability-identifier-naming.ConstantMemberCase - value: camelBack - - key: readability-identifier-naming.ConstantMemberPrefix - value: '' - - key: readability-identifier-naming.ConstantMemberSuffix - value: '' - - key: readability-identifier-naming.ConstantParameterCase - value: camelBack - - key: readability-identifier-naming.ConstantParameterPrefix - value: '' - - key: readability-identifier-naming.ConstantParameterSuffix - value: '' - - key: readability-identifier-naming.ConstantPrefix - value: '' - - key: readability-identifier-naming.ConstantSuffix - value: '' - - key: readability-identifier-naming.ConstexprFunctionCase - value: camelBack - - key: readability-identifier-naming.ConstexprFunctionPrefix - value: '' - - key: readability-identifier-naming.ConstexprFunctionSuffix - value: '' - - key: readability-identifier-naming.ConstexprMethodCase - value: camelBack - - key: readability-identifier-naming.ConstexprMethodPrefix - value: '' - - key: readability-identifier-naming.ConstexprMethodSuffix - value: '' - - key: readability-identifier-naming.ConstexprVariableCase - value: camelBack - - key: readability-identifier-naming.ConstexprVariablePrefix - value: '' - - key: readability-identifier-naming.ConstexprVariableSuffix - value: '' - - key: readability-identifier-naming.EnumCase - value: CamelCase - - key: readability-identifier-naming.EnumConstantCase - value: camelBack - - key: readability-identifier-naming.EnumConstantPrefix - value: '' - - key: readability-identifier-naming.EnumConstantSuffix - value: '' - - key: readability-identifier-naming.EnumPrefix - value: '' - - key: readability-identifier-naming.EnumSuffix - value: '' - - key: readability-identifier-naming.FunctionCase - value: camelBack - - key: readability-identifier-naming.FunctionPrefix - value: '' - - key: readability-identifier-naming.FunctionSuffix - value: '' - - key: readability-identifier-naming.GlobalConstantCase - value: camelBack - - key: readability-identifier-naming.GlobalConstantPrefix - value: '' - - key: readability-identifier-naming.GlobalConstantSuffix - value: '' - - key: readability-identifier-naming.GlobalFunctionCase - value: camelBack - - key: readability-identifier-naming.GlobalFunctionPrefix - value: '' - - key: readability-identifier-naming.GlobalFunctionSuffix - value: '' - - key: readability-identifier-naming.GlobalVariableCase - value: camelBack - - key: readability-identifier-naming.GlobalVariablePrefix - value: '' - - key: readability-identifier-naming.GlobalVariableSuffix - value: '' - - key: readability-identifier-naming.IgnoreFailedSplit - value: '0' - - key: readability-identifier-naming.InlineNamespaceCase - value: CamelCase - - key: readability-identifier-naming.InlineNamespacePrefix - value: '' - - key: readability-identifier-naming.InlineNamespaceSuffix - value: '' - - key: readability-identifier-naming.LocalConstantCase - value: camelBack - - key: readability-identifier-naming.LocalConstantPrefix - value: '' - - key: readability-identifier-naming.LocalConstantSuffix - value: '' - - key: readability-identifier-naming.LocalVariableCase - value: camelBack - - key: readability-identifier-naming.LocalVariablePrefix - value: '' - - key: readability-identifier-naming.LocalVariableSuffix - value: '' - - key: readability-identifier-naming.MacroDefinitionCase - value: '' - - key: readability-identifier-naming.MacroDefinitionPrefix - value: '' - - key: readability-identifier-naming.MacroDefinitionSuffix - value: '' - - key: readability-identifier-naming.MemberCase - value: camelBack - - key: readability-identifier-naming.MemberPrefix - value: '' - - key: readability-identifier-naming.MemberSuffix - value: '' - - key: readability-identifier-naming.MethodCase - value: camelBack - - key: readability-identifier-naming.MethodPrefix - value: '' - - key: readability-identifier-naming.MethodSuffix - value: '' - - key: readability-identifier-naming.NamespaceCase - value: CamelCase - - key: readability-identifier-naming.NamespacePrefix - value: '' - - key: readability-identifier-naming.NamespaceSuffix - value: '' - - key: readability-identifier-naming.ParameterCase - value: camelBack - - key: readability-identifier-naming.ParameterPackCase - value: camelBack - - key: readability-identifier-naming.ParameterPackPrefix - value: '' - - key: readability-identifier-naming.ParameterPackSuffix - value: '' - - key: readability-identifier-naming.ParameterPrefix - value: '' - - key: readability-identifier-naming.ParameterSuffix - value: '' - - key: readability-identifier-naming.PrivateMemberCase - value: camelBack - - key: readability-identifier-naming.PrivateMemberPrefix - value: 'm_' - - key: readability-identifier-naming.PrivateMemberSuffix - value: '' - - key: readability-identifier-naming.PrivateMethodCase - value: camelBack - - key: readability-identifier-naming.PrivateMethodPrefix - value: '' - - key: readability-identifier-naming.PrivateMethodSuffix - value: '' - - key: readability-identifier-naming.ProtectedMemberCase - value: camelBack - - key: readability-identifier-naming.ProtectedMemberPrefix - value: 'm_' - - key: readability-identifier-naming.ProtectedMemberSuffix - value: '' - - key: readability-identifier-naming.ProtectedMethodCase - value: camelBack - - key: readability-identifier-naming.ProtectedMethodPrefix - value: '' - - key: readability-identifier-naming.ProtectedMethodSuffix - value: '' - - key: readability-identifier-naming.PublicMemberCase - value: camelBack - - key: readability-identifier-naming.PublicMemberPrefix - value: '' - - key: readability-identifier-naming.PublicMemberSuffix - value: '' - - key: readability-identifier-naming.PublicMethodCase - value: camelBack - - key: readability-identifier-naming.PublicMethodPrefix - value: '' - - key: readability-identifier-naming.PublicMethodSuffix - value: '' - - key: readability-identifier-naming.StaticConstantCase - value: camelBack - - key: readability-identifier-naming.StaticConstantPrefix - value: '' - - key: readability-identifier-naming.StaticConstantSuffix - value: '' - - key: readability-identifier-naming.StaticVariableCase - value: camelBack - - key: readability-identifier-naming.StaticVariablePrefix - value: '' - - key: readability-identifier-naming.StaticVariableSuffix - value: '' - - key: readability-identifier-naming.StructCase - value: CamelCase - - key: readability-identifier-naming.StructPrefix - value: '' - - key: readability-identifier-naming.StructSuffix - value: '' - - key: readability-identifier-naming.TemplateParameterCase - value: CamelCase - - key: readability-identifier-naming.TemplateParameterPrefix - value: '' - - key: readability-identifier-naming.TemplateParameterSuffix - value: '' - - key: readability-identifier-naming.TemplateTemplateParameterCase - value: CamelCase - - key: readability-identifier-naming.TemplateTemplateParameterPrefix - value: '' - - key: readability-identifier-naming.TemplateTemplateParameterSuffix - value: '' - - key: readability-identifier-naming.TypeAliasCase - value: CamelCase - - key: readability-identifier-naming.TypeAliasPrefix - value: '' - - key: readability-identifier-naming.TypeAliasSuffix - value: '' - - key: readability-identifier-naming.TypeTemplateParameterCase - value: CamelCase - - key: readability-identifier-naming.TypeTemplateParameterPrefix - value: '' - - key: readability-identifier-naming.TypeTemplateParameterSuffix - value: '' - - key: readability-identifier-naming.TypedefCase - value: CamelCase - - key: readability-identifier-naming.TypedefPrefix - value: '' - - key: readability-identifier-naming.TypedefSuffix - value: '' - - key: readability-identifier-naming.UnionCase - value: UPPER_CASE - - key: readability-identifier-naming.UnionPrefix - value: 'dontuseunion' - - key: readability-identifier-naming.UnionSuffix - value: '' - - key: readability-identifier-naming.ValueTemplateParameterCase - value: camelBack - - key: readability-identifier-naming.ValueTemplateParameterPrefix - value: '' - - key: readability-identifier-naming.ValueTemplateParameterSuffix - value: '' - - key: readability-identifier-naming.VariableCase - value: camelBack - - key: readability-identifier-naming.VariablePrefix - value: '' - - key: readability-identifier-naming.VariableSuffix - value: '' - - key: readability-identifier-naming.VirtualMethodCase - value: camelBack - - key: readability-identifier-naming.VirtualMethodPrefix - value: '' - - key: readability-identifier-naming.VirtualMethodSuffix - value: '' - - key: readability-implicit-bool-cast.AllowConditionalIntegerCasts - value: '0' - - key: readability-implicit-bool-cast.AllowConditionalPointerCasts - value: '0' - - key: readability-simplify-boolean-expr.ChainedConditionalAssignment - value: '0' - - key: readability-simplify-boolean-expr.ChainedConditionalReturn - value: '0' - - key: misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables - value: '1' diff --git a/LICENSE b/LICENSE deleted file mode 100644 index cc6c8dc..0000000 --- a/LICENSE +++ /dev/null @@ -1,29 +0,0 @@ -BSD 3-Clause License - -Copyright (c) 2020, Zivid AS -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -1. Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - -3. Neither the name of the copyright holder nor the names of its - contributors may be used to endorse or promote products derived from - this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md index 1981bec..cbc62c9 100644 --- a/README.md +++ b/README.md @@ -1,106 +1,107 @@ -# HALCON samples +# HDevelop samples + +This repository contains HDevelop code samples for Zivid SDK v2.6.1. For +tested compatibility with earlier SDK versions, please check out +[accompanying +releases](https://github.com/zivid/zivid-halcon-samples/tree/master/../../releases). + +![image](https://www.zivid.com/hubfs/softwarefiles/images/zivid-generic-github-header.png) -This repository contains code samples for the usage of a **Zivid** 3D camera in **HALCON**. -![Zivid Image][header-image] --- *Contents:* [**Samples**](#Samples-list) | -[**Instructions**](#Instructions) | +[**Installation**](#Installation) | [**Support**](#Support) | -[**Licence**](#Licence) +[**License**](#License) --- -## Samples list - -There are two main categories of samples: **Camera** and **Applications**. The samples in the **Camera** category focus only on how to use the camera. The samples in the **Applications** category use the output generated by the camera, such as the 3D point cloud, a 2D image or other data from the camera. These samples shows how the data from the camera can be used. - -Samples indicated by **(cpp)** are written in C++, samples indiced by **(csharp)** are written in C#, while samples written in HDevelop is indicated by **(hdev)**. - -- **Camera** - - **Basic** - - **Capture** ([**hdev**][hdev-capture-url]) - Capture point clouds, with color, from the Zivid camera and use it to generate a HALCON ObjectModel3D which is then visualized. - - **CaptureHDR** ([**hdev**][hdev-captureHDR-url]) - Capture HDR point clouds, with color, from the Zivid camera and use it to generate a HALCON ObjectModel3D which is then visualized. - - **CaptureHDRCompleteSettings** ([**hdev**][hdev-captureHDRCompleteSettings-url]) - Capture point clouds, with color, from the Zivid camera with fully configured settings and use it to generate a HALCON ObjectModel3D which is then visualized. - - **CaptureHDRLoop** ([**hdev**][hdev-captureHDRLoop-url]) - Capture HDR point clouds, with color, from the zivid camera in a loop (while actively changing some acquisition settings). Each point cloud is used to generate a HALCON ObjectModel3D which is then visualized. Settings are read from .json files from [**Zivid sample data**][zivid-sample-data-url]. However, you may also get settings from Zivid Studio. When you save settings they will be stored in .yaml format. Halcon only support reading JSON files, so in order to convert them to JSON use [**YAMLSettingsToJSON**][YAMLSettingsToJSON-url]. - - **ConnectToSerialNumberCamera** ([**hdev**][hdev-connectToSerialNumberCamera-url]) - Connect to a specific Zivid 3D camera based on its serial number. You should modify the sample to include your cameras serial number before running the sample. - - **CaptureSavePLY** ([**hdev**][hdev-captureSavePLY-url]) - Capture a point cloud, with colors, from the camera and save it to a .ply file format. The .ply file is saved in the same folder as the sample. - - **CaptureViaGenICam** ([**cpp**][cpp-captureViaGenICam-url], [**csharp**](csharp-captureViaGenICam-url)) - Capture and save a point cloud, with colors, using GenICam interface and Halcon C++/C# SDK. - - **CaptureViaZivid** ([**cpp**][cpp-captureViaZivid-url], [**csharp**](csharp-captureViaZivid-url)) - Capture a point cloud, with colors, using Zivid SDK, transform it to a Halcon point cloud and save it using Halcon C++/C# SDK. - - **InfoUtilOther** - - **QuerySettingsAndParameters** ([**hdev**][hdev-querySettingsAndParameters-url]) - Query information about the image acquisition interface and selected specific parameters of Zivid camera. - -- **Applications** - - **Basic** - - **FileFormats** - - **ReadPLY** ([**hdev**][hdev-readPLY-url]) - Read point cloud from PLY file and visualize it. - - **Advanced** - - **ObjectMatching** ([**hdev**][hdev-objectMatching-url]) - - **SurfaceMatchingCreateModelFromFile** ([**hdev**][hdev-surfaceMatchingCreateModelFromFile-url]) - Load a model from file for surface-based matching algorithm integrated into HALCON. This example comes with three models created by this program: a Pringles can (190 g), a plastic Coca-Cola bottle (0.5 l) and a Twinings tea box (~15cm x 7cm x 8cm). - - **SurfaceMatchingCreateModel** ([**hdev**][hdev-surfaceMatchingCreateModel-url]) - Create your own model for surface-based matching algorithm integrated into HALCON. This example comes with three models created by this program: a Pringles can (190 g), a plastic Coca-Cola bottle (0.5 l) and a Twinings tea box (~15cm x 7cm x 8cm). - - **SurfaceMatchingFindModelFromFile** ([**hdev**][hdev-surfaceMatchingFindModelFromFile-url]) - Run surface-based 3D matching algorithm using a model from file. The model used for matching is created from a reference view of the object. That model is then searched for in a newly captured 3D point cloud. This example comes with three existing object models: a Pringles can (190 g), a plastic Coca-Cola bottle (0.5 l) and a Twinings tea box (~15cm x 7cm x 8cm). - - **SurfaceMatchingFindModel** ([**hdev**][hdev-surfaceMatchingFindModel-url]) - Run surface-based 3D matching algorithm on data taken with the Zivid camera. The model used for matching is created from a reference view of the object. That model is then searched for in a newly captured 3D point cloud. This example comes with two existing object models: a Pringles can (190 g), a plastic Coca-Cola bottle (0.5 l) and a Twinings tea box (~15cm x 7cm x 8cm). - -- **Procedures** - - **get_first_available_zivid_device** ([**hdev**][hdev-get_first_available_zivid_device-url]) - This procedure returns the first Zivid device from the input tuple of devices. The input tuple 'Devices' is typically returned by info_framegrabber function as follows: 'info_framegrabber ('GenICamTL','device', Information, Devices)' - - **get_zivid_sample_data_dir** ([**hdev**][hdev-get_zivid_sample_data_dir-url]) - This procedure returns the path to [**Zivid sample data**][zivid-sample-data-url]. This should be used if you want to use some of the sample data, e.g. settings in .json files. - -## Instructions - -1. [**Install Zivid Software**][zivid-software-installation-url]. -Note: The samples require Zivid SDK v2 (minor version 2.1 or newer). -2. [**Download Zivid Sample Data**][zivid-sample-data-url]. -3. [**Install HALCON Software**][halcon-url]. -Note: The version tested with Zivid cameras is 20.05 Progress for Windows. - -4. Launch HALCON. +## Samples list -5. Open and run one of the samples. Check out [how to run a HALCON sample][how-to-run-a-halcon-sample-url]. +There are two main categories of samples: **Camera** and +**Applications**. The samples in the **Camera** category focus only on +how to use the camera. The samples in the **Applications** category use +the output generated by the camera, such as the 3D point cloud, a 2D +image or other data from the camera. These samples shows how the data +from the camera can be used. + + - **Camera** + - **Basic** + - [Capture](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Camera/Basic/Capture.hdev) - Capture a 3D color point cloud from the camera and use it + to generate a HALCON ObjectModel3D which is then visualized. + - [CaptureHDR](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Camera/Basic/CaptureHDR.hdev) - Capture an HDR image from the camera and use it to + generate a HALCON ObjectModel3D which is then visualized. + - [CaptureHDRCompleteSettings](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Camera/Basic/CaptureHDRCompleteSettings.hdev) - Capture an HDR image from the Zivid camera with fully + configured settings for each frame. + - [CaptureSavePLY](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Camera/Basic/CaptureSavePLY.hdev) - Capture a 3D color point cloud from the camera and save it + to a PLY file format. + - [ConnectToSerialNumberCamera](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Camera/Basic/ConnectToSerialNumberCamera.hdev) - Connect to a specific Zivid 3D camera based on its serial + number. + - **Advanced** + - [CaptureHDRLoop](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Camera/Advanced/CaptureHDRLoop.hdev) - Capture HDR images from the camera in a loop (while + actively changing some HDR settings). + - **InfoUtilOther** + - [QuerySettingsAndParameters](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev) - Query information about the image acquisition interface + and selected specific parameters of Zivid camera. + - **Applications** + - **Basic** + - **FileFormats** + - [ReadPLY](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Applications/Basic/FileFormats/ReadPLY.hdev) - Import and display a Zivid point cloud from a PLY + file. + - **Advanced** + - **ObjectMatching** + - [SurfaceMatchingCreateModel](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev) - Create a model for HALCON surface-based 3D matching + algorithm from a Zivid point cloud captured by a camera. + - [SurfaceMatchingCreateModelFromFile](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev) - Create a model for HALCON surface-based 3D matching + algorithm from a Zivid point cloud loaded from a ZDF + file. + - [SurfaceMatchingFindModel](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev) - Utilize surface-based 3D matching on data taken with a + Zivid camera. + - [SurfaceMatchingFindModelFromFile](https://github.com/zivid/zivid-halcon-samples/tree/master//source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev) - Utilize surface-based 3D matching on data taken with a + Zivid camera. + +## Installation + +If you want to use Zivid in HALCON, we provide a GenICam GenTL producer +that comes with the [Zivid Software](http://www.zivid.com/downloads). + +Zivid and HALCON are compatible with Windows 10 and Ubuntu 16.04, 18.04, +20.04. + +To setup and use Zivid in one of these operating systems, please follow +their respective instructions in the following pages: + + - [Install Zivid + HALCON for + Windows](https://support.zivid.com/latest/rst/api-reference/samples/halcon/install-zivid-halcon-for-windows.html) + - [Install Zivid + HALCON for + LINUX](https://support.zivid.com/latest/rst/api-reference/samples/halcon/install-zivid-halcon-for-linux.html) + - [Create a HALCON "Hello World" + Program](https://support.zivid.com/latest/rst/api-reference/samples/halcon/create-a-halcon-hello-world.html) + - [How to Run a HALCON + Sample](https://support.zivid.com/latest/rst/api-reference/samples/halcon/how-to-run-a-halcon-sample.html) + - [HALCON Sample + Videos](https://support.zivid.com/latest/rst/api-reference/samples/halcon/halcon-sample-videos.html) + +The following HALCON versions have been tested and confirmed to work +with Zivid cameras: + + - 19.05 Progress, 20.05 Progress, 21.11 Progress + +We recommend to use one of the HALCON versions we have tested. ## Support -If you need assistance with using Zivid cameras, visit our [**Knowledge Base**][knowladge-base-url] or contact us at [customersuccess@zivid.com](mailto:customersuccess@zivid.com). - -## Licence -Zivid Samples are distributed under the [BSD license][halcon-samples-licence-url]. - -[header-image]: https://www.zivid.com/hubfs/softwarefiles/images/zivid-generic-github-header.png - -[hdev-capture-url]: source/hdev/Camera/Basic/Capture.hdev -[hdev-captureHDR-url]: source/hdev/Camera/Basic/CaptureHDR.hdev -[hdev-captureHDRCompleteSettings-url]: source/hdev/Camera/Basic/CaptureHDRCompleteSettings.hdev -[hdev-captureHDRLoop-url]: source/hdev/Camera/Basic/CaptureHDRLoop.hdev -[YAMLSettingsToJSON-url]: source/hdev/Camera/Basic/YAMLSettingsToJSON.py -[hdev-connectToSerialNumberCamera-url]: source/hdev/Camera/Basic/ConnectToSerialNumberCamera.hdev -[hdev-captureSavePLY-url]: source/hdev/Camera/Basic/CaptureSavePLY.hdev -[cpp-captureViaGenICam-url]: source/cpp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cpp -[cpp-captureViaZivid-url]: source/cpp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cpp -[csharp-captureViaGenICam-url]: source/csharp/Camera/Basic/CaptureViaGenICam -[csharp-captureViaZivid-url]: source/csharp/Camera/Basic/CaptureViaZivid -[hdev-querySettingsAndParameters-url]: source/hdev/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev - -[hdev-readPLY-url]: source/hdev/Applications/Basic/FileFormats/ReadPLY.hdev -[hdev-objectMatching-url]: source/hdev/Applications/Advanced/ObjectMatching -[hdev-surfaceMatchingCreateModelFromFile-url]: source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev -[hdev-surfaceMatchingCreateModel-url]: source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev -[hdev-surfaceMatchingFindModelFromFile-url]: source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev -[hdev-surfaceMatchingFindModel-url]: source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev -[hdev-get_first_available_zivid_device-url]: source/hdev/Procedures/get_first_available_zivid_device.hdvp -[hdev-get_zivid_sample_data_dir-url]: source/hdev/Procedures/get_zivid_sample_data_dir.hdvp - - -[halcon-url]: https://www.mvtec.com/products/halcon/ - -[knowladge-base-url]: https://support.zivid.com/ -[zivid-software-installation-url]: https://support.zivid.com/latest/getting-started/software-installation.html -[zivid-sample-data-url]: https://support.zivid.com/latest/api-reference/samples/sample-data.html - -[how-to-run-a-halcon-sample-url]: https://support.zivid.com/latest/api-reference/samples/halcon.html -[halcon-samples-licence-url]: https://github.com/zivid/halcon-samples/blob/master/LICENSE +For more information about the Zivid cameras, please visit our +[Knowledge Base](https://support.zivid.com/latest). If you run into any +issues please check out +[Troubleshooting](https://support.zivid.com/latest/rst/support/troubleshooting.html). +## License +Zivid Samples are distributed under the [BSD +license](https://github.com/zivid/zivid-halcon-samples/tree/master/LICENSE). diff --git a/continuous-integration/linux/build.sh b/continuous-integration/linux/build.sh deleted file mode 100644 index 6cf858a..0000000 --- a/continuous-integration/linux/build.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -ROOT_DIR=$(realpath "$SCRIPT_DIR/../..") -SOURCE_DIR="$ROOT_DIR/source" -BUILD_ROOT_DIR="$ROOT_DIR/build/ci" - -#There's a C++11 compatibility bug in the Zivid API which makes it fail on -#older versions of Clang, such as the default Clang 3.8.2 on Ubuntu 16.04. -#An internal Zivid issue to fix this has been logged. When that issue has -#been fixed, this entire option should be removed. -if [[ "$1" == "--skip-clang" ]]; then - SKIP_CLANG=true -fi - -#TODO 16.04 default pcl is too old. See issue #43 -source /etc/os-release || exit $? -if [[ "$VERSION_ID" == "16.04" ]]; then - OS_SPECIFIC_OPTIONS="-DUSE_PCL=OFF -DUSE_EIGEN3=OFF -DUSE_OPENCV=OFF" -elif [[ "$VERSION_ID" == "18.04" ]]; then - OS_SPECIFIC_OPTIONS="-DUSE_EIGEN3=OFF -DUSE_OPENCV=OFF" -elif [[ "$VERSION_ID" == "20.04" ]]; then - EIGEN3_INCLUDE_DIR="/usr/include/eigen3" - OS_SPECIFIC_OPTIONS="" -else - echo "ERROR: found $VERSION_ID. Expected 16.04, 18.04 or 20.04" - exit 1 -fi - -function build() -{ - COMPILER=$1 - BUILD_SUBDIR=$2 - BUILD_DIR="$BUILD_ROOT_DIR/$BUILD_SUBDIR" - - echo "-----------------------------------------------" - echo " Building with $COMPILER" - echo "-----------------------------------------------" - - mkdir --parents "$BUILD_DIR" || exit $? - cd "$BUILD_DIR" || exit $? - cmake -GNinja -DCMAKE_CXX_COMPILER="$COMPILER" \ - -DWARNINGS=ON \ - -DWARNINGS_AS_ERRORS=ON \ - -DEIGEN3_INCLUDE_DIR=${EIGEN3_INCLUDE_DIR} \ - $OS_SPECIFIC_OPTIONS \ - "$SOURCE_DIR" || exit $? - cmake --build . || exit $? -} - -if [[ ! "$SKIP_CLANG" ]]; then - build clang++ clang || exit $? -fi -build g++ gcc || exit $? diff --git a/continuous-integration/linux/lint.sh b/continuous-integration/linux/lint.sh deleted file mode 100644 index 1c300da..0000000 --- a/continuous-integration/linux/lint.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -ROOT_DIR=$(realpath "$SCRIPT_DIR/../..") -SOURCE_DIR="$ROOT_DIR/source/cpp" - -cppFiles=$(find "$SOURCE_DIR" -name '*.cpp') -hFiles=$(find "$SOURCE_DIR" -name '*.h' -not -path "$SOURCE_DIR/3rd-party/*") - -if [ -z "$cppFiles" ]; then - echo Error: Cannot find C++ source files - exit 1 -fi - -echo "Checking formatting" -errorsFound=0 -for fileName in $cppFiles $hFiles; do - echo $fileName - diff $fileName <(clang-format-10 $fileName) - if [ $? -ne 0 ]; then - let "errorsFound=errorsFound+1" - else - echo "ok" - fi -done -echo -if [ $errorsFound -ne 0 ]; then - echo "ERROR: $errorsFound formatting error(s) found! See the diffs for each file printed above." - exit 1 -fi - -BUILD_DIR="$ROOT_DIR/build/ci/tidy" -mkdir --parents "$BUILD_DIR" || exit $? -cd "$BUILD_DIR" || exit $? -cmake -GNinja \ - -DCMAKE_CXX_CLANG_TIDY="/usr/bin/clang-tidy-10" \ - -DWARNINGS=ON \ - -DWARNINGS_AS_ERRORS=ON \ - -DEIGEN3_INCLUDE_DIR="/usr/include/eigen3" \ - "$SOURCE_DIR" || exit $? -cmake --build . || exit $? - -echo "All files are properly formatted!" ["$0"] diff --git a/continuous-integration/linux/platform-dependent/ubuntu-18.04/setup.sh b/continuous-integration/linux/platform-dependent/ubuntu-18.04/setup.sh deleted file mode 100644 index dd8f343..0000000 --- a/continuous-integration/linux/platform-dependent/ubuntu-18.04/setup.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -export DEBIAN_FRONTEND=noninteractive - -function apt-yes { - apt-get --assume-yes "$@" -} - -apt-yes update || exit $? -apt-yes dist-upgrade || exit $? - -apt-yes install \ - clang \ - clang-format-8 \ - clang-tidy-8 \ - cmake \ - libpcl-dev \ - wget \ - ninja-build \ - || exit $? - -function install_www_deb { - TMP_DIR=$(mktemp --tmpdir --directory install_www_deb-XXXX) || exit $? - pushd $TMP_DIR || exit $? - wget -q "$@" || exit $? - echo "Installing Zivid debian package $1" - apt-yes install --fix-broken ./*deb || exit $? - popd || exit $? - rm -r $TMP_DIR || exit $? -} - -install_www_deb https://www.zivid.com/hubfs/softwarefiles/releases/2.4.2+1a2e8cfb-1/u18/zivid-telicam-driver_3.0.1.1-3_amd64.deb || exit $? -install_www_deb https://www.zivid.com/hubfs/softwarefiles/releases/2.4.2+1a2e8cfb-1/u18/zivid_2.4.2+1a2e8cfb-1_amd64.deb || exit $? diff --git a/continuous-integration/linux/platform-dependent/ubuntu-20.04/setup.sh b/continuous-integration/linux/platform-dependent/ubuntu-20.04/setup.sh deleted file mode 100644 index 084e793..0000000 --- a/continuous-integration/linux/platform-dependent/ubuntu-20.04/setup.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -export DEBIAN_FRONTEND=noninteractive - -function apt-yes { - apt-get --assume-yes "$@" -} - -apt-yes update || exit $? -apt-yes dist-upgrade || exit $? - -apt-yes install \ - clang \ - clang-format-10 \ - clang-tidy-10 \ - cmake \ - wget \ - ninja-build \ - || exit $? - -function install_www_deb { - TMP_DIR=$(mktemp --tmpdir --directory install_www_deb-XXXX) || exit $? - pushd $TMP_DIR || exit $? - wget -q "$@" || exit $? - echo "Installing Zivid debian package $1" - apt-yes install --fix-broken ./*deb || exit $? - popd || exit $? - rm -r $TMP_DIR || exit $? -} - -install_www_deb https://www.zivid.com/hubfs/softwarefiles/releases/2.4.2+1a2e8cfb-1/u18/zivid-telicam-driver_3.0.1.1-3_amd64.deb || exit $? -install_www_deb https://www.zivid.com/hubfs/softwarefiles/releases/2.4.2+1a2e8cfb-1/u18/zivid_2.4.2+1a2e8cfb-1_amd64.deb || exit $? diff --git a/continuous-integration/linux/setup.sh b/continuous-integration/linux/setup.sh deleted file mode 100644 index 13fd100..0000000 --- a/continuous-integration/linux/setup.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# This script uses info in /etc/os-release to dispatch setup to a -# platform specific implementation - -SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" - -# Elevate permissions -if [ $EUID != 0 ]; then - sudo "$0" "$@" - exit $? -fi - -source /etc/os-release || exit $? - -osId=$ID -if [[ $VERSION_ID ]]; then - osId=$osId-$VERSION_ID -fi - -setupScript=$SCRIPT_DIR/platform-dependent/$osId/setup.sh - -if [[ -f $setupScript ]]; then - $setupScript || exit $? -else - echo $setupScript not found - echo Support for $PRETTY_NAME is not implemented - exit 1 -fi - -echo Success! [$0] diff --git a/source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev new file mode 100644 index 0000000..a36c838 --- /dev/null +++ b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev @@ -0,0 +1,148 @@ + + + + + + * + * Create a model for HALCON surface-based 3D matching algorithm from a Zivid point cloud captured by a camera. + * + * It should be used together with the SurfaceMatchingFindModel.hdev where the model created by this program is utilized for surface-based 3D matching algorithm. + * This example comes with HDR settings and other parameters which were used to create models of the following three objects: + * Twinings tea box + * Pringles can (190 g) + * plastic Coca-Cola bottle (0.5 l) + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Getting first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + import './../../../Procedures' + get_first_available_zivid_device (Devices, Device) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + + * Configuring 3D-settings + set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') + set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') + + * Setting timeout for aborting a pending grab to infinity; useful for longer exposure times + set_framegrabber_param (AcqHandle, 'grab_timeout', -1) + + * Switching to HDR mode (multiple acquisitions) + set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') + + * Resetting any previous HDR settings + set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) + + * Configuring HDR settings (Twinings tea box) + *set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + *set_framegrabber_param (AcqHandle, 'Aperture', 5.65) + *set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + *set_framegrabber_param (AcqHandle, 'Aperture', 4.0) + *set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Configuring HDR settings (Pringles can) + *set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + *set_framegrabber_param (AcqHandle, 'Aperture', 4.36) + *set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + *set_framegrabber_param (AcqHandle, 'Aperture', 2.0) + *set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Configuring HDR settings (Coca-Cola bottle) + *set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + *set_framegrabber_param (AcqHandle, 'Aperture', 6.16) + *set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + *set_framegrabber_param (AcqHandle, 'Aperture', 3.08) + *set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Configuring HDR settings (Your own object) + set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + set_framegrabber_param (AcqHandle, 'Aperture', 10.37) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 5.50) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 2.37) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Capturing frame (HDR) + grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D_Scene) + + * Extracting the following images: X, Y, Z, SNR, and RGB + select_obj (Image, X, 1) + select_obj (Image, Y, 2) + select_obj (Image, Z, 3) + select_obj (Image, Confidence, 4) + select_obj (Image, RGBA, 5) + + * Preparing graphics window + dev_close_window () + WinWidth := 1920 + WinHeight := 1200 + dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) + + * Displaying RGB image + dev_set_window (Window3D) + dev_display (RGBA) + + * Using the mouse cursor to draw a region around the object + dev_disp_text (['Position the mouse cursor on the edge of the object', 'Click and hold the left mouse button to begin drawing the ROI around the object', 'Release the left mouse button to end drawing the ROI', 'Click the right mouse button to continue running the program'], 'window', 'bottom', 'left', 'black', [], []) + draw_region (RegionDraw, Window3D) + + * Geting min and max Z values encapsulated by the created region + min_max_gray (RegionDraw, Z, 0, MinZ, MaxZ, RangeZ) + + * Segmenting Z image with Z values encapsulated by the created region + threshold (Z, RegionZ, MinZ, MaxZ) + reduce_domain (Z, RegionZ, Z) + + * Segmenting resulting Z image with the created region + reduce_domain (Z, RegionDraw, Z) + + * Transforming 3D points from X, Y, Z images to a HALCON 3D object model + xyz_to_object_model_3d (X, Y, Z, ObjectModel3D) + + * Computing normals for the HALCON 3D object model + count_seconds (T0) + sample_object_model_3d (ObjectModel3D, 'fast_compute_normals', 1, [], [], ObjectModel3D) + count_seconds (T1) + TimeForSampling := (T1 - T0) + + * Creating a HALCON surface-based matching model + count_seconds (T0) + create_surface_model (ObjectModel3D, 0.01, [], [], SFM) + count_seconds (T1) + TimeForCreating := (T1 - T0) + + * Disconnecting from Zivid Camera + close_framegrabber (AcqHandle) + + * Saving the HALCON 3D object model + write_object_model_3d (ObjectModel3D, 'om3', 'ObjectModel3D', [], [] ) + + * Saving the HALCON surface-based matching model + write_surface_model (SFM,'SFM') + + * Loading the HALCON 3D object model + read_object_model_3d ('ObjectModel3D', 'm', [], [], ObjectModel3D, Status) + + * Loading the HALCON surface-based matching model + read_surface_model ('SFM', SFM) + + * Displaying the 3D color point cloud, press the button to continue + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], [], [], [], [], [], PoseOut) + + * Closing graphics window + dev_set_window (Window3D) + dev_close_window () + + + + + + diff --git a/source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev new file mode 100644 index 0000000..71452e3 --- /dev/null +++ b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev @@ -0,0 +1,116 @@ + + + + + + * + * Create a model for HALCON surface-based 3D matching algorithm from a Zivid point cloud loaded from a ZDF file. + * + * It should be used together with the SurfaceMatchingFindModelFromFile.hdev where the model created by this program is utilized for surface-based 3D matching algorithm. + * This example comes with models of three following objects: + * Twinings tea box + * Pringles can (190 g) + * plastic Coca-Cola bottle (0.5 l) + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Preparing the graphics window + dev_close_window () + WinWidth := 1920 + WinHeight := 1200 + dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) + + * Reading a 3D point cloud of the scene + * Twinings tea box + SurfaceModelFile:= 'TwiningsTeaBox' + * Pringles can + * SurfaceModelFile:= 'PringlesCan' + * Coca-Cola bottle + * SurfaceModelFile:= 'CocaColaBottle' + + import './../../../Procedures' + get_zivid_sample_data_dir(ZividDataDir) + ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile + '/Im1.ply' + read_object_model_3d (ScenePath, 'm', ['xyz_map_width'], [1920], ObjectModel3D_Scene, Status) + + * Fixing to make the point cloud appear with colors + get_object_model_3d_params (ObjectModel3D_Scene, 'red', red) + get_object_model_3d_params (ObjectModel3D_Scene, 'green', green) + get_object_model_3d_params (ObjectModel3D_Scene, 'blue', blue) + set_object_model_3d_attrib (ObjectModel3D_Scene, '&red', 'points', red, ObjectModel3D_Scene) + set_object_model_3d_attrib (ObjectModel3D_Scene, '&green', 'points', green, ObjectModel3D_Scene) + set_object_model_3d_attrib (ObjectModel3D_Scene, '&blue', 'points', blue, ObjectModel3D_Scene) + + * Generating X, Y, and Z image + object_model_3d_to_xyz (X, Y, Z, ObjectModel3D_Scene, 'from_xyz_map', [], []) + + * Generating R, G, B, and RGB image + get_image_size (X, Width, Height) + gen_image_const (R, 'real', Width, Height) + gen_image_const (G, 'real', Width, Height) + gen_image_const (B, 'real', Width, Height) + get_domain (R, Domain) + get_region_points (Domain, Rows, Columns) + set_grayval (R, Rows, Columns, red) + set_grayval (G, Rows, Columns, green) + set_grayval (B, Rows, Columns, blue) + compose3 (R, G, B, RGB) + + * Use the mouse cursor to draw a region around the object + dev_disp_text (['Position the mouse cursor on the edge of the object', 'Click and hold the left mouse button to begin drawing the ROI around the object', 'Release the left mouse button to end drawing the ROI', 'Click the right mouse button to continue running the program'], 'window', 'bottom', 'left', 'black', [], []) + draw_region (RegionDraw, Window3D) + + * Getting min and max Z values encapsulated by the created region + min_max_gray (RegionDraw, Z, 0, MinZ, MaxZ, RangeZ) + + * Segmenting the Z image with Z values encapsulated by the created region + threshold (Z, RegionZ, MinZ, MaxZ) + reduce_domain (Z, RegionZ, Z) + + * Segmenting the resulting Z image with the created region + reduce_domain (Z, RegionDraw, Z) + + * Transforming 3D points from X, Y, Z images to a HALCON 3D object model + xyz_to_object_model_3d (X, Y, Z, ObjectModel3D) + + * Computing normals for the HALCON 3D object model + count_seconds (T0) + sample_object_model_3d (ObjectModel3D, 'fast_compute_normals', 1, [], [], ObjectModel3D) + count_seconds (T1) + TimeForSampling := (T1 - T0) + + * Creating a HALCON surface-based matching model + count_seconds (T0) + create_surface_model (ObjectModel3D, 0.01, [], [], SFM) + count_seconds (T1) + TimeForCreating := (T1 - T0) + + * Saving the HALCON 3D object model + write_object_model_3d (ObjectModel3D, 'om3', 'ObjectModel3D', [], [] ) + + * Saving the HALCON surface-based matching model + write_surface_model (SFM, 'SFM') + + * Loading the HALCON 3D object model + read_object_model_3d ('ObjectModel3D', 'm', [], [], ObjectModel3D, Status) + + * Loading the HALCON surface-based matching model + read_surface_model ('SFM', SFM) + + * Displaying the 3D color point cloud, press the button to continue + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], [], [], [], [], [], PoseOut) + + * Closing the graphics window + dev_set_window (Window3D) + dev_close_window () + + + + + + diff --git a/source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev new file mode 100644 index 0000000..24498c9 --- /dev/null +++ b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev @@ -0,0 +1,224 @@ + + + + + + * + * Utilize surface-based 3D matching on data taken with a Zivid camera. + * + * The model used for matching is created from a reference view of the object, see SurfaceMatchingCreateModel.hdev or SurfaceMatchingCreateModel.hdevFromFile. + * The model is then searched for in a newly captured 3D point cloud. This example comes with models for the three following objects: + * Twinings tea box + * Pringles can (190 g) + * plastic Coca-Cola bottle (0.5 l) + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Specify whether you want to use your own model or not + MySurfaceModelFile := false + * MySurfaceModelFile := true + + * Specify the HALCON model for surface-based 3D matching + * Existing Twinings tea box model + SurfaceModelFile := 'TwiningsTeaBox' + * Existing Pringles can model + * SurfaceModelFile := 'PringlesCan' + * Existing Coca-Cola bottle model + * SurfaceModelFile := 'CocaColaBottle' + * Your own model created with the SurfaceMatchingCreateModel.hdev + * SurfaceModelFile := '' + + import './../../../Procedures' + get_zivid_sample_data_dir(ZividDataDir) + ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile + + * Getting first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + get_first_available_zivid_device (Devices, Device) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + + * Configuring 3D-settings + set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') + set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') + + * Seting the timeout for aborting a pending grab to infinity; useful for longer exposure times + set_framegrabber_param (AcqHandle, 'grab_timeout', -1) + + * Switching to HDR mode (multiple acquisitions) + set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') + + * Reseting any previous HDR settings + set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) + + * Configuring HDR settings + * Twinings tea box + if (SurfaceModelFile = 'TwiningsTeaBox') + set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + set_framegrabber_param (AcqHandle, 'Aperture', 5.50) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 4.00) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + endif + * Pringles can + if (SurfaceModelFile = 'PringlesCan') + set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + set_framegrabber_param (AcqHandle, 'Aperture', 4.36) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 2.00) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + endif + * Coca-Cola bottle + if (SurfaceModelFile = 'CocaColaBottle') + set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + set_framegrabber_param (AcqHandle, 'Aperture', 6.16) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 3.08) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + endif + * Your own model created with the SurfaceMatchingCreateModel.hdev + if (SurfaceModelFile = '') + set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + set_framegrabber_param (AcqHandle, 'Aperture', 16.00) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 5.50) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 2.37) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + endif + + * Loading the HALCON model for surface-based 3D matching + if (MySurfaceModelFile) + SFMFilename := 'SFM' + else + tuple_add(ScenePath,'/SFM', SFMFilename) + endif + read_surface_model (SFMFilename, SFM) + + * Loading the HALCON 3D object model (used for visualization purpose) + if (MySurfaceModelFile) + ObjectModel3DFilename := 'ObjectModel3D' + else + tuple_add(ScenePath,'/ObjectModel3D', ObjectModel3DFilename) + endif + read_object_model_3d (ObjectModel3DFilename, 'm', [], [], ObjectModel3D, Status) + + + * Preparing the graphics window + dev_close_window () + WinWidth := 1920 + WinHeight := 1200 + dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) + + for Index := 1 to 10 by 1 + + * Capturing frame (HDR) + grab_data (Image, Region, Contours, AcqHandle, ObjectModel3DSceneRaw) + + * Extracting the following images: X, Y, Z, SNR, and RGB + select_obj (Image, X, 1) + select_obj (Image, Y, 2) + select_obj (Image, Z, 3) + select_obj (Image, Confidence, 4) + select_obj (Image, RGBA, 5) + + * Converting to HALCON 3D object model + xyz_to_object_model_3d (X, Y, Z, ObjectModel3DScene) + + * Computing 3D object model normals, which is necessary for surface-based 3D matching + count_seconds (T0) + sample_object_model_3d (ObjectModel3DScene, 'fast_compute_normals', 1, [], [], ObjectModel3DScene) + count_seconds (T1) + TimeForSampling := (T1 - T0) + + * Object detection and pose estimation based on surface-based 3D matching + count_seconds (T0) + * RelSamplingDistance - point cloud downsampling (0 = no downsampling) + * Twinings tea box + if (SurfaceModelFile = 'TwiningsTeaBox') + RelSamplingDistance := 0.01 + endif + * Pringles can + if (SurfaceModelFile = 'PringlesCan') + RelSamplingDistance := 0.03 + endif + * Coca-Cola bottle + if (SurfaceModelFile = 'CocaColaBottle') + RelSamplingDistance := 0.003 + endif + * Your own model created with the SurfaceMatchingCreateModel.hdev + if (SurfaceModelFile = '') + RelSamplingDistance := 0.01 + endif + * KeyPointFraction - additional downsampling for the detection (1 = all points used) + KeyPointFraction := 1 + * MinScore - minimum score for the detection + MinScore := 0.4 + find_surface_model (SFM, ObjectModel3DScene, RelSamplingDistance, KeyPointFraction, MinScore, 'true', ['num_matches', 'scene_normal_computation'], [10, 'mls'], Pose, Score, SurfaceMatchingResultID) + count_seconds (T1) + TimeForMatching := (T1 - T0) + + if (Score!=[]) + + * Preparing result(s) + if (Score[0] < MinScore) + continue + endif + CPose := Pose[0:6] + rigid_trans_object_model_3d (ObjectModel3D, CPose, ObjectModel3DResult) + + * Visualizing matching scene and key points + Message := 'Original scene points (white)' + Message[1] := 'Sampled scene points (cyan)' + Message[2] := 'Key points (yellow)' + get_surface_matching_result (SurfaceMatchingResultID, 'sampled_scene', [], SampledScene) + get_surface_matching_result (SurfaceMatchingResultID, 'key_points', [], KeyPoints) + dev_clear_window () + Message[3] := ' ' + Message[4] := 'Rotate: Left button' + Message[5] := 'Zoom: Shift + left button' + Message[6] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, [ObjectModel3DScene,SampledScene,KeyPoints], [], [], ['color_' + [0,1,2],'point_size_' + [0,1,2]], ['gray','cyan','yellow',1.0,3.0,5.0], Message, [], Message, PoseOut) + + * Visualizing result(s) + Message1 := 'Scene: ' + Index + Message1[1] := 'Found ' + |ObjectModel3DResult| + ' object(s) in ' + TimeForMatching$'.3' + ' ms' + ScoreString := sum(Score$'.2f' + ' / ') + Message1[2] := 'Score(s): ' + ScoreString{0:strlen(ScoreString) - 4} + NumResult := |ObjectModel3DResult| + tuple_gen_const (NumResult, 'green', Colors) + tuple_gen_const (NumResult, 'circle', Shapes) + tuple_gen_const (NumResult, 3, Radii) + Indices := [1:NumResult] + dev_clear_window () + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, [ObjectModel3DScene,ObjectModel3DResult], [], [], ['color_' + [0,Indices],'point_size_0'], ['gray',Colors,1.0], Message1, [], Instructions, PoseOut) + + * Clear: Free result(s) + clear_object_model_3d (ObjectModel3DScene) + clear_object_model_3d (ObjectModel3DResult) + clear_object_model_3d (SampledScene) + clear_object_model_3d (KeyPoints) + clear_surface_matching_result (SurfaceMatchingResultID) + + endif + + endfor + + * Disconnecting from Zivid Camera + close_framegrabber (AcqHandle) + + * Closing graphics window + dev_set_window (Window3D) + dev_close_window () + + + + + + diff --git a/source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev new file mode 100644 index 0000000..bac74a9 --- /dev/null +++ b/source/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev @@ -0,0 +1,173 @@ + + + + + + * + * Utilize surface-based 3D matching on data taken with a Zivid camera. + * + * The model used for matching is created from a reference view of the object, see SurfaceMatchingCreateModelFromFile.hdev. The model is then searched for in a newly + * captured 3D point cloud. This example comes with models for the three following objects: + * Twinings tea box + * Pringles can (190 g) + * plastic Coca-Cola bottle (0.5 l) + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Preparing graphics window + dev_close_window () + WinWidth := 1920 + WinHeight := 1200 + dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) + + * Specify the object for surface-based 3D matching + * Existing Twinings tea box model + SurfaceModelFile := 'TwiningsTeaBox' + * Existing Pringles can model + * SurfaceModelFile := 'PringlesCan' + * Existing Coca-Cola bottle model + * SurfaceModelFile := 'CocaColaBottle' + + import './../../../Procedures' + get_zivid_sample_data_dir(ZividDataDir) + ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile + + * Specify whether you want to use your own model created with the SurfaceMatchingCreateModelFromFile.hdev + MySurfaceModelFile := false + * MySurfaceModelFile := true + + * Loading the HALCON model for surface-based 3D matching + if (MySurfaceModelFile) + SFMFileName := 'SFM' + else + tuple_add (ScenePath, '/SFM', SFMFileName) + endif + read_surface_model (SFMFileName, SFM) + + * Loading the HALCON 3D object model (used for visualization purpose) + if (MySurfaceModelFile) + ObjectModel3DFile := 'ObjectModel3D' + else + tuple_add (ScenePath, '/ObjectModel3D', ObjectModel3DFile) + endif + read_object_model_3d (ObjectModel3DFile, 'm', [], [], ObjectModel3D, Status) + + for Index := 1 to 5 by 1 + + tuple_add (ScenePath, '/im', SceneFilename) + tuple_add (SceneFilename, Index, SceneFilename) + tuple_add (SceneFilename, '.ply', SceneFilename) + read_object_model_3d (SceneFilename, 'm', ['xyz_map_width'], [1920], ObjectModel3DScene, Status) + + * Fixing to make the point cloud appear with colors + get_object_model_3d_params (ObjectModel3DScene, 'red', red) + get_object_model_3d_params (ObjectModel3DScene, 'green', green) + get_object_model_3d_params (ObjectModel3DScene, 'blue', blue) + set_object_model_3d_attrib (ObjectModel3DScene, '&red', 'points', red, ObjectModel3DScene) + set_object_model_3d_attrib (ObjectModel3DScene, '&green', 'points', green, ObjectModel3DScene) + set_object_model_3d_attrib (ObjectModel3DScene, '&blue', 'points', blue, ObjectModel3DScene) + + * Generating X, Y, and Z image + object_model_3d_to_xyz ( X, Y, Z, ObjectModel3DScene, 'from_xyz_map', [], []) + + * Generating R, G, B, and RGB image + get_image_size (X, Width, Height) + gen_image_const (R, 'real', Width, Height) + gen_image_const (G, 'real', Width, Height) + gen_image_const (B, 'real', Width, Height) + get_domain (R, Domain) + get_region_points (Domain, Rows, Columns) + set_grayval (R, Rows, Columns, red) + set_grayval (G, Rows, Columns, green) + set_grayval (B, Rows, Columns, blue) + compose3 (R, G, B, RGB) + + * Computing 3D object model normals, which is necessary for surface-based 3D matching + count_seconds (T0) + sample_object_model_3d (ObjectModel3DScene, 'fast_compute_normals', 1, [], [], ObjectModel3DScene) + count_seconds (T1) + TimeForSampling := (T1 - T0) + + * Object detection and pose estimation based on surface-based 3D matching + count_seconds (T0) + * RelSamplingDistance - point cloud downsampling (0 = no downsampling) + * Twinings tea box + if (SurfaceModelFile = 'TwiningsTeaBox') + RelSamplingDistance := 0.01 + endif + * Pringles can + if (SurfaceModelFile = 'PringlesCan') + RelSamplingDistance := 0.03 + endif + * Coca-Cola bottle + if (SurfaceModelFile = 'CocaColaBottle') + RelSamplingDistance := 0.003 + endif + * KeyPointFraction - additional downsampling for the detection (1 = all points used) + KeyPointFraction := 1 + * MinScore - minimum score for the detection + MinScore := 0.4 + find_surface_model (SFM, ObjectModel3DScene, RelSamplingDistance, KeyPointFraction, MinScore, 'true', ['num_matches', 'scene_normal_computation'], [10, 'mls'], Pose, Score, SurfaceMatchingResultID) + count_seconds (T1) + TimeForMatching := (T1 - T0) + + if (Score!=[]) + + * Preparing result(s) + if (Score[0] < MinScore) + continue + endif + CPose := Pose[0:6] + rigid_trans_object_model_3d (ObjectModel3D, CPose, ObjectModel3DResult) + + * Visualizing matching scene and key points + Message := 'Original scene points (white)' + Message[1] := 'Sampled scene points (cyan)' + Message[2] := 'Key points (yellow)' + get_surface_matching_result (SurfaceMatchingResultID, 'sampled_scene', [], SampledScene) + get_surface_matching_result (SurfaceMatchingResultID, 'key_points', [], KeyPoints) + dev_clear_window () + Message[3] := ' ' + Message[4] := 'Rotate: Left button' + Message[5] := 'Zoom: Shift + left button' + Message[6] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, [ObjectModel3DScene,SampledScene,KeyPoints], [], [], ['color_' + [0,1,2],'point_size_' + [0,1,2]], ['gray','cyan','yellow',1.0,3.0,5.0], Message, [], Message, PoseOut) + + * Visualizing result(s) + Message1 := 'Scene: ' + Index + Message1[1] := 'Found ' + |ObjectModel3DResult| + ' object(s) in ' + TimeForMatching$'.3' + ' ms' + ScoreString := sum(Score$'.2f' + ' / ') + Message1[2] := 'Score(s): ' + ScoreString{0:strlen(ScoreString) - 4} + NumResult := |ObjectModel3DResult| + tuple_gen_const (NumResult, 'green', Colors) + tuple_gen_const (NumResult, 'circle', Shapes) + tuple_gen_const (NumResult, 3, Radii) + Indices := [1:NumResult] + dev_clear_window () + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, [ObjectModel3DScene,ObjectModel3DResult], [], [], ['color_' + [0,Indices],'point_size_0'], ['gray',Colors,1.0], Message1, [], Instructions, PoseOut) + + * Clear: Free result(s) + clear_object_model_3d (ObjectModel3DScene) + clear_object_model_3d (ObjectModel3DResult) + clear_object_model_3d (SampledScene) + clear_object_model_3d (KeyPoints) + clear_surface_matching_result (SurfaceMatchingResultID) + + endif + + endfor + + * Closing graphics window + dev_set_window (Window3D) + dev_close_window () + + + + + + diff --git a/source/Applications/Basic/FileFormats/ReadPLY.hdev b/source/Applications/Basic/FileFormats/ReadPLY.hdev new file mode 100644 index 0000000..92b4faa --- /dev/null +++ b/source/Applications/Basic/FileFormats/ReadPLY.hdev @@ -0,0 +1,74 @@ + + + + + + * + * Import and display a Zivid point cloud from a PLY file. + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. + * + + * Preparing graphics windows + dev_close_window () + WinWidth := 960 + WinHeight := 800 + dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window2D) + dev_open_window (0, WinWidth, WinWidth, WinHeight, 'blue', Window3D) + + * Reading PCD point cloud from file + import './../../../Procedures' + get_zivid_sample_data_dir(ZividDataDir) + PointCloudFile := ZividDataDir + '/Zivid3D.ply' + read_object_model_3d (PointCloudFile, 'mm', ['xyz_map_width'], [1920], ObjectModel3D, Status) + + * Fixing to make the point cloud appear with colors + get_object_model_3d_params (ObjectModel3D, 'red', red) + get_object_model_3d_params (ObjectModel3D, 'green', green) + get_object_model_3d_params (ObjectModel3D, 'blue', blue) + set_object_model_3d_attrib (ObjectModel3D, '&red', 'points', red, ObjectModel3D) + set_object_model_3d_attrib (ObjectModel3D, '&green', 'points', green, ObjectModel3D) + set_object_model_3d_attrib (ObjectModel3D, '&blue', 'points', blue, ObjectModel3D) + + * Generating X, Y, and Z image + object_model_3d_to_xyz (X, Y, Z, ObjectModel3D, 'from_xyz_map', [], []) + + * Generating R, G, B, and RGB image + get_image_size (X, Width, Height) + gen_image_const (R, 'real', Width, Height) + gen_image_const (G, 'real', Width, Height) + gen_image_const (B, 'real', Width, Height) + get_domain (R, Domain) + get_region_points (Domain, Rows, Columns) + set_grayval (R, Rows, Columns, red) + set_grayval (G, Rows, Columns, green) + set_grayval (B, Rows, Columns, blue) + compose3 (R, G, B, RGB) + + * Displaying RGB image + dev_set_window (Window2D) + dev_display (RGB) + + * Visualizing current 3D object model + dev_set_window (Window3D) + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&red','&green','&blue'], Instructions, [], '', PoseOut) + + * Clearing 3D object model from memory + clear_object_model_3d (ObjectModel3D) + + * Closing graphics windows + dev_set_window (Window2D) + dev_close_window () + dev_set_window (Window3D) + dev_close_window () + + + + + + + + diff --git a/source/Camera/Advanced/CaptureHDRLoop.hdev b/source/Camera/Advanced/CaptureHDRLoop.hdev new file mode 100644 index 0000000..6a4dd5f --- /dev/null +++ b/source/Camera/Advanced/CaptureHDRLoop.hdev @@ -0,0 +1,153 @@ + + + + + + * + * Capture HDR images from the camera in a loop (while actively changing some HDR settings). + * + * Each HDR image is used to generate a HALCON ObjectModel3D which is then visualized. + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Preparing the graphics window + dev_close_window () + WinWidth := 960 + WinHeight := 800 + dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) + + *Getting first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + import './../../Procedures' + get_first_available_zivid_device (Devices, Device) + get_zivid_sample_data_dir(ZividDataDir) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + get_framegrabber_param (AcqHandle, 'DeviceModelName', DeviceModelName) + tuple_substr (DeviceModelName, 0, 8, DeviceModelFolder) + + * Configuring 3D-settings + set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') + set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') + + * Seting the timeout for aborting a pending grab to infinity; useful for longer exposure times + set_framegrabber_param (AcqHandle, 'grab_timeout', -1) + + * Switching to HDR mode (multiple acquisitions) + set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') + + for Index := 0 to 2 by 1 + + * Reseting any previous HDR settings + set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) + + * Configuring HDR settings for frames + set_settings (AcqHandle, ZividDataDir + '/SettingsJson/' + DeviceModelFolder +'/Settings0'+(Index+1)+'.json') + + * Capturing frame (HDR) + grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) + + * Displaying 3D color point cloud, press the button to continue + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) + + endfor + + * Disconnecting from Zivid Camera + close_framegrabber (AcqHandle) + + * Closing graphics window + dev_close_window () + + + + + + + + + + + + + + + read_dict(path, [], [], json_dict) + + get_dict_tuple (json_dict, 'Settings', Settings) + get_dict_tuple (Settings, 'Acquisitions', Acquisitions) + get_dict_param (Acquisitions, 'keys', [], AllKeys) + + * Getting acquisition settings + for Index := 0 to |AllKeys| - 1 by 1 + get_dict_tuple (Acquisitions, Index, AcquisitionIndex) + get_dict_tuple (AcquisitionIndex, 'Acquisition', Acquisition) + get_dict_tuple (Acquisition, 'ExposureTime', ExposureTime) + set_framegrabber_param (AcqHandle, 'ExposureTime', ExposureTime) + get_dict_tuple (Acquisition, 'Aperture', Aperture) + set_framegrabber_param (AcqHandle, 'Aperture', Aperture) + get_dict_tuple (Acquisition, 'Brightness', Brightness) + set_framegrabber_param (AcqHandle, 'Brightness', Brightness) + get_dict_tuple (Acquisition, 'Gain', Gain) + set_framegrabber_param (AcqHandle, 'Gain', Gain) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + endfor + + * Getting filter settings + get_dict_tuple (Settings, 'Processing', Processing) + get_dict_tuple (Processing, 'Filters', Filters) + + get_dict_tuple (Filters, 'Noise', Noise) + get_dict_tuple (Noise, 'Removal', Removal) + get_dict_tuple (Removal, 'Enabled', Enabled) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalEnabled', Enabled) + get_dict_tuple (Removal, 'Threshold', Threshold) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalThreshold', Threshold) + + get_dict_tuple (Filters, 'Smoothing', Smoothing) + get_dict_tuple (Smoothing, 'Gaussian', Gaussian) + get_dict_tuple (Gaussian, 'Enabled', Enabled) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianEnabled', Enabled) + get_dict_tuple (Gaussian, 'Sigma', Sigma) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianSigma', Sigma) + + get_dict_tuple (Filters, 'Outlier', Outlier) + get_dict_tuple (Outlier, 'Removal', Removal) + get_dict_tuple (Removal, 'Enabled', Enabled) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalEnabled', Enabled) + get_dict_tuple (Removal, 'Threshold', Threshold) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalThreshold', Threshold) + + get_dict_tuple (Filters, 'Reflection', Reflection) + get_dict_tuple (Reflection, 'Removal', Removal) + get_dict_tuple (Removal, 'Enabled', Enabled) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersReflectionRemovalEnabled', Enabled) + + + * Getting color balance settings + get_dict_tuple (Processing, 'Color', Color) + get_dict_tuple (Color, 'Balance', Balance) + get_dict_tuple (Balance, 'Blue', Blue) + set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceBlue', Blue) + get_dict_tuple (Balance, 'Green', Green) + set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceGreen', Green) + get_dict_tuple (Balance, 'Red', Red) + set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceRed', Red) + + + return () + + + + + + + + + diff --git a/source/Camera/Basic/Capture.hdev b/source/Camera/Basic/Capture.hdev new file mode 100644 index 0000000..e8a29d0 --- /dev/null +++ b/source/Camera/Basic/Capture.hdev @@ -0,0 +1,78 @@ + + + + + + * + * Capture a 3D color point cloud from the camera and use it to generate a HALCON ObjectModel3D which is then visualized. + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Preparing graphics windows + dev_close_window () + WinWidth := 960 + WinHeight := 800 + dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) + dev_open_window (0, WinWidth, WinWidth, WinHeight, 'black', Window2D) + + *Getting first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + import './../../Procedures' + get_first_available_zivid_device (Devices, Device) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + + * Configuring 3D-settings + set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') + set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') + + * Switching to single Frame mode + set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'SingleFrame') + + * Configuring settings + set_framegrabber_param (AcqHandle, 'Aperture', 5.66) + set_framegrabber_param (AcqHandle, 'ExposureTime', 6500) + set_framegrabber_param (AcqHandle, 'Gain', 1) + set_framegrabber_param (AcqHandle, 'Brightness', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalThreshold', 5) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianSigma', 1.5) + + * Capturing frame + grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) + + * Extracting the following images: X, Y, Z, SNR, and RGB + select_obj (Image, X, 1) + select_obj (Image, Y, 2) + select_obj (Image, Z, 3) + select_obj (Image, Confidence, 4) + select_obj (Image, RGBA, 5) + + * Displaying 2D color image + dev_set_window (Window2D) + dev_display (RGBA) + + * Displaying 3D color point cloud, press the button to continue + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) + + * Disconnecting from Zivid Camera + close_framegrabber (AcqHandle) + + * Closing graphics windows + dev_set_window (Window2D) + dev_close_window () + dev_set_window (Window3D) + dev_close_window () + + + + + + diff --git a/source/Camera/Basic/CaptureHDR.hdev b/source/Camera/Basic/CaptureHDR.hdev new file mode 100644 index 0000000..5d88440 --- /dev/null +++ b/source/Camera/Basic/CaptureHDR.hdev @@ -0,0 +1,83 @@ + + + + + + * + * Capture an HDR image from the camera and use it to generate a HALCON ObjectModel3D which is then visualized. + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Preparing graphics windows + dev_close_window () + WinWidth := 960 + WinHeight := 800 + dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) + dev_open_window (0, WinWidth, WinWidth, WinHeight, 'black', Window2D) + + *Getting first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + import './../../Procedures' + get_first_available_zivid_device (Devices, Device) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + + * Configuring 3D-settings + set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') + set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') + + * Seting the timeout for aborting a pending grab to infinity + set_framegrabber_param (AcqHandle, 'grab_timeout', -1) + + * Switching to the HDR mode (multiple acquisitions) + set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') + + * Reseting any previous HDR settings + set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) + + * Configuring HDR settings + set_framegrabber_param (AcqHandle, 'Aperture', 11.31) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 5.66) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + set_framegrabber_param (AcqHandle, 'Aperture', 2.83) + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Capturing frame (HDR) + grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) + + * Extracting the following images: X, Y, Z, SNR, and RGB + select_obj (Image, X, 1) + select_obj (Image, Y, 2) + select_obj (Image, Z, 3) + select_obj (Image, Confidence, 4) + select_obj (Image, RGBA, 5) + + * Displaying 2D color image + dev_set_window (Window2D) + dev_display (RGBA) + + * Displaying 3D color point cloud, press the button to continue + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + dev_set_window (Window3D) + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) + + * Disconnecting from the Zivid Camera + close_framegrabber (AcqHandle) + + * Closing graphics windows + dev_set_window (Window2D) + dev_close_window () + dev_set_window (Window3D) + dev_close_window () + + + + + + diff --git a/source/Camera/Basic/CaptureHDRCompleteSettings.hdev b/source/Camera/Basic/CaptureHDRCompleteSettings.hdev new file mode 100644 index 0000000..3ef7c9a --- /dev/null +++ b/source/Camera/Basic/CaptureHDRCompleteSettings.hdev @@ -0,0 +1,104 @@ + + + + + + * + * Capture an HDR image from the Zivid camera with fully configured settings for each frame. + * + * In general, taking an HDR image is a lot simpler than this as the default settings work for most scenes. The purpose of this example is to demonstrate how to + * configure all the settings. + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Preparing graphics window + dev_close_window () + WinWidth := 960 + WinHeight := 800 + dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) + + *Get first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + import './../../Procedures' + get_first_available_zivid_device (Devices, Device) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + + * Configuring 3D-settings + set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') + set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') + + * Seting timeout for aborting a pending grab to infinity; useful for longer exposure times + set_framegrabber_param (AcqHandle, 'grab_timeout', -1) + + * Switching to HDR mode (multiple acquisitions) + set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') + + * Resetting any previous HDR settings + set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) + + * Configuring HDR settings for the first image + set_framegrabber_param (AcqHandle, 'Aperture', 8) + set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + set_framegrabber_param (AcqHandle, 'Brightness', 1) + set_framegrabber_param (AcqHandle, 'Gain', 1) + + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Configuring HDR settings for the second image + set_framegrabber_param (AcqHandle, 'Aperture', 4.00) + set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) + set_framegrabber_param (AcqHandle, 'Brightness', 1) + set_framegrabber_param (AcqHandle, 'Gain', 1) + + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Configuring HDR settings for the third image + set_framegrabber_param (AcqHandle, 'Aperture', 4.00) + set_framegrabber_param (AcqHandle, 'ExposureTime', 40000) + set_framegrabber_param (AcqHandle, 'Brightness', 1) + set_framegrabber_param (AcqHandle, 'Gain', 1) + + set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) + + * Setting global settings + set_framegrabber_param (AcqHandle, 'ExperimentalEngine', 'phase') + set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianSigma', 1.5) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalThreshold', 7.0) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalThreshold', 5.0) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersReflectionRemovalEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionCorrectionEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionCorrectionStrength', 0.4) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionRemovalEnabled', 1) + set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionRemovalThreshold', 0.5) + set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceBlue', 1) + set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceGreen', 1) + set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceRed', 1) + set_framegrabber_param (AcqHandle, 'ProcessingColorExperimentalToneMappingEnabled', 'always') + + * Capturing frame (HDR) + grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) + + * Displaying 3D color point cloud, press the button to continue + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) + + * Disconnecting from Zivid Camera + close_framegrabber (AcqHandle) + + * Closing graphics window + dev_close_window () + + + + + + diff --git a/source/Camera/Basic/CaptureSavePLY.hdev b/source/Camera/Basic/CaptureSavePLY.hdev new file mode 100644 index 0000000..71aab96 --- /dev/null +++ b/source/Camera/Basic/CaptureSavePLY.hdev @@ -0,0 +1,89 @@ + + + + + + * + * Capture a 3D color point cloud from the camera and save it to a PLY file format. + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + * Preparing graphics windows + dev_close_window () + WinWidth := 960 + WinHeight := 800 + dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) + + *Getting first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + import './../../Procedures' + get_first_available_zivid_device (Devices, Device) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + + * Configuring 3D-settings + set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') + set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') + + * Switching to single acquisition mode + set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'SingleFrame') + + * Configuring settings + set_framegrabber_param (AcqHandle, 'Aperture', 5.66) + set_framegrabber_param (AcqHandle, 'ExposureTime', 6500) + set_framegrabber_param (AcqHandle, 'Gain', 1) + set_framegrabber_param (AcqHandle, 'Brightness', 1) + + * Capturing frame + grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) + + * Extracting the following images: X, Y, Z, SNR, and RGB + select_obj (Image, X, 1) + select_obj (Image, Y, 2) + select_obj (Image, Z, 3) + select_obj (Image, Confidence, 4) + select_obj (Image, RGB, 5) + + * Transforming 3D points from X, Y, Z images to a HALCON 3D object model + xyz_to_object_model_3d (X, Y, Z, ObjectModel3D) + + * Adding RGB data to the 3D point cloud + decompose3 (RGB, R, G, B) + + get_domain (R, Domain) + get_region_points (Domain, Rows, Columns) + get_grayval (R, Rows, Columns, GrayvalR) + set_object_model_3d_attrib_mod (ObjectModel3D, 'red', 'points', GrayvalR) + + get_domain (G, Domain) + get_region_points (Domain, Rows, Columns) + get_grayval (G, Rows, Columns, GrayvalG) + set_object_model_3d_attrib_mod (ObjectModel3D, 'green', 'points', GrayvalG) + + get_domain (B, Domain) + get_region_points (Domain, Rows, Columns) + get_grayval (B, Rows, Columns, GrayvalB) + set_object_model_3d_attrib_mod (ObjectModel3D, 'blue', 'points', GrayvalB) + + * Displaying 3D color point cloud, press the button to continue + dev_set_window (Window3D) + Instructions[0] := 'Rotate: Left button' + Instructions[1] := 'Zoom: Shift + left button' + Instructions[2] := 'Move: Ctrl + left button' + visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['red','green','blue'], '', [], '', PoseOut) + + * Writing a 3D object model in a PLY file format + write_object_model_3d (ObjectModel3D, 'ply', 'Zivid3DPLY.ply', ['invert_normals'], ['true']) + + * Disconnecting from Zivid Camera + close_framegrabber (AcqHandle) + + + + + + + diff --git a/source/Camera/Basic/ConnectToSerialNumberCamera.hdev b/source/Camera/Basic/ConnectToSerialNumberCamera.hdev new file mode 100644 index 0000000..ba1db90 --- /dev/null +++ b/source/Camera/Basic/ConnectToSerialNumberCamera.hdev @@ -0,0 +1,34 @@ + + + + + + * + * Connect to a specific Zivid 3D camera based on its serial number. + * + * Note: Verify that the serial number set is the serial number of the camera you are using. + * + * Please note that you first need to install Zivid Software and correctly set the environment + * variables. After this, you can access the camera with the HALCON GenICamTL interface. + * + + * Connecting to Zivid camera with the following serial number + CameraSerial := 'Zivid_DEV_19242553' + open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', CameraSerial, 0, 0, AcqHandle) + + * Disconnecting from Zivid Camera + close_framegrabber (AcqHandle) + + * Querying information about the connected image acquisition devices to find your device serial number + info_framegrabber ('GenICamTL', 'device', Information, Device) + + * Extracting serial number from your device + tuple_split (Device[0], '|' , Substrings) + tuple_strlen (Substrings[2], StrLength) + tuple_substr (Substrings[2],13,StrLength-2,CameraSerial) + + + + + + diff --git a/source/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev b/source/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev new file mode 100644 index 0000000..5caf232 --- /dev/null +++ b/source/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev @@ -0,0 +1,104 @@ + + + + + + * + * Query information about the image acquisition interface and selected specific parameters of Zivid camera. + * + * Please note that you first need to install Zivid Software and correctly set the environment variables. After this, you can access the camera with the HALCON + * GenICamTL interface. + * + + *Querying information about the image acquisition interface + info_framegrabber ('GenICamTL', 'general', Information_general, ValueList_general) + info_framegrabber ('GenICamTL', 'defaults', Information_defaults, ValueList_defaults) + info_framegrabber ('GenICamTL', 'info_boards', Information_info_boards, ValueList_info_boards) + + info_framegrabber ('GenICamTL', 'parameters', Information_parameters, ValueList_parameters) + info_framegrabber ('GenICamTL', 'parameters_readonly', Information_parameters_readonly, ValueList_parameters_readonly) + info_framegrabber ('GenICamTL', 'parameters_writeonly', Information_parameters_writeonly, ValueList_parameters_writeonly) + + *Getting first available Zivid device + info_framegrabber ('GenICamTL','device', Information, Devices) + import './../../Procedures' + get_first_available_zivid_device (Devices, Device) + + * Connecting to Zivid camera + open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) + + * Querying information about specific parameters of Zivid camera + get_framegrabber_param (AcqHandle, 'available_callback_types', Value_available_callback_types) + get_framegrabber_param (AcqHandle, 'available_param_names', Value_available_param_names) + + get_framegrabber_param (AcqHandle, 'DeviceSerialNumber', Value_DeviceSerialNumber) + get_framegrabber_param (AcqHandle, 'DeviceVendorName', Value_DeviceVendorName) + get_framegrabber_param (AcqHandle, 'DeviceModelName', Value_DeviceModelName) + + get_framegrabber_param (AcqHandle, 'WidthMax', Value_WidthMax) + get_framegrabber_param (AcqHandle, 'HeightMax', Value_HeightMax) + get_framegrabber_param (AcqHandle, 'Width', Value_Widt) + get_framegrabber_param (AcqHandle, 'Height', Value_Height) + get_framegrabber_param (AcqHandle, 'PixelSize', Value_PixelSize) + get_framegrabber_param (AcqHandle, 'PayloadSize', Value_PayloadSize) + + get_framegrabber_param (AcqHandle, '[System]TLID', Value_SystemTLID) + get_framegrabber_param (AcqHandle, '[System]TLVendorName', Value_SystemTLVendorName) + get_framegrabber_param (AcqHandle, '[System]TLModelName', Value_SystemTLModelName) + get_framegrabber_param (AcqHandle, '[System]TLVersion', Value_SystemTLVersion) + get_framegrabber_param (AcqHandle, '[System]TLFileName', Value_SystemTLFileName) + get_framegrabber_param (AcqHandle, '[System]TLPath', Value_SystemTLPath) + get_framegrabber_param (AcqHandle, '[System]TLType', Value_SystemTLType) + get_framegrabber_param (AcqHandle, '[System]GenTLVersionMajor', Value_SystemGenTLVersionMajor) + get_framegrabber_param (AcqHandle, '[System]GenTLVersionMinor', Value_SystemGenTLVersionMinor) + get_framegrabber_param (AcqHandle, '[System]GenTLSFNCVersionMajor', Value_SystemGenTLSFNCVersionMajor) + get_framegrabber_param (AcqHandle, '[System]GenTLSFNCVersionMinor', Value_SystemGenTLSFNCVersionMinor) + get_framegrabber_param (AcqHandle, '[System]GenTLSFNCVersionSubMinor', Value_SystemGenTLSFNCVersionSubMinor) + get_framegrabber_param (AcqHandle, '[System]InterfaceSelector', Value_SystemInterfaceSelector) + get_framegrabber_param (AcqHandle, '[System]InterfaceID', Value_SystemInterfaceID) + + get_framegrabber_param (AcqHandle, '[Interface]InterfaceID', Value_InterfaceID) + get_framegrabber_param (AcqHandle, '[Interface]InterfaceType', Value_InterfaceType) + get_framegrabber_param (AcqHandle, '[Interface]DeviceSelector', Value_InterfaceDeviceSelector) + get_framegrabber_param (AcqHandle, '[Interface]DeviceID', Value_InterfaceDeviceID) + get_framegrabber_param (AcqHandle, '[Interface]DeviceVendorName', Value_InterfaceDeviceVendorName) + get_framegrabber_param (AcqHandle, '[Interface]DeviceModelName', Value_InterfaceDeviceModelName) + get_framegrabber_param (AcqHandle, '[Interface]DeviceAccessStatus', Value_InterfaceDeviceAccessStatus) + get_framegrabber_param (AcqHandle, '[Interface]DeviceSerialNumber', Value_InterfaceDeviceSerialNumber) + + get_framegrabber_param (AcqHandle, '[Device]DeviceID', Value_DeviceID) + get_framegrabber_param (AcqHandle, '[Device]DeviceSerialNumber', Value_DeviceDeviceSerialNumber) + get_framegrabber_param (AcqHandle, '[Device]DeviceVendorName', Value_DeviceDeviceVendorName) + get_framegrabber_param (AcqHandle, '[Device]DeviceModelName', Value_DeviceDeviceModelName) + get_framegrabber_param (AcqHandle, '[Device]DeviceVersion', Value_DeviceVersion) + get_framegrabber_param (AcqHandle, '[Device]DeviceManufacturerInfo', Value_DeviceManufacturerInfo) + get_framegrabber_param (AcqHandle, '[Device]DeviceType', Value_DeviceType) + get_framegrabber_param (AcqHandle, '[Device]DeviceAccessStatus', Value_DeviceAccessStatus) + get_framegrabber_param (AcqHandle, '[Device]StreamSelector', Value_DeviceStreamSelector) + get_framegrabber_param (AcqHandle, '[Device]StreamID', Value_DeviceStreamID) + + get_framegrabber_param (AcqHandle, '[Stream]StreamID', Value_StreamID) + get_framegrabber_param (AcqHandle, '[Stream]StreamType', Value_StreamType) + get_framegrabber_param (AcqHandle, '[Stream]StreamAnnouncedBufferCount', Value_StreamAnnouncedBufferCount) + get_framegrabber_param (AcqHandle, '[Stream]StreamBufferHandlingMode', Value_StreamBufferHandlingMode) + get_framegrabber_param (AcqHandle, '[Stream]StreamAnnounceBufferMinimum', Value_StreamAnnounceBufferMinimum) + get_framegrabber_param (AcqHandle, '[Stream]StreamThreadPriority', Value_StreamThreadPriority) + get_framegrabber_param (AcqHandle, '[Stream]StreamAuxiliaryBufferCount', Value_StreamAuxiliaryBufferCount) + + get_framegrabber_param (AcqHandle, 'image_available', Value_image_available) + get_framegrabber_param (AcqHandle, 'image_width', Value_image_width) + get_framegrabber_param (AcqHandle, 'image_height', Value_image_height) + get_framegrabber_param (AcqHandle, 'num_buffers', Value_num_buffers) + get_framegrabber_param (AcqHandle, 'tl_displayname', Value_tl_displayname) + get_framegrabber_param (AcqHandle, 'tl_filename', Value_tl_filename) + get_framegrabber_param (AcqHandle, 'tl_id', Value_tl_id) + get_framegrabber_param (AcqHandle, 'tl_model', Value_tl_model) + get_framegrabber_param (AcqHandle, 'tl_pathname', Value_tl_pathname) + get_framegrabber_param (AcqHandle, 'num_buffers_await_delivery', Value_num_buffers_await_delivery) + get_framegrabber_param (AcqHandle, 'num_buffers_underrun', Value_num_buffers_underrun) + + + + + + diff --git a/source/Procedures/get_first_available_zivid_device.hdvp b/source/Procedures/get_first_available_zivid_device.hdvp new file mode 100644 index 0000000..e3d4695 --- /dev/null +++ b/source/Procedures/get_first_available_zivid_device.hdvp @@ -0,0 +1,36 @@ + + + + + + + + + + + + + * + * Get the first Zivid device from the input tuple of devices. + * + * The input tuple 'Devices' is typically returned by info_framegrabber function as follows: + * 'info_framegrabber ('GenICamTL','device', Information, Devices)' + * + + for i := 0 to |Devices| by 1 + SplitDevices := split(split(Devices[i], '|'), ':') + if(SplitDevices[2]{0:4} == 'Zivid') + Device := SplitDevices[2]{0:strlen(SplitDevices[2])-2} + break + endif + endfor + return () + + + + + + + + + diff --git a/source/Procedures/get_zivid_sample_data_dir.hdvp b/source/Procedures/get_zivid_sample_data_dir.hdvp new file mode 100644 index 0000000..6470762 --- /dev/null +++ b/source/Procedures/get_zivid_sample_data_dir.hdvp @@ -0,0 +1,34 @@ + + + + + + + + + + * + * Get the path of ZIVID DATA depending on your operating system. + * + * This is used to get data, e.g. camera settings, for some halcon samples. + * + + get_system ('operating_system', OSName) + + if (OSName{0:2} == 'Win') + ZIVID_SAMPLE_DATA_DIR := environment('ProgramData') + '/Zivid' + else + ZIVID_SAMPLE_DATA_DIR := '/usr/share/Zivid/data' + endif + return () + + + + + + + + + + + diff --git a/source/python/convert_intrinsics_opencv_to_halcon.py b/source/SampleUtils/convert_intrinsics_opencv_to_halcon.py similarity index 98% rename from source/python/convert_intrinsics_opencv_to_halcon.py rename to source/SampleUtils/convert_intrinsics_opencv_to_halcon.py index 10640f1..d816626 100644 --- a/source/python/convert_intrinsics_opencv_to_halcon.py +++ b/source/SampleUtils/convert_intrinsics_opencv_to_halcon.py @@ -97,18 +97,18 @@ def undistorted_pixels(self, pixels: NDArray) -> NDArray: x = (pixels[:, :, 0] - self.cx) * self.sx y = (pixels[:, :, 1] - self.cy) * self.sy - r2 = x ** 2 + y ** 2 - r4 = r2 ** 2 + r2 = x**2 + y**2 + r4 = r2**2 r6 = r2 * r4 x_u = ( x * (1 + self.poly[0] * r2 + self.poly[1] * r4 + self.poly[2] * r6) - + self.poly[3] * (r2 + 2 * x ** 2) + + self.poly[3] * (r2 + 2 * x**2) + 2 * self.poly[4] * x * y ) y_u = ( y * (1 + self.poly[0] * r2 + self.poly[1] * r4 + self.poly[2] * r6) - + self.poly[4] * (r2 + 2 * y ** 2) + + self.poly[4] * (r2 + 2 * y**2) + 2 * self.poly[3] * x * y ) diff --git a/source/SampleUtils/yaml_settings_to_json.py b/source/SampleUtils/yaml_settings_to_json.py new file mode 100644 index 0000000..097d5ea --- /dev/null +++ b/source/SampleUtils/yaml_settings_to_json.py @@ -0,0 +1,31 @@ +""" Script to convert from .yaml/.yml to .json +""" + +import argparse +import json +from pathlib import Path + +import yaml + + +def _args() -> argparse.Namespace: + parser = argparse.ArgumentParser() + parser.add_argument("--directory", type=Path, required=True) + return parser.parse_args() + + +def _main() -> None: + input_directory = _args().directory + if not input_directory.is_dir(): + raise Exception(f"{input_directory} is not a directory") + output_directory = Path(f"{input_directory}_json") + output_directory.mkdir(exist_ok=True) + for x in list(_args().directory.glob("*.yml")): + output_file = output_directory / f"{x.stem}.json" + with open(x, "r", encoding="utf-8") as yaml_in, open(output_file, "w", encoding="utf-8") as json_out: + yaml_object = yaml.safe_load(yaml_in) + json.dump(yaml_object, json_out, indent=2) + + +if __name__ == "__main__": + _main() diff --git a/source/cpp/CMakeLists.txt b/source/cpp/CMakeLists.txt deleted file mode 100644 index 1e914ba..0000000 --- a/source/cpp/CMakeLists.txt +++ /dev/null @@ -1,47 +0,0 @@ -cmake_minimum_required(VERSION 3.5 FATAL_ERROR) - -project(CppHalconSamples) - -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) -include(CompilerOptions) - -set(ZIVID_VERSION 2.1.0) - -set(SAMPLES - Camera/Basic/CaptureViaGenICam - Camera/Basic/CaptureViaZivid) - -set(Halcon_DEPENDING CaptureViaGenICam CaptureViaZivid) - -if(DEFINED ENV{HALCONROOT} AND NOT $ENV{HALCONROOT} STREQUAL "") - message("Using HALCONROOT " $ENV{HALCONROOT}) - STRING(REGEX REPLACE "\\\\" "/" HALCONROOT $ENV{HALCONROOT}) -endif() - -find_package(Halcon) -find_package(HDevEngine) -find_package(Zivid ${ZIVID_VERSION} COMPONENTS Core REQUIRED) - -message(STATUS "All samples: ${SAMPLES}") - -foreach(SAMPLE ${SAMPLES}) - get_filename_component(SAMPLE_NAME ${SAMPLE} NAME) - - add_executable(${SAMPLE_NAME} ${SAMPLE}/${SAMPLE_NAME}.cpp) - - target_link_libraries(${SAMPLE_NAME} Zivid::Core) - - if(${SAMPLE_NAME} IN_LIST Halcon_DEPENDING) - target_link_libraries( - ${SAMPLE_NAME} - ${HALCON_LIBS} - ${HDEVENGINE_LIBS}) - target_include_directories( - ${SAMPLE_NAME} - PUBLIC - ${HALCON_INC_DIRS} - ${HDEVENGINE_INC_DIRS} - include - ) - endif() -endforeach() \ No newline at end of file diff --git a/source/cpp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cpp b/source/cpp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cpp deleted file mode 100644 index a6b9d28..0000000 --- a/source/cpp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* -This example shows how to capture and save a point cloud, with colors, using GenICam interface and Halcon C++ SDK. -*/ - -#include -#include - -#include -#include - -void savePointCloud(const HalconCpp::HObjectModel3D &model, const std::string &fileName) -{ - model.WriteObjectModel3d(HalconCpp::HString{ "ply" }, - HalconCpp::HString{ fileName.c_str() }, - HalconCpp::HString{ "invert_normals" }, - HalconCpp::HString{ "false" }); -} - -void setColorsInObjectModel3D(HalconCpp::HObjectModel3D &objectModel3D, - const HalconCpp::HImage &RGB, - const HalconCpp::HImage &zReduced) -{ - const HalconCpp::HRegion domain = zReduced.GetDomain(); - HalconCpp::HTuple rows, cols; - domain.GetRegionPoints(&rows, &cols); - - objectModel3D.SetObjectModel3dAttribMod(HalconCpp::HTuple("red"), - "points", - RGB.AccessChannel(1).GetGrayval(rows, cols)); - objectModel3D.SetObjectModel3dAttribMod(HalconCpp::HTuple("green"), - "points", - RGB.AccessChannel(2).GetGrayval(rows, cols)); - objectModel3D.SetObjectModel3dAttribMod(HalconCpp::HTuple("blue"), - "points", - RGB.AccessChannel(3).GetGrayval(rows, cols)); -} - -HalconCpp::HString getFirstAvailableZividDevice() -{ - auto devices = HalconCpp::HTuple(); - auto information = HalconCpp::HTuple(); - HalconCpp::InfoFramegrabber("GenICamTL", "device", &information, &devices); - - auto zividDevices = devices.TupleRegexpSelect("Zivid"); - if(zividDevices.Length() == 0) - { - throw std::runtime_error("No Zivid devices found. Please check your setup."); - } - return zividDevices[0]; -} - -int main() -{ - try - { - std::cout << "Connecting to camera" << std::endl; - const auto zividDevice = getFirstAvailableZividDevice(); - auto framegrabber = HalconCpp::HTuple(); - HalconCpp::OpenFramegrabber("GenICamTL", - 1, - 1, - 0, - 0, - 0, - 0, - "progressive", - -1, - "default", - -1, - "false", - "default", - zividDevice, - 0, - 0, - &framegrabber); - - std::cout << "Configuring settings" << std::endl; - HalconCpp::SetFramegrabberParam(framegrabber, "create_objectmodel3d", "enable"); - HalconCpp::SetFramegrabberParam(framegrabber, "add_objectmodel3d_overlay_attrib", "enable"); - HalconCpp::SetFramegrabberParam(framegrabber, "AcquisitionMode", "SingleFrame"); - - HalconCpp::SetFramegrabberParam(framegrabber, "Aperture", 5.66); - HalconCpp::SetFramegrabberParam(framegrabber, "ExposureTime", 8333); - HalconCpp::SetFramegrabberParam(framegrabber, "Gain", 2); - HalconCpp::SetFramegrabberParam(framegrabber, "Brightness", 1.0); - HalconCpp::SetFramegrabberParam(framegrabber, "ProcessingFiltersOutlierRemovalEnabled", 1); - HalconCpp::SetFramegrabberParam(framegrabber, "ProcessingFiltersOutlierRemovalThreshold", 5); - HalconCpp::SetFramegrabberParam(framegrabber, "ProcessingFiltersSmoothingGaussianEnabled", 1); - HalconCpp::SetFramegrabberParam(framegrabber, "ProcessingFiltersSmoothingGaussianSigma", 1.5); - - std::cout << "Capturing frame" << std::endl; - auto region = HalconCpp::HRegion(); - auto contours = HalconCpp::HXLDCont(); - auto data = HalconCpp::HTuple(); - auto frame = HalconCpp::HImage(); - HalconCpp::GrabData(&frame, ®ion, &contours, framegrabber, &data); - - const auto x = frame.SelectObj(1); - const auto y = frame.SelectObj(2); - const auto z = frame.SelectObj(3); - const auto snr = frame.SelectObj(4); - const auto rgb = frame.SelectObj(5); - - std::cout << "Removing invalid 3D points (zeroes)" << std::endl; - auto reducedRegion = HalconCpp::HObject(); - auto zReduced = HalconCpp::HImage(); - HalconCpp::Threshold(z, &reducedRegion, 0.0001, 10000); - HalconCpp::ReduceDomain(z, reducedRegion, &zReduced); - - std::cout << "Constructing ObjectModel3D based on XYZ data" << std::endl; - HalconCpp::HObjectModel3D objectModel3D(x, y, zReduced); - - std::cout << "Adding RGB to ObjectModel3D" << std::endl; - setColorsInObjectModel3D(objectModel3D, rgb, zReduced); - - const auto pointCloudFile = "Zivid3D.ply"; - std::cout << "Saving point cloud to file: " << pointCloudFile << std::endl; - savePointCloud(objectModel3D, pointCloudFile); - } - catch(const std::exception &e) - { - std::cerr << "Error: " << Zivid::toString(e) << std::endl; - return EXIT_FAILURE; - } -} diff --git a/source/cpp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cpp b/source/cpp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cpp deleted file mode 100644 index 6075302..0000000 --- a/source/cpp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* -This example shows how to capture a point cloud, with colors, using Zivid SDK, transform it to a Halcon point cloud and save it using Halcon C++ SDK. -*/ - -#include -#include - -#include -#include -#include - -void savePointCloud(const HalconCpp::HObjectModel3D &model, const std::string &fileName) -{ - model.WriteObjectModel3d(HalconCpp::HString{ "ply" }, - HalconCpp::HString{ fileName.c_str() }, - HalconCpp::HString{ "invert_normals" }, - HalconCpp::HString{ "false" }); -} - -HalconCpp::HObjectModel3D zividToHalconPointCloud(const Zivid::PointCloud &pointCloud) -{ - const auto width = pointCloud.width(); - const auto height = pointCloud.height(); - - const auto pointsXYZ = pointCloud.copyPointsXYZ(); - const auto colorsRGBA = pointCloud.copyColorsRGBA(); - const auto normalsXYZ = pointCloud.copyNormalsXYZ(); - - int numberOfValidPoints = std::count_if(pointsXYZ.data(), - pointsXYZ.data() + pointsXYZ.size(), - [](const Zivid::PointXYZ &point) { return (!point.isNaN()); }); - - // Initializing HTuples which are later filled with data from the Zivid point cloud. - // tupleXYZMapping is of shape [width, height, rows[], cols[]], and is used for creating xyz mapping. - // See more at: https://www.mvtec.com/doc/halcon/13/en/set_object_model_3d_attrib.html - - HalconCpp::HTuple tuplePointsX, tuplePointsY, tuplePointsZ, tupleNormalsX, tupleNormalsY, tupleNormalsZ, tupleColorsR, - tupleColorsB, tupleColorsG, tupleRow, tupleCol, tupleXYZMapping; - - tuplePointsX[numberOfValidPoints - 1] = (float)0.0; - tuplePointsY[numberOfValidPoints - 1] = (float)0.0; - tuplePointsZ[numberOfValidPoints - 1] = (float)0.0; - tupleNormalsX[numberOfValidPoints - 1] = (float)0.0; - tupleNormalsY[numberOfValidPoints - 1] = (float)0.0; - tupleNormalsZ[numberOfValidPoints - 1] = (float)0.0; - tupleColorsR[numberOfValidPoints - 1] = (Hlong)0; - tupleColorsG[numberOfValidPoints - 1] = (Hlong)0; - tupleColorsB[numberOfValidPoints - 1] = (Hlong)0; - - tupleXYZMapping[2 * numberOfValidPoints + 2 - 1] = (Hlong)0; - tupleXYZMapping[0] = (Hlong)width; - tupleXYZMapping[1] = (Hlong)height; - - int validPointIndex = 0; - - for(size_t i = 0; i < height; ++i) - { - for(size_t j = 0; j < width; ++j) - { - const auto &point = pointsXYZ(i, j); - const auto &normal = normalsXYZ(i, j); - const auto &color = colorsRGBA(i, j); - - if(!isnan(point.x)) - { - tuplePointsX.DArr()[validPointIndex] = point.x; - tuplePointsY.DArr()[validPointIndex] = point.y; - tuplePointsZ.DArr()[validPointIndex] = point.z; - tupleColorsR.LArr()[validPointIndex] = color.r; - tupleColorsG.LArr()[validPointIndex] = color.g; - tupleColorsB.LArr()[validPointIndex] = color.b; - tupleXYZMapping.LArr()[2 + validPointIndex] = i; - tupleXYZMapping.LArr()[2 + numberOfValidPoints + validPointIndex] = j; - - if(!isnan(normal.x)) - { - tupleNormalsX.DArr()[validPointIndex] = normal.x; - tupleNormalsY.DArr()[validPointIndex] = normal.y; - tupleNormalsZ.DArr()[validPointIndex] = normal.z; - } - - validPointIndex++; - } - } - } - - std::cout << "Constructing ObjectModel3D based on XYZ data" << std::endl; - HalconCpp::HObjectModel3D objectModel3D(tuplePointsX, tuplePointsY, tuplePointsZ); - - std::cout << "Mapping ObjectModel3D data" << std::endl; - HalconCpp::SetObjectModel3dAttribMod(objectModel3D, "xyz_mapping", "object", tupleXYZMapping); - - std::cout << "Adding normals to ObjectModel3D" << std::endl; - HalconCpp::HTuple normalsAttribNames, normalsAttribValues; - normalsAttribNames.Append("point_normal_x"); - normalsAttribNames.Append("point_normal_y"); - normalsAttribNames.Append("point_normal_z"); - - normalsAttribValues.Append(tupleNormalsX); - normalsAttribValues.Append(tupleNormalsY); - normalsAttribValues.Append(tupleNormalsZ); - - HalconCpp::SetObjectModel3dAttribMod(objectModel3D, normalsAttribNames, "points", normalsAttribValues); - - std::cout << "Adding RGB to ObjectModel3D" << std::endl; - HalconCpp::SetObjectModel3dAttribMod(objectModel3D, "red", "points", tupleColorsR); - HalconCpp::SetObjectModel3dAttribMod(objectModel3D, "green", "points", tupleColorsG); - HalconCpp::SetObjectModel3dAttribMod(objectModel3D, "blue", "points", tupleColorsB); - - return objectModel3D; -} - -int main() -{ - try - { - std::cout << "Connecting to camera" << std::endl; - Zivid::Application zivid; - auto camera = zivid.connectCamera(); - - std::cout << "Configuring settings" << std::endl; - const auto settings = - Zivid::Settings{ Zivid::Settings::Acquisitions{ Zivid::Settings::Acquisition{ - Zivid::Settings::Acquisition::Aperture{ 5.66 }, - Zivid::Settings::Acquisition::ExposureTime{ std::chrono::microseconds{ 8333 } } } }, - Zivid::Settings::Processing::Filters::Outlier::Removal::Enabled::yes, - Zivid::Settings::Processing::Filters::Outlier::Removal::Threshold{ 5 }, - Zivid::Settings::Processing::Filters::Smoothing::Gaussian::Enabled::yes, - Zivid::Settings::Processing::Filters::Smoothing::Gaussian::Sigma{ 1.5 } }; - - std::cout << "Capturing frame" << std::endl; - const auto frame = camera.capture(settings); - const auto zividPointCloud = frame.pointCloud(); - - std::cout << "Converting to Halcon point cloud" << std::endl; - const auto halconPointCloud = zividToHalconPointCloud(zividPointCloud); - - const auto pointCloudFile = "Zivid3D.ply"; - std::cout << "Saving point cloud to file: " << pointCloudFile << std::endl; - savePointCloud(halconPointCloud, pointCloudFile); - } - - catch(HalconCpp::HException &except) - { - std::cerr << "Error: " << except.ErrorMessage() << std::endl; - return EXIT_FAILURE; - } - - catch(const std::exception &e) - { - std::cerr << "Error: " << Zivid::toString(e) << std::endl; - return EXIT_FAILURE; - } -} diff --git a/source/cpp/README.md b/source/cpp/README.md deleted file mode 100644 index 43e5ab9..0000000 --- a/source/cpp/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# C++ samples for Halcon - -This folder contains C++ code samples using Halcon C++ SDK in combination with Zivid SDK or GenICam interface. - -## Prerequisites -* Install Zivid SDK -* Install Halcon - -## Compilation -``` -cd ./source/cpp -mkdir build -cd build -cmake .. -make -``` \ No newline at end of file diff --git a/source/cpp/cmake/CompilerOptions.cmake b/source/cpp/cmake/CompilerOptions.cmake deleted file mode 100644 index 1021eef..0000000 --- a/source/cpp/cmake/CompilerOptions.cmake +++ /dev/null @@ -1,79 +0,0 @@ -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_EXTENSIONS OFF) - -option(WARNINGS "Enable compiler warnings" OFF) - -if(WARNINGS) - option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" OFF) -endif() - -if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if(WARNINGS) - if(WARNINGS_AS_ERRORS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") - endif() - - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything") - set(WARNINGS_THAT_SHOULD_BE_IGNORED # WHY it is ok to ignore - c++98-compat # Code base should be modern - c++98-compat-pedantic # Code base should be modern - newline-eof # Legacy warning, no benefit when using modern compilers and editors - sign-conversion # Happens a lot in these samples, would complicate them too much to handle manually - sign-compare # Happens a lot in these samples, would complicate them too much to handle manually - shorten-64-to-32 # Narrowing conversions: Too strict and noisy for this code base - padded # The type and order of elements caused the compiler to add padding to the end of a struct - conversion # Implicit conversion loses integer precision (signed to unsigned). Expected to happen a lot in these samples, would complicate them too much to handle manually - ) - foreach(WARNING ${WARNINGS_THAT_SHOULD_BE_IGNORED}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-${WARNING}") - endforeach() - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - if(WARNINGS) - if(WARNINGS_AS_ERRORS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") - endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra") - set(WARNINGS_THAT_SHOULD_BE_IGNORED # WHY it is ok to ignore - #TODO, see the Clang options - ) - foreach(WARNING ${WARNINGS_THAT_SHOULD_BE_IGNORED}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-${WARNING}") - endforeach() - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -w") - endif() -elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") - if(WARNINGS) - if(WARNINGS_AS_ERRORS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") - endif() - - set(WARNINGS_THAT_SHOULD_BE_IGNORED # WHY it is ok to ignore - 4702 # Got unreachable warnings from external, even though they are generallly ignored by /experimental:external - 4710 # If the compiler decides to not inline a function, that's their decision - 4711 # If the compiler decides to inline a function, that's their decision - 4571 # Just a non-interesting informational warning about msvc changing behaviour in 7.1 - 4267 # Conversion: Happens a lot in these samples, would complicate them too much to handle manually - 4365 # Conversion: Happens a lot in these samples, would complicate them too much to handle manually - 4388 # Signed/unsigned comparison: Happens a lot in these samples, would complicate them too much to handle manually - 5045 # Compiler will insert Spectre mitigation for memory load if /Qspectre switch specified - # This warning is purely informational - 4244 # Narrowing conversions: Too strict and noisy for this code base - 4242 # Narrowing conversions: Too strict and noisy for this code base - 4820 # The type and order of elements caused the compiler to add padding to the end of a struct - ) - foreach(WARNING ${WARNINGS_THAT_SHOULD_BE_IGNORED}) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd${WARNING}") - endforeach() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /experimental:external /external:anglebrackets /external:W0") - else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /w") - endif() - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /ignore:4099") -else() - message(WARNING "Unknown compiler, not able to set compiler options for ${CMAKE_CXX_COMPILER_ID}") -endif() diff --git a/source/cpp/cmake/FindHDevEngine.cmake b/source/cpp/cmake/FindHDevEngine.cmake deleted file mode 100644 index 65d5f83..0000000 --- a/source/cpp/cmake/FindHDevEngine.cmake +++ /dev/null @@ -1,64 +0,0 @@ -if(NOT DEFINED HALCONARCH) - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(HALCONARCH x64-macosx) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(HALCONARCH x64-linux) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - set(HALCONARCH x64-win64) - else() - set(HALCONARCH x86sse2-win32) - endif() - else() - message( FATAL_ERROR "Unsupported system." ) - endif() -endif() - -if(HALCONROOT) - - if(EXISTS "${HALCONROOT}/lib") - set(HALCON_EXT_LIB_DIR ${HALCONROOT}/lib/${HALCONARCH}) - else() - if(EXISTS "${HALCONROOT}/libd") - set(HALCON_EXT_LIB_DIR ${HALCONROOT}/libd/${HALCONARCH}) - else() - if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - message( FATAL_ERROR "HALCONROOT environment variable is not set or HALCON is not installed.") - endif() - endif() - endif() - - if(EXISTS "${HALCONROOT}/include") - set(HDEVENGINE_INC_DIRS ${HALCONROOT}/include) - else() - if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - message( FATAL_ERROR "HALCONROOT environment variable is not set or HALCON is not installed.") - endif() - endif() - -endif() - -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if(HALCON_EXT_LIB_DIR) - set(HDEVENGINE_LIBS "-F ${HALCON_EXT_LIB_DIR} -framework HDevEngineCpp") - set(HDEVENGINE_LIBS_XL "-F ${HALCON_EXT_LIB_DIR} -framework HDevEngineCppxl") - else() - set(HDEVENGINE_LIBS "-framework HDevEngineCpp") - set(HDEVENGINE_LIBS_XL "-framework HDevEngineCppxl") - endif() -else() - if(${WIN32}) - set(PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX}) - set(SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX}) - else() - set(PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) - set(SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) - endif() - if(HALCON_EXT_LIB_DIR) - set(HDEVENGINE_LIBS ${HALCON_EXT_LIB_DIR}/${PREFIX}hdevenginecpp${SUFFIX}) - set(HDEVENGINE_LIBS_XL ${HALCON_EXT_LIB_DIR}/${PREFIX}hdevenginecppxl${SUFFIX}) - else() - set(HDEVENGINE_LIBS ${PREFIX}hdevenginecpp${SUFFIX}) - set(HDEVENGINE_LIBS_XL ${PREFIX}hdevenginecppxl${SUFFIX}) - endif() -endif() \ No newline at end of file diff --git a/source/cpp/cmake/FindHalcon.cmake b/source/cpp/cmake/FindHalcon.cmake deleted file mode 100644 index f4ba5c5..0000000 --- a/source/cpp/cmake/FindHalcon.cmake +++ /dev/null @@ -1,84 +0,0 @@ -if(NOT DEFINED HALCONARCH) - if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - set(HALCONARCH x64-macosx) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(HALCONARCH x64-linux) - elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8") - set(HALCONARCH x64-win64) - else() - set(HALCONARCH x86sse2-win32) - endif() - else() - message( FATAL_ERROR "Unsupported system." ) - endif() -endif() - -if(HALCONROOT) - - if(EXISTS "${HALCONROOT}/lib") - set(HALCON_EXT_LIB_DIR ${HALCONROOT}/lib/${HALCONARCH}) - else() - if(EXISTS "${HALCONROOT}/libd") - set(HALCON_EXT_LIB_DIR ${HALCONROOT}/libd/${HALCONARCH}) - else() - if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - message( FATAL_ERROR "HALCONROOT environment variable is not set or HALCON is not installed.") - endif() - endif() - endif() - - if(EXISTS "${HALCONROOT}/include") - set(HALCON_INC_DIRS ${HALCONROOT}/include) - else() - if(${CMAKE_SYSTEM_NAME} MATCHES "Windows") - message( FATAL_ERROR "HALCONROOT environment variable is not set or HALCON is not installed.") - endif() - endif() - -endif() - -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if(HALCON_EXT_LIB_DIR) - set(HALCON_LIBS "-F ${HALCON_EXT_LIB_DIR} -framework HALCON" - "-F ${HALCON_EXT_LIB_DIR} -framework HALCONC" - "-F ${HALCON_EXT_LIB_DIR} -framework HALCONCpp") - - set(HALCONXL_LIBS "-F ${HALCON_EXT_LIB_DIR} -framework HALCONxl" - "-F ${HALCON_EXT_LIB_DIR} -framework HALCONCxl" - "-F ${HALCON_EXT_LIB_DIR} -framework HALCONCppxl") - else() - set(HALCON_LIBS "-framework HALCON" - "-framework HALCONC" - "-framework HALCONCpp") - - set(HALCONXL_LIBS "-framework HALCONxl" - "-framework HALCONCxl" - "-framework HALCONCppxl") - endif() -else() - if(${WIN32}) - set(PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX}) - set(SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX}) - else() - set(PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) - set(SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) - endif() - if(HALCON_EXT_LIB_DIR) - set(HALCON_LIBS ${HALCON_EXT_LIB_DIR}/${PREFIX}halcon${SUFFIX} - ${HALCON_EXT_LIB_DIR}/${PREFIX}halconc${SUFFIX} - ${HALCON_EXT_LIB_DIR}/${PREFIX}halconcpp${SUFFIX}) - - set(HALCON_LIBS_XL ${HALCON_EXT_LIB_DIR}/${PREFIX}halconxl${SUFFIX} - ${HALCON_EXT_LIB_DIR}/${PREFIX}halconcxl${SUFFIX} - ${HALCON_EXT_LIB_DIR}/${PREFIX}halconcppxl${SUFFIX}) - else() - set(HALCON_LIBS ${PREFIX}halcon${SUFFIX} - ${PREFIX}halconc${SUFFIX} - ${PREFIX}halconcpp${SUFFIX}) - - set(HALCON_LIBS_XL ${PREFIX}halconxl${SUFFIX} - ${PREFIX}halconcxl${SUFFIX} - ${PREFIX}halconcppxl${SUFFIX}) - endif() -endif() \ No newline at end of file diff --git a/source/csharp/Camera/Basic/CaptureViaGenICam/App.config b/source/csharp/Camera/Basic/CaptureViaGenICam/App.config deleted file mode 100644 index 7eb8d24..0000000 --- a/source/csharp/Camera/Basic/CaptureViaGenICam/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cs b/source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cs deleted file mode 100644 index 2a5acb4..0000000 --- a/source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; - -class Program -{ - static void Main() - { - try - { - Console.WriteLine("Connecting to camera"); - var zividDevice = GetFirstAvailableZividDevice(); - var framegrabber = new HalconDotNet.HTuple(); - HalconDotNet.HOperatorSet.OpenFramegrabber("GenICamTL", - 1, - 1, - 0, - 0, - 0, - 0, - "progressive", - -1, - "default", - -1, - "false", - "default", - zividDevice, - 0, - 0, - out framegrabber); - - Console.WriteLine("Configuring 3D-settings"); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "create_objectmodel3d", "enable"); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "add_objectmodel3d_overlay_attrib", "enable"); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "AcquisitionMode", "SingleFrame"); - - Console.WriteLine("Configuring camera settings"); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "Aperture", 5.66); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "ExposureTime", 8333); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "Gain", 1); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "ProcessingFiltersOutlierRemovalEnabled", 1); - HalconDotNet.HOperatorSet.SetFramegrabberParam(framegrabber, "ProcessingFiltersOutlierRemovalThreshold", 5); - - Console.WriteLine("Capturing frame"); - var frame = new HalconDotNet.HObject(); - var region = new HalconDotNet.HObject(); - var contours = new HalconDotNet.HObject(); - var data = new HalconDotNet.HTuple(); - HalconDotNet.HOperatorSet.GrabData(out frame, out region, out contours, framegrabber, out data); - - var x = frame.SelectObj(1); - var y = frame.SelectObj(2); - var z = frame.SelectObj(3); - var snr = frame.SelectObj(4); - var rgb = frame.SelectObj(5); - - Console.WriteLine("Removing invalid 3D points (zeroes)"); - var reducedRegion = new HalconDotNet.HObject(); - var zReduced = new HalconDotNet.HObject(); - HalconDotNet.HOperatorSet.Threshold(z, out reducedRegion, 0.0001, 10000); - HalconDotNet.HOperatorSet.ReduceDomain(z, reducedRegion, out zReduced); - - Console.WriteLine("Constructing ObjetModel3D based on XYZ data"); - var objectModel3D = new HalconDotNet.HTuple(); - HalconDotNet.HOperatorSet.XyzToObjectModel3d(x, y, zReduced, out objectModel3D); - - Console.WriteLine("Adding RGB to ObjectModel3D"); - SetColorsInObjectModel3D(objectModel3D, rgb, zReduced); - - string pointCloudFile = "Zivid3D.ply"; - Console.WriteLine("Saving point cloud to file: " + pointCloudFile); - SaveHalconPointCloud(objectModel3D, pointCloudFile); - } - catch (Exception ex) - { - Console.WriteLine("Error: " + ex.Message); - Environment.ExitCode = 1; - } - } - - private static void SaveHalconPointCloud(HalconDotNet.HTuple model, string fileName) - { - HalconDotNet.HOperatorSet.WriteObjectModel3d(model, "ply", fileName, "invert_normals", "false"); - } - - private static void SetColorsInObjectModel3D(HalconDotNet.HTuple objectModel3D, HalconDotNet.HObject RGB, HalconDotNet.HObject zReduced) - { - var domain = new HalconDotNet.HObject(); - var rows = new HalconDotNet.HTuple(); - var cols = new HalconDotNet.HTuple(); - - HalconDotNet.HOperatorSet.GetDomain(zReduced, out domain); - HalconDotNet.HOperatorSet.GetRegionPoints(domain, out rows, out cols); - - var objectRed = new HalconDotNet.HObject(); - var objectGreen = new HalconDotNet.HObject(); - var objectBlue = new HalconDotNet.HObject(); - - HalconDotNet.HOperatorSet.AccessChannel(RGB, out objectRed, 1); - HalconDotNet.HOperatorSet.AccessChannel(RGB, out objectGreen, 1); - HalconDotNet.HOperatorSet.AccessChannel(RGB, out objectBlue, 1); - - var tupleRed = new HalconDotNet.HTuple(); - var tupleGreen = new HalconDotNet.HTuple(); - var tupleBlue = new HalconDotNet.HTuple(); - - HalconDotNet.HOperatorSet.GetGrayval(objectRed, rows, cols, out tupleRed); - HalconDotNet.HOperatorSet.GetGrayval(objectGreen, rows, cols, out tupleGreen); - HalconDotNet.HOperatorSet.GetGrayval(objectBlue, rows, cols, out tupleBlue); - - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, "red", "points", tupleRed); - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, "green", "points", tupleGreen); - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, "blue", "points", tupleBlue); - } - - private static HalconDotNet.HTuple GetFirstAvailableZividDevice() - { - var devices = new HalconDotNet.HTuple(); - var information = new HalconDotNet.HTuple(); - HalconDotNet.HOperatorSet.InfoFramegrabber("GenICamTL", "device", out information, out devices); - - var zividDevices = devices.TupleRegexpSelect("Zivid"); - if (zividDevices.Length == 0) - { - throw new System.InvalidOperationException("No Zivid devices found. Please check your setup."); - } - return zividDevices[0]; - } -} diff --git a/source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.csproj b/source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.csproj deleted file mode 100644 index 7afe889..0000000 --- a/source/csharp/Camera/Basic/CaptureViaGenICam/CaptureViaGenICam.csproj +++ /dev/null @@ -1,77 +0,0 @@ - - - - - Debug - AnyCPU - {232B04D3-A809-4FE2-AF9B-4EB9761F66AB} - Exe - Properties - CaptureViaGenICam - CaptureViaGenICam - v4.6.1 - 512 - true - - - true - ..\$(Configuration)\$(Platform) - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - true - true - true - - - ..\$(Configuration)\$(Platform) - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - true - true - - - - - - - - - - - - - $(HALCONROOT)\bin\dotnet35\halcondotnet.dll - - - $(HALCONROOT)\bin\dotnet35\hdevenginedotnet.dll - - - $(ZIVID_INSTALL_FOLDER)\bin\ZividCoreNET.dll - - - $(ZIVID_INSTALL_FOLDER)\bin_debug\ZividCoreNET.dll - - - - - - - - - - - - \ No newline at end of file diff --git a/source/csharp/Camera/Basic/CaptureViaGenICam/Properties/AssemblyInfo.cs b/source/csharp/Camera/Basic/CaptureViaGenICam/Properties/AssemblyInfo.cs deleted file mode 100644 index e756876..0000000 --- a/source/csharp/Camera/Basic/CaptureViaGenICam/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitleAttribute("CaptureViaGenICam")] -[assembly: AssemblyDescriptionAttribute("")] -[assembly: AssemblyConfigurationAttribute("")] -[assembly: AssemblyCompanyAttribute("")] -[assembly: AssemblyProductAttribute("CaptureViaGenICam")] -[assembly: AssemblyCopyrightAttribute("Copyright 2015-2020 (C) Zivid AS")] -[assembly: AssemblyTrademarkAttribute("")] -[assembly: AssemblyCultureAttribute("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("232b04d3-a809-4fe2-af9b-4eb9761f66ab")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/source/csharp/Camera/Basic/CaptureViaZivid/App.config b/source/csharp/Camera/Basic/CaptureViaZivid/App.config deleted file mode 100644 index 88fa402..0000000 --- a/source/csharp/Camera/Basic/CaptureViaZivid/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cs b/source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cs deleted file mode 100644 index 0e2630b..0000000 --- a/source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.cs +++ /dev/null @@ -1,154 +0,0 @@ -using System; -using Duration = Zivid.NET.Duration; - -class Program -{ - static void Main() - { - try - { - var zivid = new Zivid.NET.Application(); - - Console.WriteLine("Connecting to camera"); - var camera = zivid.ConnectCamera(); - - Console.WriteLine("Configuring settings"); - var settings = new Zivid.NET.Settings - { - Acquisitions = { new Zivid.NET.Settings.Acquisition{ Aperture = 5.66, - ExposureTime = Duration.FromMicroseconds(10000) } }, - Processing = { Filters = { Outlier = { Removal = { Enabled = true, Threshold = 5.0 } } } } - }; - - Console.WriteLine("Capturing frame"); - var frame = camera.Capture(settings); - var pointCloud = frame.PointCloud; - - Console.WriteLine("Converting to Halcon point cloud"); - HalconDotNet.HObjectModel3D objectModel3D = ZividToHalconPointCloud(pointCloud); - - string pointCloudFile = "Zivid3D.ply"; - Console.WriteLine("Saving point cloud to: " + pointCloudFile); - SaveHalconPointCloud(objectModel3D, pointCloudFile); - } - catch (Exception ex) - { - Console.WriteLine("Error: " + ex.Message); - Environment.ExitCode = 1; - } - } - - private static void SaveHalconPointCloud(HalconDotNet.HObjectModel3D model, string fileName) - { - model.WriteObjectModel3d("ply", fileName, "invert_normals", "false"); - } - - private static int FindNumberOfValidPoints(float[,,] pointCloud, ulong height, ulong width) - { - var numberOfValidPoints = 0; - for (ulong i = 0; i < height; i++) - { - for (ulong j = 0; j < width; j++) - { - float x = pointCloud[i, j, 0]; - if (!float.IsNaN(x)) - { - numberOfValidPoints = numberOfValidPoints + 1; - } - } - } - return numberOfValidPoints; - } - - private static HalconDotNet.HObjectModel3D ZividToHalconPointCloud(Zivid.NET.PointCloud pointCloud) - { - var height = pointCloud.Height; - var width = pointCloud.Width; - var pointsXYZ = pointCloud.CopyPointsXYZ(); - var normalsXYZ = pointCloud.CopyNormalsXYZ(); - var colorsRGBA = pointCloud.CopyColorsRGBA(); - - var numberOfValidPoints = FindNumberOfValidPoints(pointsXYZ, height, width); - // Initializing HTuples which are later filled with data from the Zivid point cloud. - // tupleXYZMapping is of shape [width, height, rows[], cols[]], and is used for creating xyz mapping. - // See more at: https://www.mvtec.com/doc/halcon/13/en/set_object_model_3d_attrib.html - - var tuplePointsX = new HalconDotNet.HTuple(); - var tuplePointsY = new HalconDotNet.HTuple(); - var tuplePointsZ = new HalconDotNet.HTuple(); - - var tupleNormalsX = new HalconDotNet.HTuple(); - var tupleNormalsY = new HalconDotNet.HTuple(); - var tupleNormalsZ = new HalconDotNet.HTuple(); - - var tupleColorsR = new HalconDotNet.HTuple(); - var tupleColorsG = new HalconDotNet.HTuple(); - var tupleColorsB = new HalconDotNet.HTuple(); - - var tupleXYZMapping = new HalconDotNet.HTuple(); - - tuplePointsX[numberOfValidPoints - 1] = (float)0; - tuplePointsY[numberOfValidPoints - 1] = (float)0; - tuplePointsZ[numberOfValidPoints - 1] = (float)0; - - tupleNormalsX[numberOfValidPoints - 1] = (float)0; - tupleNormalsY[numberOfValidPoints - 1] = (float)0; - tupleNormalsZ[numberOfValidPoints - 1] = (float)0; - - tupleColorsR[numberOfValidPoints - 1] = (byte)0; - tupleColorsG[numberOfValidPoints - 1] = (byte)0; - tupleColorsB[numberOfValidPoints - 1] = (byte)0; - - tupleXYZMapping[2 * numberOfValidPoints + 2 - 1] = (uint)0; - tupleXYZMapping[0] = (uint)width; - tupleXYZMapping[1] = (uint)height; - - var validPointIndex = 0; - for (uint i = 0; i < height; i++) - { - for (uint j = 0; j < width; j++) - { - float x = pointsXYZ[i, j, 0]; - float normal = normalsXYZ[i, j, 0]; - - if (!float.IsNaN(x)) - { - tuplePointsX[validPointIndex] = pointsXYZ[i, j, 0]; - tuplePointsY[validPointIndex] = pointsXYZ[i, j, 1]; - tuplePointsZ[validPointIndex] = pointsXYZ[i, j, 2]; - tupleColorsR[validPointIndex] = colorsRGBA[i, j, 0]; - tupleColorsG[validPointIndex] = colorsRGBA[i, j, 1]; - tupleColorsB[validPointIndex] = colorsRGBA[i, j, 2]; - tupleXYZMapping[2 + validPointIndex] = i; - tupleXYZMapping[2 + numberOfValidPoints + validPointIndex] = j; - - if (!float.IsNaN(normal)) - { - tupleNormalsX[validPointIndex] = normalsXYZ[i, j, 0]; - tupleNormalsY[validPointIndex] = normalsXYZ[i, j, 1]; - tupleNormalsZ[validPointIndex] = normalsXYZ[i, j, 2]; - } - validPointIndex++; - } - } - } - - Console.WriteLine("Constructing ObjectModel3D based on XYZ data"); - var objectModel3D = new HalconDotNet.HObjectModel3D(tuplePointsX, tuplePointsY, tuplePointsZ); - - Console.WriteLine("Mapping ObjectModel3D data"); - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, "xyz_mapping", "object", tupleXYZMapping); - - Console.WriteLine("Adding normals to ObjectModel3D"); - var normalsAttribNames = new HalconDotNet.HTuple("point_normal_x", "point_normal_y", "point_normal_z"); - var normalsAttribValues = new HalconDotNet.HTuple(tupleNormalsX, tupleNormalsY, tupleNormalsZ); - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, normalsAttribNames, "points", normalsAttribValues); - - Console.WriteLine("Adding RGB to ObjectModel3D"); - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, "red", "points", tupleColorsR); - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, "green", "points", tupleColorsG); - HalconDotNet.HOperatorSet.SetObjectModel3dAttribMod(objectModel3D, "blue", "points", tupleColorsB); - - return objectModel3D; - } -} \ No newline at end of file diff --git a/source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.csproj b/source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.csproj deleted file mode 100644 index 5733dac..0000000 --- a/source/csharp/Camera/Basic/CaptureViaZivid/CaptureViaZivid.csproj +++ /dev/null @@ -1,77 +0,0 @@ - - - - - Debug - AnyCPU - {DD533F88-E34D-41A8-B734-1B94A5A4A31F} - Exe - Properties - CaptureViaZivid - CaptureViaZivid - v4.5.2 - 512 - true - - - true - ..\$(Configuration)\$(Platform) - DEBUG;TRACE - full - x64 - prompt - MinimumRecommendedRules.ruleset - true - true - true - - - ..\$(Configuration)\$(Platform) - TRACE - true - pdbonly - x64 - prompt - MinimumRecommendedRules.ruleset - true - true - - - - - - - - - - - - - $(HALCONROOT)\bin\dotnet35\halcondotnet.dll - - - $(HALCONROOT)\bin\dotnet35\hdevenginedotnet.dll - - - $(ZIVID_INSTALL_FOLDER)\bin\ZividCoreNET.dll - - - $(ZIVID_INSTALL_FOLDER)\bin_debug\ZividCoreNET.dll - - - - - - - - - - - - diff --git a/source/csharp/Camera/Basic/CaptureViaZivid/Properties/AssemblyInfo.cs b/source/csharp/Camera/Basic/CaptureViaZivid/Properties/AssemblyInfo.cs deleted file mode 100644 index aee39fe..0000000 --- a/source/csharp/Camera/Basic/CaptureViaZivid/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. - -[assembly: AssemblyTitleAttribute("CaptureViaZivid")] -[assembly: AssemblyDescriptionAttribute("")] -[assembly: AssemblyConfigurationAttribute("")] -[assembly: AssemblyCompanyAttribute("")] -[assembly: AssemblyProductAttribute("CaptureViaZivid")] -[assembly: AssemblyCopyrightAttribute("Copyright 2015-2020 (C) Zivid AS")] -[assembly: AssemblyTrademarkAttribute("")] -[assembly: AssemblyCultureAttribute("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("dd533f88-e34d-41a8-b734-1b94a5a4a31f")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// - -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: AssemblyInformationalVersion("1.0.0.0")] diff --git a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev b/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev deleted file mode 100644 index f1c75b7..0000000 --- a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModel.hdev +++ /dev/null @@ -1,151 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to create a model for HALCON surface-based 3D -* matching algorithm. It should be used together with the -* SurfaceMatchingFindModel.hdev where the model created by this -* program is utilized for surface-based 3D matching algorithm. This -* example comes with HDR settings and other parameters which were used -* to create models of the following three objects: a Twinings tea box, -* a Pringles can (190 g), and a plastic Coca-Cola bottle (0.5 l). -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Getting first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -import './../../../Procedures' -get_first_available_zivid_device (Devices, Device) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) - -* Configuring 3D-settings -set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') -set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') - -* Setting timeout for aborting a pending grab to infinity; useful for longer exposure times -set_framegrabber_param (AcqHandle, 'grab_timeout', -1) - -* Switching to HDR mode (multiple acquisitions) -set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') - -* Resetting any previous HDR settings -set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) - -* Configuring HDR settings (Twinings tea box) -*set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) -*set_framegrabber_param (AcqHandle, 'Aperture', 5.65) -*set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -*set_framegrabber_param (AcqHandle, 'Aperture', 4.0) -*set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Configuring HDR settings (Pringles can) -*set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) -*set_framegrabber_param (AcqHandle, 'Aperture', 4.36) -*set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -*set_framegrabber_param (AcqHandle, 'Aperture', 2.0) -*set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Configuring HDR settings (Coca-Cola bottle) -*set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) -*set_framegrabber_param (AcqHandle, 'Aperture', 6.16) -*set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -*set_framegrabber_param (AcqHandle, 'Aperture', 3.08) -*set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Configuring HDR settings (Your own object) -set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) -set_framegrabber_param (AcqHandle, 'Aperture', 10.37) -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -set_framegrabber_param (AcqHandle, 'Aperture', 5.50) -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -set_framegrabber_param (AcqHandle, 'Aperture', 2.37) -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Capturing frame (HDR) -grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D_Scene) - -* Extracting the following images: X, Y, Z, SNR, and RGB -select_obj (Image, X, 1) -select_obj (Image, Y, 2) -select_obj (Image, Z, 3) -select_obj (Image, Confidence, 4) -select_obj (Image, RGBA, 5) - -* Preparing graphics window -dev_close_window () -WinWidth := 1920 -WinHeight := 1200 -dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) - -* Displaying RGB image -dev_set_window (Window3D) -dev_display (RGBA) - -* Using the mouse cursor to draw a region around the object -dev_disp_text (['Position the mouse cursor on the edge of the object', 'Click and hold the left mouse button to begin drawing the ROI around the object', 'Release the left mouse button to end drawing the ROI', 'Click the right mouse button to continue running the program'], 'window', 'bottom', 'left', 'black', [], []) -draw_region (RegionDraw, Window3D) - -* Geting min and max Z values encapsulated by the created region -min_max_gray (RegionDraw, Z, 0, MinZ, MaxZ, RangeZ) - -* Segmenting Z image with Z values encapsulated by the created region -threshold (Z, RegionZ, MinZ, MaxZ) -reduce_domain (Z, RegionZ, Z) - -* Segmenting resulting Z image with the created region -reduce_domain (Z, RegionDraw, Z) - -* Transforming 3D points from X, Y, Z images to a HALCON 3D object model -xyz_to_object_model_3d (X, Y, Z, ObjectModel3D) - -* Computing normals for the HALCON 3D object model -count_seconds (T0) -sample_object_model_3d (ObjectModel3D, 'fast_compute_normals', 1, [], [], ObjectModel3D) -count_seconds (T1) -TimeForSampling := (T1 - T0) - -* Creating a HALCON surface-based matching model -count_seconds (T0) -create_surface_model (ObjectModel3D, 0.01, [], [], SFM) -count_seconds (T1) -TimeForCreating := (T1 - T0) - -* Disconnecting from Zivid Camera -close_framegrabber (AcqHandle) - -* Saving the HALCON 3D object model -write_object_model_3d (ObjectModel3D, 'om3', 'ObjectModel3D', [], [] ) - -* Saving the HALCON surface-based matching model -write_surface_model (SFM,'SFM') - -* Loading the HALCON 3D object model -read_object_model_3d ('ObjectModel3D', 'm', [], [], ObjectModel3D, Status) - -* Loading the HALCON surface-based matching model -read_surface_model ('SFM', SFM) - -* Displaying the 3D color point cloud, press the button to continue -Instructions[0] := 'Rotate: Left button' -Instructions[1] := 'Zoom: Shift + left button' -Instructions[2] := 'Move: Ctrl + left button' -visualize_object_model_3d (Window3D, ObjectModel3D, [], [], [], [], [], [], [], PoseOut) - -* Closing graphics window -dev_set_window (Window3D) -dev_close_window () - - - - - - diff --git a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev b/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev deleted file mode 100644 index 3873cf5..0000000 --- a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingCreateModelFromFile.hdev +++ /dev/null @@ -1,118 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to create a model for HALCON surface-based 3D -* matching algorithm. It should be used together with the -* SurfaceMatchingFindModelFromFile.hdev where the model created -* by this program is utilized for surface-based 3D matching algorithm. -* This example comes with models of three following objects:a Twinings -* tea box, a Pringles can (190 g), and a plastic Coca-Cola bottle (0.5 l). -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Preparing the graphics window -dev_close_window () -WinWidth := 1920 -WinHeight := 1200 -dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) - -* Reading a 3D point cloud of the scene -* Twinings tea box -SurfaceModelFile:= 'TwiningsTeaBox' -* Pringles can -* SurfaceModelFile:= 'PringlesCan' -* Coca-Cola bottle -* SurfaceModelFile:= 'CocaColaBottle' - -import './../../../Procedures' -get_zivid_sample_data_dir(ZividDataDir) -ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile + '/Im1.ply' -read_object_model_3d (ScenePath, 'm', ['xyz_map_width'], [1920], ObjectModel3D_Scene, Status) - -* Fixing to make the point cloud appear with colors -get_object_model_3d_params (ObjectModel3D_Scene, 'red', red) -get_object_model_3d_params (ObjectModel3D_Scene, 'green', green) -get_object_model_3d_params (ObjectModel3D_Scene, 'blue', blue) -set_object_model_3d_attrib (ObjectModel3D_Scene, '&red', 'points', red, ObjectModel3D_Scene) -set_object_model_3d_attrib (ObjectModel3D_Scene, '&green', 'points', green, ObjectModel3D_Scene) -set_object_model_3d_attrib (ObjectModel3D_Scene, '&blue', 'points', blue, ObjectModel3D_Scene) - -* Generating X, Y, and Z image -object_model_3d_to_xyz (X, Y, Z, ObjectModel3D_Scene, 'from_xyz_map', [], []) - -* Generating R, G, B, and RGB image -get_image_size (X, Width, Height) -gen_image_const (R, 'real', Width, Height) -gen_image_const (G, 'real', Width, Height) -gen_image_const (B, 'real', Width, Height) -get_domain (R, Domain) -get_region_points (Domain, Rows, Columns) -set_grayval (R, Rows, Columns, red) -set_grayval (G, Rows, Columns, green) -set_grayval (B, Rows, Columns, blue) -compose3 (R, G, B, RGB) - -* Use the mouse cursor to draw a region around the object -dev_disp_text (['Position the mouse cursor on the edge of the object', 'Click and hold the left mouse button to begin drawing the ROI around the object', 'Release the left mouse button to end drawing the ROI', 'Click the right mouse button to continue running the program'], 'window', 'bottom', 'left', 'black', [], []) -draw_region (RegionDraw, Window3D) - -* Getting min and max Z values encapsulated by the created region -min_max_gray (RegionDraw, Z, 0, MinZ, MaxZ, RangeZ) - -* Segmenting the Z image with Z values encapsulated by the created region -threshold (Z, RegionZ, MinZ, MaxZ) -reduce_domain (Z, RegionZ, Z) - -* Segmenting the resulting Z image with the created region -reduce_domain (Z, RegionDraw, Z) - -* Transforming 3D points from X, Y, Z images to a HALCON 3D object model -xyz_to_object_model_3d (X, Y, Z, ObjectModel3D) - -* Computing normals for the HALCON 3D object model -count_seconds (T0) -sample_object_model_3d (ObjectModel3D, 'fast_compute_normals', 1, [], [], ObjectModel3D) -count_seconds (T1) -TimeForSampling := (T1 - T0) - -* Creating a HALCON surface-based matching model -count_seconds (T0) -create_surface_model (ObjectModel3D, 0.01, [], [], SFM) -count_seconds (T1) -TimeForCreating := (T1 - T0) - -* Saving the HALCON 3D object model -write_object_model_3d (ObjectModel3D, 'om3', 'ObjectModel3D', [], [] ) - -* Saving the HALCON surface-based matching model -write_surface_model (SFM, 'SFM') - -* Loading the HALCON 3D object model -read_object_model_3d ('ObjectModel3D', 'm', [], [], ObjectModel3D, Status) - -* Loading the HALCON surface-based matching model -read_surface_model ('SFM', SFM) - -* Displaying the 3D color point cloud, press the button to continue -Instructions[0] := 'Rotate: Left button' -Instructions[1] := 'Zoom: Shift + left button' -Instructions[2] := 'Move: Ctrl + left button' -visualize_object_model_3d (Window3D, ObjectModel3D, [], [], [], [], [], [], [], PoseOut) - -* Closing the graphics window -dev_set_window (Window3D) -dev_close_window () - - - - - - diff --git a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev b/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev deleted file mode 100644 index cb51d08..0000000 --- a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModel.hdev +++ /dev/null @@ -1,227 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example demonstrates surface-based 3D matching on data taken with -* a Zivid camera. The model used for matching is created from a -* reference view of the object, see SurfaceMatchingCreateModel.hdev -* or SurfaceMatchingCreateModel.hdevFromFile. The model is then -* searched for in a newly captured 3D point cloud. This example comes with -* models for the three following objects: a Twinings tea box, a Pringles -* can (190 g), and a plastic Coca-Cola bottle (0.5 l). -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Specify whether you want to use your own model or not -MySurfaceModelFile := false -* MySurfaceModelFile := true - -* Specify the HALCON model for surface-based 3D matching -* Existing Twinings tea box model -SurfaceModelFile := 'TwiningsTeaBox' -* Existing Pringles can model -* SurfaceModelFile := 'PringlesCan' -* Existing Coca-Cola bottle model -* SurfaceModelFile := 'CocaColaBottle' -* Your own model created with the SurfaceMatchingCreateModel.hdev -* SurfaceModelFile := '' - -import './../../../Procedures' -get_zivid_sample_data_dir(ZividDataDir) -ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile - -* Getting first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -get_first_available_zivid_device (Devices, Device) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) - -* Configuring 3D-settings -set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') -set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') - -* Seting the timeout for aborting a pending grab to infinity; useful for longer exposure times -set_framegrabber_param (AcqHandle, 'grab_timeout', -1) - -* Switching to HDR mode (multiple acquisitions) -set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') - -* Reseting any previous HDR settings -set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) - -* Configuring HDR settings -* Twinings tea box -if (SurfaceModelFile = 'TwiningsTeaBox') - set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) - set_framegrabber_param (AcqHandle, 'Aperture', 5.50) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - set_framegrabber_param (AcqHandle, 'Aperture', 4.00) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -endif -* Pringles can -if (SurfaceModelFile = 'PringlesCan') - set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) - set_framegrabber_param (AcqHandle, 'Aperture', 4.36) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - set_framegrabber_param (AcqHandle, 'Aperture', 2.00) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -endif -* Coca-Cola bottle -if (SurfaceModelFile = 'CocaColaBottle') - set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) - set_framegrabber_param (AcqHandle, 'Aperture', 6.16) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - set_framegrabber_param (AcqHandle, 'Aperture', 3.08) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -endif -* Your own model created with the SurfaceMatchingCreateModel.hdev -if (SurfaceModelFile = '') - set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) - set_framegrabber_param (AcqHandle, 'Aperture', 16.00) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - set_framegrabber_param (AcqHandle, 'Aperture', 5.50) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - set_framegrabber_param (AcqHandle, 'Aperture', 2.37) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -endif - -* Loading the HALCON model for surface-based 3D matching -if (MySurfaceModelFile) - SFMFilename := 'SFM' -else - tuple_add(ScenePath,'/SFM', SFMFilename) -endif -read_surface_model (SFMFilename, SFM) - -* Loading the HALCON 3D object model (used for visualization purpose) -if (MySurfaceModelFile) - ObjectModel3DFilename := 'ObjectModel3D' -else - tuple_add(ScenePath,'/ObjectModel3D', ObjectModel3DFilename) -endif -read_object_model_3d (ObjectModel3DFilename, 'm', [], [], ObjectModel3D, Status) - - -* Preparing the graphics window -dev_close_window () -WinWidth := 1920 -WinHeight := 1200 -dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) - -for Index := 1 to 10 by 1 - - * Capturing frame (HDR) - grab_data (Image, Region, Contours, AcqHandle, ObjectModel3DSceneRaw) - - * Extracting the following images: X, Y, Z, SNR, and RGB - select_obj (Image, X, 1) - select_obj (Image, Y, 2) - select_obj (Image, Z, 3) - select_obj (Image, Confidence, 4) - select_obj (Image, RGBA, 5) - - * Converting to HALCON 3D object model - xyz_to_object_model_3d (X, Y, Z, ObjectModel3DScene) - - * Computing 3D object model normals, which is necessary for surface-based 3D matching - count_seconds (T0) - sample_object_model_3d (ObjectModel3DScene, 'fast_compute_normals', 1, [], [], ObjectModel3DScene) - count_seconds (T1) - TimeForSampling := (T1 - T0) - - * Object detection and pose estimation based on surface-based 3D matching - count_seconds (T0) - * RelSamplingDistance - point cloud downsampling (0 = no downsampling) - * Twinings tea box - if (SurfaceModelFile = 'TwiningsTeaBox') - RelSamplingDistance := 0.01 - endif - * Pringles can - if (SurfaceModelFile = 'PringlesCan') - RelSamplingDistance := 0.03 - endif - * Coca-Cola bottle - if (SurfaceModelFile = 'CocaColaBottle') - RelSamplingDistance := 0.003 - endif - * Your own model created with the SurfaceMatchingCreateModel.hdev - if (SurfaceModelFile = '') - RelSamplingDistance := 0.01 - endif - * KeyPointFraction - additional downsampling for the detection (1 = all points used) - KeyPointFraction := 1 - * MinScore - minimum score for the detection - MinScore := 0.4 - find_surface_model (SFM, ObjectModel3DScene, RelSamplingDistance, KeyPointFraction, MinScore, 'true', ['num_matches', 'scene_normal_computation'], [10, 'mls'], Pose, Score, SurfaceMatchingResultID) - count_seconds (T1) - TimeForMatching := (T1 - T0) - - if (Score!=[]) - - * Preparing result(s) - if (Score[0] < MinScore) - continue - endif - CPose := Pose[0:6] - rigid_trans_object_model_3d (ObjectModel3D, CPose, ObjectModel3DResult) - - * Visualizing matching scene and key points - Message := 'Original scene points (white)' - Message[1] := 'Sampled scene points (cyan)' - Message[2] := 'Key points (yellow)' - get_surface_matching_result (SurfaceMatchingResultID, 'sampled_scene', [], SampledScene) - get_surface_matching_result (SurfaceMatchingResultID, 'key_points', [], KeyPoints) - dev_clear_window () - Message[3] := ' ' - Message[4] := 'Rotate: Left button' - Message[5] := 'Zoom: Shift + left button' - Message[6] := 'Move: Ctrl + left button' - visualize_object_model_3d (Window3D, [ObjectModel3DScene,SampledScene,KeyPoints], [], [], ['color_' + [0,1,2],'point_size_' + [0,1,2]], ['gray','cyan','yellow',1.0,3.0,5.0], Message, [], Message, PoseOut) - - * Visualizing result(s) - Message1 := 'Scene: ' + Index - Message1[1] := 'Found ' + |ObjectModel3DResult| + ' object(s) in ' + TimeForMatching$'.3' + ' ms' - ScoreString := sum(Score$'.2f' + ' / ') - Message1[2] := 'Score(s): ' + ScoreString{0:strlen(ScoreString) - 4} - NumResult := |ObjectModel3DResult| - tuple_gen_const (NumResult, 'green', Colors) - tuple_gen_const (NumResult, 'circle', Shapes) - tuple_gen_const (NumResult, 3, Radii) - Indices := [1:NumResult] - dev_clear_window () - Instructions[0] := 'Rotate: Left button' - Instructions[1] := 'Zoom: Shift + left button' - Instructions[2] := 'Move: Ctrl + left button' - visualize_object_model_3d (Window3D, [ObjectModel3DScene,ObjectModel3DResult], [], [], ['color_' + [0,Indices],'point_size_0'], ['gray',Colors,1.0], Message1, [], Instructions, PoseOut) - - * Clear: Free result(s) - clear_object_model_3d (ObjectModel3DScene) - clear_object_model_3d (ObjectModel3DResult) - clear_object_model_3d (SampledScene) - clear_object_model_3d (KeyPoints) - clear_surface_matching_result (SurfaceMatchingResultID) - - endif - -endfor - -* Disconnecting from Zivid Camera -close_framegrabber (AcqHandle) - -* Closing graphics window -dev_set_window (Window3D) -dev_close_window () - - - - - - diff --git a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev b/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev deleted file mode 100644 index b46c35c..0000000 --- a/source/hdev/Applications/Advanced/ObjectMatching/SurfaceMatchingFindModelFromFile.hdev +++ /dev/null @@ -1,176 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example demonstrates surface-based 3D matching on data taken -* with a Zivid camera. The model used for matching is created from a -* reference view of the object, see -* SurfaceMatchingCreateModelFromFile.hdev. The model is then -* searched for in a newly captured 3D point cloud. This example comes -* with models for the three following objects: a Twinings tea box, -* a Pringles can (190 g), and a plastic Coca-Cola bottle (0.5 l). -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Preparing graphics window -dev_close_window () -WinWidth := 1920 -WinHeight := 1200 -dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window3D) - -* Specify the object for surface-based 3D matching -* Existing Twinings tea box model -SurfaceModelFile := 'TwiningsTeaBox' -* Existing Pringles can model -* SurfaceModelFile := 'PringlesCan' -* Existing Coca-Cola bottle model -* SurfaceModelFile := 'CocaColaBottle' - -import './../../../Procedures' -get_zivid_sample_data_dir(ZividDataDir) -ScenePath := ZividDataDir + '/ObjectMatching/' + SurfaceModelFile - -* Specify whether you want to use your own model created with the SurfaceMatchingCreateModelFromFile.hdev -MySurfaceModelFile := false -* MySurfaceModelFile := true - -* Loading the HALCON model for surface-based 3D matching -if (MySurfaceModelFile) - SFMFileName := 'SFM' -else - tuple_add (ScenePath, '/SFM', SFMFileName) -endif -read_surface_model (SFMFileName, SFM) - -* Loading the HALCON 3D object model (used for visualization purpose) -if (MySurfaceModelFile) - ObjectModel3DFile := 'ObjectModel3D' -else - tuple_add (ScenePath, '/ObjectModel3D', ObjectModel3DFile) -endif -read_object_model_3d (ObjectModel3DFile, 'm', [], [], ObjectModel3D, Status) - -for Index := 1 to 5 by 1 - - tuple_add (ScenePath, '/im', SceneFilename) - tuple_add (SceneFilename, Index, SceneFilename) - tuple_add (SceneFilename, '.ply', SceneFilename) - read_object_model_3d (SceneFilename, 'm', ['xyz_map_width'], [1920], ObjectModel3DScene, Status) - - * Fixing to make the point cloud appear with colors - get_object_model_3d_params (ObjectModel3DScene, 'red', red) - get_object_model_3d_params (ObjectModel3DScene, 'green', green) - get_object_model_3d_params (ObjectModel3DScene, 'blue', blue) - set_object_model_3d_attrib (ObjectModel3DScene, '&red', 'points', red, ObjectModel3DScene) - set_object_model_3d_attrib (ObjectModel3DScene, '&green', 'points', green, ObjectModel3DScene) - set_object_model_3d_attrib (ObjectModel3DScene, '&blue', 'points', blue, ObjectModel3DScene) - - * Generating X, Y, and Z image - object_model_3d_to_xyz ( X, Y, Z, ObjectModel3DScene, 'from_xyz_map', [], []) - - * Generating R, G, B, and RGB image - get_image_size (X, Width, Height) - gen_image_const (R, 'real', Width, Height) - gen_image_const (G, 'real', Width, Height) - gen_image_const (B, 'real', Width, Height) - get_domain (R, Domain) - get_region_points (Domain, Rows, Columns) - set_grayval (R, Rows, Columns, red) - set_grayval (G, Rows, Columns, green) - set_grayval (B, Rows, Columns, blue) - compose3 (R, G, B, RGB) - - * Computing 3D object model normals, which is necessary for surface-based 3D matching - count_seconds (T0) - sample_object_model_3d (ObjectModel3DScene, 'fast_compute_normals', 1, [], [], ObjectModel3DScene) - count_seconds (T1) - TimeForSampling := (T1 - T0) - - * Object detection and pose estimation based on surface-based 3D matching - count_seconds (T0) - * RelSamplingDistance - point cloud downsampling (0 = no downsampling) - * Twinings tea box - if (SurfaceModelFile = 'TwiningsTeaBox') - RelSamplingDistance := 0.01 - endif - * Pringles can - if (SurfaceModelFile = 'PringlesCan') - RelSamplingDistance := 0.03 - endif - * Coca-Cola bottle - if (SurfaceModelFile = 'CocaColaBottle') - RelSamplingDistance := 0.003 - endif - * KeyPointFraction - additional downsampling for the detection (1 = all points used) - KeyPointFraction := 1 - * MinScore - minimum score for the detection - MinScore := 0.4 - find_surface_model (SFM, ObjectModel3DScene, RelSamplingDistance, KeyPointFraction, MinScore, 'true', ['num_matches', 'scene_normal_computation'], [10, 'mls'], Pose, Score, SurfaceMatchingResultID) - count_seconds (T1) - TimeForMatching := (T1 - T0) - - if (Score!=[]) - - * Preparing result(s) - if (Score[0] < MinScore) - continue - endif - CPose := Pose[0:6] - rigid_trans_object_model_3d (ObjectModel3D, CPose, ObjectModel3DResult) - - * Visualizing matching scene and key points - Message := 'Original scene points (white)' - Message[1] := 'Sampled scene points (cyan)' - Message[2] := 'Key points (yellow)' - get_surface_matching_result (SurfaceMatchingResultID, 'sampled_scene', [], SampledScene) - get_surface_matching_result (SurfaceMatchingResultID, 'key_points', [], KeyPoints) - dev_clear_window () - Message[3] := ' ' - Message[4] := 'Rotate: Left button' - Message[5] := 'Zoom: Shift + left button' - Message[6] := 'Move: Ctrl + left button' - visualize_object_model_3d (Window3D, [ObjectModel3DScene,SampledScene,KeyPoints], [], [], ['color_' + [0,1,2],'point_size_' + [0,1,2]], ['gray','cyan','yellow',1.0,3.0,5.0], Message, [], Message, PoseOut) - - * Visualizing result(s) - Message1 := 'Scene: ' + Index - Message1[1] := 'Found ' + |ObjectModel3DResult| + ' object(s) in ' + TimeForMatching$'.3' + ' ms' - ScoreString := sum(Score$'.2f' + ' / ') - Message1[2] := 'Score(s): ' + ScoreString{0:strlen(ScoreString) - 4} - NumResult := |ObjectModel3DResult| - tuple_gen_const (NumResult, 'green', Colors) - tuple_gen_const (NumResult, 'circle', Shapes) - tuple_gen_const (NumResult, 3, Radii) - Indices := [1:NumResult] - dev_clear_window () - Instructions[0] := 'Rotate: Left button' - Instructions[1] := 'Zoom: Shift + left button' - Instructions[2] := 'Move: Ctrl + left button' - visualize_object_model_3d (Window3D, [ObjectModel3DScene,ObjectModel3DResult], [], [], ['color_' + [0,Indices],'point_size_0'], ['gray',Colors,1.0], Message1, [], Instructions, PoseOut) - - * Clear: Free result(s) - clear_object_model_3d (ObjectModel3DScene) - clear_object_model_3d (ObjectModel3DResult) - clear_object_model_3d (SampledScene) - clear_object_model_3d (KeyPoints) - clear_surface_matching_result (SurfaceMatchingResultID) - - endif - -endfor - -* Closing graphics window -dev_set_window (Window3D) -dev_close_window () - - - - - - diff --git a/source/hdev/Applications/Basic/FileFormats/ReadPLY.hdev b/source/hdev/Applications/Basic/FileFormats/ReadPLY.hdev deleted file mode 100644 index 92ff9a4..0000000 --- a/source/hdev/Applications/Basic/FileFormats/ReadPLY.hdev +++ /dev/null @@ -1,78 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to import and display a Zivid point -* cloud from a PLY file. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. -* - -* Preparing graphics windows -dev_close_window () -WinWidth := 960 -WinHeight := 800 -dev_open_window (0, 0, WinWidth, WinHeight, 'black', Window2D) -dev_open_window (0, WinWidth, WinWidth, WinHeight, 'blue', Window3D) - -* Reading PCD point cloud from file -import './../../../Procedures' -get_zivid_sample_data_dir(ZividDataDir) -PointCloudFile := ZividDataDir + '/Zivid3D.ply' -read_object_model_3d (PointCloudFile, 'mm', ['xyz_map_width'], [1920], ObjectModel3D, Status) - -* Fixing to make the point cloud appear with colors -get_object_model_3d_params (ObjectModel3D, 'red', red) -get_object_model_3d_params (ObjectModel3D, 'green', green) -get_object_model_3d_params (ObjectModel3D, 'blue', blue) -set_object_model_3d_attrib (ObjectModel3D, '&red', 'points', red, ObjectModel3D) -set_object_model_3d_attrib (ObjectModel3D, '&green', 'points', green, ObjectModel3D) -set_object_model_3d_attrib (ObjectModel3D, '&blue', 'points', blue, ObjectModel3D) - -* Generating X, Y, and Z image -object_model_3d_to_xyz (X, Y, Z, ObjectModel3D, 'from_xyz_map', [], []) - -* Generating R, G, B, and RGB image -get_image_size (X, Width, Height) -gen_image_const (R, 'real', Width, Height) -gen_image_const (G, 'real', Width, Height) -gen_image_const (B, 'real', Width, Height) -get_domain (R, Domain) -get_region_points (Domain, Rows, Columns) -set_grayval (R, Rows, Columns, red) -set_grayval (G, Rows, Columns, green) -set_grayval (B, Rows, Columns, blue) -compose3 (R, G, B, RGB) - -* Displaying RGB image -dev_set_window (Window2D) -dev_display (RGB) - -* Visualizing current 3D object model -dev_set_window (Window3D) -Instructions[0] := 'Rotate: Left button' -Instructions[1] := 'Zoom: Shift + left button' -Instructions[2] := 'Move: Ctrl + left button' -visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&red','&green','&blue'], Instructions, [], '', PoseOut) - -* Clearing 3D object model from memory -clear_object_model_3d (ObjectModel3D) - -* Closing graphics windows -dev_set_window (Window2D) -dev_close_window () -dev_set_window (Window3D) -dev_close_window () - - - - - - - - diff --git a/source/hdev/Camera/Basic/Capture.hdev b/source/hdev/Camera/Basic/Capture.hdev deleted file mode 100644 index 9a99071..0000000 --- a/source/hdev/Camera/Basic/Capture.hdev +++ /dev/null @@ -1,83 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to capture a 3D color point cloud -* from the camera and use it to generate a HALCON ObjectModel3D -* which is then visualized. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Preparing graphics windows -dev_close_window () -WinWidth := 960 -WinHeight := 800 -dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) -dev_open_window (0, WinWidth, WinWidth, WinHeight, 'black', Window2D) - -*Getting first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -import './../../Procedures' -get_first_available_zivid_device (Devices, Device) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) - -* Configuring 3D-settings -set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') -set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') - -* Switching to single Frame mode -set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'SingleFrame') - -* Configuring settings -set_framegrabber_param (AcqHandle, 'Aperture', 5.66) -set_framegrabber_param (AcqHandle, 'ExposureTime', 6500) -set_framegrabber_param (AcqHandle, 'Gain', 1) -set_framegrabber_param (AcqHandle, 'Brightness', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalThreshold', 5) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianSigma', 1.5) - -* Capturing frame -grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) - -* Extracting the following images: X, Y, Z, SNR, and RGB -select_obj (Image, X, 1) -select_obj (Image, Y, 2) -select_obj (Image, Z, 3) -select_obj (Image, Confidence, 4) -select_obj (Image, RGBA, 5) - -* Displaying 2D color image -dev_set_window (Window2D) -dev_display (RGBA) - -* Displaying 3D color point cloud, press the button to continue -Instructions[0] := 'Rotate: Left button' -Instructions[1] := 'Zoom: Shift + left button' -Instructions[2] := 'Move: Ctrl + left button' -visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) - -* Disconnecting from Zivid Camera -close_framegrabber (AcqHandle) - -* Closing graphics windows -dev_set_window (Window2D) -dev_close_window () -dev_set_window (Window3D) -dev_close_window () - - - - - - diff --git a/source/hdev/Camera/Basic/CaptureHDR.hdev b/source/hdev/Camera/Basic/CaptureHDR.hdev deleted file mode 100644 index cd6aa58..0000000 --- a/source/hdev/Camera/Basic/CaptureHDR.hdev +++ /dev/null @@ -1,88 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to capture an HDR image from the camera -* and use it to generate a HALCON ObjectModel3D which is then -* visualized. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Preparing graphics windows -dev_close_window () -WinWidth := 960 -WinHeight := 800 -dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) -dev_open_window (0, WinWidth, WinWidth, WinHeight, 'black', Window2D) - -*Getting first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -import './../../Procedures' -get_first_available_zivid_device (Devices, Device) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) - -* Configuring 3D-settings -set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') -set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') - -* Seting the timeout for aborting a pending grab to infinity -set_framegrabber_param (AcqHandle, 'grab_timeout', -1) - -* Switching to the HDR mode (multiple acquisitions) -set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') - -* Reseting any previous HDR settings -set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) - -* Configuring HDR settings -set_framegrabber_param (AcqHandle, 'Aperture', 11.31) -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -set_framegrabber_param (AcqHandle, 'Aperture', 5.66) -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) -set_framegrabber_param (AcqHandle, 'Aperture', 2.83) -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Capturing frame (HDR) -grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) - -* Extracting the following images: X, Y, Z, SNR, and RGB -select_obj (Image, X, 1) -select_obj (Image, Y, 2) -select_obj (Image, Z, 3) -select_obj (Image, Confidence, 4) -select_obj (Image, RGBA, 5) - -* Displaying 2D color image -dev_set_window (Window2D) -dev_display (RGBA) - -* Displaying 3D color point cloud, press the button to continue -Instructions[0] := 'Rotate: Left button' -Instructions[1] := 'Zoom: Shift + left button' -Instructions[2] := 'Move: Ctrl + left button' -dev_set_window (Window3D) -visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) - -* Disconnecting from the Zivid Camera -close_framegrabber (AcqHandle) - -* Closing graphics windows -dev_set_window (Window2D) -dev_close_window () -dev_set_window (Window3D) -dev_close_window () - - - - - - diff --git a/source/hdev/Camera/Basic/CaptureHDRCompleteSettings.hdev b/source/hdev/Camera/Basic/CaptureHDRCompleteSettings.hdev deleted file mode 100644 index 8525d0b..0000000 --- a/source/hdev/Camera/Basic/CaptureHDRCompleteSettings.hdev +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to capture an HDR image from the Zivid -* camera with fully configured settings for each frame. In general, -* taking an HDR image is a lot simpler than this as the default -* settings work for most scenes. The purpose of this example is to -* demonstrate how to configure all the settings. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Preparing graphics window -dev_close_window () -WinWidth := 960 -WinHeight := 800 -dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) - -*Get first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -import './../../Procedures' -get_first_available_zivid_device (Devices, Device) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) - -* Configuring 3D-settings -set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') -set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') - -* Seting timeout for aborting a pending grab to infinity; useful for longer exposure times -set_framegrabber_param (AcqHandle, 'grab_timeout', -1) - -* Switching to HDR mode (multiple acquisitions) -set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') - -* Resetting any previous HDR settings -set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) - -* Configuring HDR settings for the first image -set_framegrabber_param (AcqHandle, 'Aperture', 8) -set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) -set_framegrabber_param (AcqHandle, 'Brightness', 1) -set_framegrabber_param (AcqHandle, 'Gain', 1) - -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Configuring HDR settings for the second image -set_framegrabber_param (AcqHandle, 'Aperture', 4.00) -set_framegrabber_param (AcqHandle, 'ExposureTime', 10000) -set_framegrabber_param (AcqHandle, 'Brightness', 1) -set_framegrabber_param (AcqHandle, 'Gain', 1) - -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Configuring HDR settings for the third image -set_framegrabber_param (AcqHandle, 'Aperture', 4.00) -set_framegrabber_param (AcqHandle, 'ExposureTime', 40000) -set_framegrabber_param (AcqHandle, 'Brightness', 1) -set_framegrabber_param (AcqHandle, 'Gain', 1) - -set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - -* Setting global settings -set_framegrabber_param (AcqHandle, 'ExperimentalEngine', 'phase') -set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianSigma', 1.5) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalThreshold', 7.0) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalThreshold', 5.0) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersReflectionRemovalEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionCorrectionEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionCorrectionStrength', 0.4) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionRemovalEnabled', 1) -set_framegrabber_param (AcqHandle, 'ProcessingFiltersExperimentalContrastDistortionRemovalThreshold', 0.5) -set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceBlue', 1) -set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceGreen', 1) -set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceRed', 1) -set_framegrabber_param (AcqHandle, 'ProcessingColorExperimentalToneMappingEnabled', 'always') - -* Capturing frame (HDR) -grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) - -* Displaying 3D color point cloud, press the button to continue -Instructions[0] := 'Rotate: Left button' -Instructions[1] := 'Zoom: Shift + left button' -Instructions[2] := 'Move: Ctrl + left button' -visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) - -* Disconnecting from Zivid Camera -close_framegrabber (AcqHandle) - -* Closing graphics window -dev_close_window () - - - - - - diff --git a/source/hdev/Camera/Basic/CaptureHDRLoop.hdev b/source/hdev/Camera/Basic/CaptureHDRLoop.hdev deleted file mode 100644 index 140de0d..0000000 --- a/source/hdev/Camera/Basic/CaptureHDRLoop.hdev +++ /dev/null @@ -1,157 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to capture HDR images from the camera -* in a loop (while actively changing some HDR settings). Each -* HDR image is used to generate a HALCON ObjectModel3D -* which is then visualized. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Preparing the graphics window -dev_close_window () -WinWidth := 960 -WinHeight := 800 -dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) - -*Getting first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -import './../../Procedures' -get_first_available_zivid_device (Devices, Device) -get_zivid_sample_data_dir(ZividDataDir) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL', 1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) -get_framegrabber_param (AcqHandle, 'DeviceModelName', DeviceModelName) -tuple_substr (DeviceModelName, 0, 8, DeviceModelFolder) - -* Configuring 3D-settings -set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') -set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') - -* Seting the timeout for aborting a pending grab to infinity; useful for longer exposure times -set_framegrabber_param (AcqHandle, 'grab_timeout', -1) - -* Switching to HDR mode (multiple acquisitions) -set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'MultiAcquisitionFrame') - -for Index := 0 to 2 by 1 - - * Reseting any previous HDR settings - set_framegrabber_param (AcqHandle, 'ResetAcquisitions', 1) - - * Configuring HDR settings for frames - set_settings (AcqHandle, ZividDataDir + '/SettingsJson/' + DeviceModelFolder +'/Settings0'+(Index+1)+'.json') - - * Capturing frame (HDR) - grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) - - * Displaying 3D color point cloud, press the button to continue - Instructions[0] := 'Rotate: Left button' - Instructions[1] := 'Zoom: Shift + left button' - Instructions[2] := 'Move: Ctrl + left button' - visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['&overlay_red','&overlay_green','&overlay_blue'], [], [], [Instructions], PoseOut) - -endfor - -* Disconnecting from Zivid Camera -close_framegrabber (AcqHandle) - -* Closing graphics window -dev_close_window () - - - - - - - - - - - - - - - read_dict(path, [], [], json_dict) - - get_dict_tuple (json_dict, 'Settings', Settings) - get_dict_tuple (Settings, 'Acquisitions', Acquisitions) - get_dict_param (Acquisitions, 'keys', [], AllKeys) - - * Getting acquisition settings - for Index := 0 to |AllKeys| - 1 by 1 - get_dict_tuple (Acquisitions, Index, AcquisitionIndex) - get_dict_tuple (AcquisitionIndex, 'Acquisition', Acquisition) - get_dict_tuple (Acquisition, 'ExposureTime', ExposureTime) - set_framegrabber_param (AcqHandle, 'ExposureTime', ExposureTime) - get_dict_tuple (Acquisition, 'Aperture', Aperture) - set_framegrabber_param (AcqHandle, 'Aperture', Aperture) - get_dict_tuple (Acquisition, 'Brightness', Brightness) - set_framegrabber_param (AcqHandle, 'Brightness', Brightness) - get_dict_tuple (Acquisition, 'Gain', Gain) - set_framegrabber_param (AcqHandle, 'Gain', Gain) - set_framegrabber_param (AcqHandle, 'AddAcquisition', 1) - - endfor - - * Getting filter settings - get_dict_tuple (Settings, 'Processing', Processing) - get_dict_tuple (Processing, 'Filters', Filters) - - get_dict_tuple (Filters, 'Noise', Noise) - get_dict_tuple (Noise, 'Removal', Removal) - get_dict_tuple (Removal, 'Enabled', Enabled) - set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalEnabled', Enabled) - get_dict_tuple (Removal, 'Threshold', Threshold) - set_framegrabber_param (AcqHandle, 'ProcessingFiltersNoiseRemovalThreshold', Threshold) - - get_dict_tuple (Filters, 'Smoothing', Smoothing) - get_dict_tuple (Smoothing, 'Gaussian', Gaussian) - get_dict_tuple (Gaussian, 'Enabled', Enabled) - set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianEnabled', Enabled) - get_dict_tuple (Gaussian, 'Sigma', Sigma) - set_framegrabber_param (AcqHandle, 'ProcessingFiltersSmoothingGaussianSigma', Sigma) - - get_dict_tuple (Filters, 'Outlier', Outlier) - get_dict_tuple (Outlier, 'Removal', Removal) - get_dict_tuple (Removal, 'Enabled', Enabled) - set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalEnabled', Enabled) - get_dict_tuple (Removal, 'Threshold', Threshold) - set_framegrabber_param (AcqHandle, 'ProcessingFiltersOutlierRemovalThreshold', Threshold) - - get_dict_tuple (Filters, 'Reflection', Reflection) - get_dict_tuple (Reflection, 'Removal', Removal) - get_dict_tuple (Removal, 'Enabled', Enabled) - set_framegrabber_param (AcqHandle, 'ProcessingFiltersReflectionRemovalEnabled', Enabled) - - - * Getting color balance settings - get_dict_tuple (Processing, 'Color', Color) - get_dict_tuple (Color, 'Balance', Balance) - get_dict_tuple (Balance, 'Blue', Blue) - set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceBlue', Blue) - get_dict_tuple (Balance, 'Green', Green) - set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceGreen', Green) - get_dict_tuple (Balance, 'Red', Red) - set_framegrabber_param (AcqHandle, 'ProcessingColorBalanceRed', Red) - - -return () - - - - - - - - - diff --git a/source/hdev/Camera/Basic/CaptureSavePLY.hdev b/source/hdev/Camera/Basic/CaptureSavePLY.hdev deleted file mode 100644 index 7335a96..0000000 --- a/source/hdev/Camera/Basic/CaptureSavePLY.hdev +++ /dev/null @@ -1,93 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to capture a 3D color point cloud -* from the camera and save it to a PLY file format. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Preparing graphics windows -dev_close_window () -WinWidth := 960 -WinHeight := 800 -dev_open_window (0, 0, WinWidth, WinHeight, 'blue', Window3D) - -*Getting first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -import './../../Procedures' -get_first_available_zivid_device (Devices, Device) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) - -* Configuring 3D-settings -set_framegrabber_param (AcqHandle, 'create_objectmodel3d', 'enable') -set_framegrabber_param (AcqHandle, 'add_objectmodel3d_overlay_attrib', 'enable') - -* Switching to single acquisition mode -set_framegrabber_param (AcqHandle, 'AcquisitionMode', 'SingleFrame') - -* Configuring settings -set_framegrabber_param (AcqHandle, 'Aperture', 5.66) -set_framegrabber_param (AcqHandle, 'ExposureTime', 6500) -set_framegrabber_param (AcqHandle, 'Gain', 1) -set_framegrabber_param (AcqHandle, 'Brightness', 1) - -* Capturing frame -grab_data (Image, Region, Contours, AcqHandle, ObjectModel3D) - -* Extracting the following images: X, Y, Z, SNR, and RGB -select_obj (Image, X, 1) -select_obj (Image, Y, 2) -select_obj (Image, Z, 3) -select_obj (Image, Confidence, 4) -select_obj (Image, RGB, 5) - -* Transforming 3D points from X, Y, Z images to a HALCON 3D object model -xyz_to_object_model_3d (X, Y, Z, ObjectModel3D) - -* Adding RGB data to the 3D point cloud -decompose3 (RGB, R, G, B) - -get_domain (R, Domain) -get_region_points (Domain, Rows, Columns) -get_grayval (R, Rows, Columns, GrayvalR) -set_object_model_3d_attrib_mod (ObjectModel3D, 'red', 'points', GrayvalR) - -get_domain (G, Domain) -get_region_points (Domain, Rows, Columns) -get_grayval (G, Rows, Columns, GrayvalG) -set_object_model_3d_attrib_mod (ObjectModel3D, 'green', 'points', GrayvalG) - -get_domain (B, Domain) -get_region_points (Domain, Rows, Columns) -get_grayval (B, Rows, Columns, GrayvalB) -set_object_model_3d_attrib_mod (ObjectModel3D, 'blue', 'points', GrayvalB) - -* Displaying 3D color point cloud, press the button to continue -dev_set_window (Window3D) -Instructions[0] := 'Rotate: Left button' -Instructions[1] := 'Zoom: Shift + left button' -Instructions[2] := 'Move: Ctrl + left button' -visualize_object_model_3d (Window3D, ObjectModel3D, [], [], ['red_channel_attrib','green_channel_attrib','blue_channel_attrib'], ['red','green','blue'], '', [], '', PoseOut) - -* Writing a 3D object model in a PLY file format -write_object_model_3d (ObjectModel3D, 'ply', 'Zivid3DPLY.ply', ['invert_normals'], ['true']) - -* Disconnecting from Zivid Camera -close_framegrabber (AcqHandle) - - - - - - - diff --git a/source/hdev/Camera/Basic/ConnectToSerialNumberCamera.hdev b/source/hdev/Camera/Basic/ConnectToSerialNumberCamera.hdev deleted file mode 100644 index fe176ec..0000000 --- a/source/hdev/Camera/Basic/ConnectToSerialNumberCamera.hdev +++ /dev/null @@ -1,37 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to connect to a specific Zivid 3D -* camera based on its serial number. Verify that the serial -* number set is the serial number of the camera you are using. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -* Connecting to Zivid camera with the following serial number -CameraSerial := 'Zivid_DEV_19242553' -open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', CameraSerial, 0, 0, AcqHandle) - -* Disconnecting from Zivid Camera -close_framegrabber (AcqHandle) - -* Querying information about the connected image acquisition devices to find your device serial number -info_framegrabber ('GenICamTL', 'device', Information, Device) - -* Extracting serial number from your device -tuple_split (Device[0], '|' , Substrings) -tuple_strlen (Substrings[2], StrLength) -tuple_substr (Substrings[2],13,StrLength-2,CameraSerial) - - - - - - diff --git a/source/hdev/Camera/Basic/YAMLSettingsToJSON.py b/source/hdev/Camera/Basic/YAMLSettingsToJSON.py deleted file mode 100644 index fd69b90..0000000 --- a/source/hdev/Camera/Basic/YAMLSettingsToJSON.py +++ /dev/null @@ -1,33 +0,0 @@ -""" Script to convert from .yaml/.yml to .json -""" - -from pathlib import Path -import argparse -import os -import json -import yaml - - -def _main(): - parser = argparse.ArgumentParser() - parser.add_argument("directory") - args = parser.parse_args() - path = Path(args.directory) - print(path) - outdirpath = Path(f"{path}_json") - if not outdirpath.exists(): - os.mkdir(outdirpath) - - if outdirpath.is_dir(): - for x in list(path.glob("*.yml")): - out_name = f"{outdirpath}\\{x.stem}.json" - with open(x, "r") as yaml_in, open(out_name, "w") as json_out: - yaml_object = yaml.safe_load(yaml_in) - json.dump(yaml_object, json_out, indent=2) - - else: - print(f"{outdirpath} is not a directory") - - -if __name__ == "__main__": - _main() diff --git a/source/hdev/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev b/source/hdev/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev deleted file mode 100644 index 88f0c2c..0000000 --- a/source/hdev/Camera/InfoUtilOther/QuerySettingsAndParameters.hdev +++ /dev/null @@ -1,108 +0,0 @@ - - - - - -* -* Example for the usage of a Zivid 3D camera in HALCON -* -* This example shows how to query information about the image acquisition -* interface and selected specific parameters of Zivid camera. -* -* Please note that you first need to install Zivid Software and -* correctly set the environment variables. After this, you can -* access the camera with the HALCON GenICamTL interface. -* - -*Querying information about the image acquisition interface -info_framegrabber ('GenICamTL', 'general', Information_general, ValueList_general) -info_framegrabber ('GenICamTL', 'defaults', Information_defaults, ValueList_defaults) -info_framegrabber ('GenICamTL', 'info_boards', Information_info_boards, ValueList_info_boards) - -info_framegrabber ('GenICamTL', 'parameters', Information_parameters, ValueList_parameters) -info_framegrabber ('GenICamTL', 'parameters_readonly', Information_parameters_readonly, ValueList_parameters_readonly) -info_framegrabber ('GenICamTL', 'parameters_writeonly', Information_parameters_writeonly, ValueList_parameters_writeonly) - -*Getting first available Zivid device -info_framegrabber ('GenICamTL','device', Information, Devices) -import './../../Procedures' -get_first_available_zivid_device (Devices, Device) - -* Connecting to Zivid camera -open_framegrabber ('GenICamTL',1, 1, 0, 0, 0, 0, 'progressive', -1, 'default', -1, 'false', 'default', Device, 0, 0, AcqHandle) - -* Querying information about specific parameters of Zivid camera -get_framegrabber_param (AcqHandle, 'available_callback_types', Value_available_callback_types) -get_framegrabber_param (AcqHandle, 'available_param_names', Value_available_param_names) - -get_framegrabber_param (AcqHandle, 'DeviceSerialNumber', Value_DeviceSerialNumber) -get_framegrabber_param (AcqHandle, 'DeviceVendorName', Value_DeviceVendorName) -get_framegrabber_param (AcqHandle, 'DeviceModelName', Value_DeviceModelName) - -get_framegrabber_param (AcqHandle, 'WidthMax', Value_WidthMax) -get_framegrabber_param (AcqHandle, 'HeightMax', Value_HeightMax) -get_framegrabber_param (AcqHandle, 'Width', Value_Widt) -get_framegrabber_param (AcqHandle, 'Height', Value_Height) -get_framegrabber_param (AcqHandle, 'PixelSize', Value_PixelSize) -get_framegrabber_param (AcqHandle, 'PayloadSize', Value_PayloadSize) - -get_framegrabber_param (AcqHandle, '[System]TLID', Value_SystemTLID) -get_framegrabber_param (AcqHandle, '[System]TLVendorName', Value_SystemTLVendorName) -get_framegrabber_param (AcqHandle, '[System]TLModelName', Value_SystemTLModelName) -get_framegrabber_param (AcqHandle, '[System]TLVersion', Value_SystemTLVersion) -get_framegrabber_param (AcqHandle, '[System]TLFileName', Value_SystemTLFileName) -get_framegrabber_param (AcqHandle, '[System]TLPath', Value_SystemTLPath) -get_framegrabber_param (AcqHandle, '[System]TLType', Value_SystemTLType) -get_framegrabber_param (AcqHandle, '[System]GenTLVersionMajor', Value_SystemGenTLVersionMajor) -get_framegrabber_param (AcqHandle, '[System]GenTLVersionMinor', Value_SystemGenTLVersionMinor) -get_framegrabber_param (AcqHandle, '[System]GenTLSFNCVersionMajor', Value_SystemGenTLSFNCVersionMajor) -get_framegrabber_param (AcqHandle, '[System]GenTLSFNCVersionMinor', Value_SystemGenTLSFNCVersionMinor) -get_framegrabber_param (AcqHandle, '[System]GenTLSFNCVersionSubMinor', Value_SystemGenTLSFNCVersionSubMinor) -get_framegrabber_param (AcqHandle, '[System]InterfaceSelector', Value_SystemInterfaceSelector) -get_framegrabber_param (AcqHandle, '[System]InterfaceID', Value_SystemInterfaceID) - -get_framegrabber_param (AcqHandle, '[Interface]InterfaceID', Value_InterfaceID) -get_framegrabber_param (AcqHandle, '[Interface]InterfaceType', Value_InterfaceType) -get_framegrabber_param (AcqHandle, '[Interface]DeviceSelector', Value_InterfaceDeviceSelector) -get_framegrabber_param (AcqHandle, '[Interface]DeviceID', Value_InterfaceDeviceID) -get_framegrabber_param (AcqHandle, '[Interface]DeviceVendorName', Value_InterfaceDeviceVendorName) -get_framegrabber_param (AcqHandle, '[Interface]DeviceModelName', Value_InterfaceDeviceModelName) -get_framegrabber_param (AcqHandle, '[Interface]DeviceAccessStatus', Value_InterfaceDeviceAccessStatus) -get_framegrabber_param (AcqHandle, '[Interface]DeviceSerialNumber', Value_InterfaceDeviceSerialNumber) - -get_framegrabber_param (AcqHandle, '[Device]DeviceID', Value_DeviceID) -get_framegrabber_param (AcqHandle, '[Device]DeviceSerialNumber', Value_DeviceDeviceSerialNumber) -get_framegrabber_param (AcqHandle, '[Device]DeviceVendorName', Value_DeviceDeviceVendorName) -get_framegrabber_param (AcqHandle, '[Device]DeviceModelName', Value_DeviceDeviceModelName) -get_framegrabber_param (AcqHandle, '[Device]DeviceVersion', Value_DeviceVersion) -get_framegrabber_param (AcqHandle, '[Device]DeviceManufacturerInfo', Value_DeviceManufacturerInfo) -get_framegrabber_param (AcqHandle, '[Device]DeviceType', Value_DeviceType) -get_framegrabber_param (AcqHandle, '[Device]DeviceAccessStatus', Value_DeviceAccessStatus) -get_framegrabber_param (AcqHandle, '[Device]StreamSelector', Value_DeviceStreamSelector) -get_framegrabber_param (AcqHandle, '[Device]StreamID', Value_DeviceStreamID) - -get_framegrabber_param (AcqHandle, '[Stream]StreamID', Value_StreamID) -get_framegrabber_param (AcqHandle, '[Stream]StreamType', Value_StreamType) -get_framegrabber_param (AcqHandle, '[Stream]StreamAnnouncedBufferCount', Value_StreamAnnouncedBufferCount) -get_framegrabber_param (AcqHandle, '[Stream]StreamBufferHandlingMode', Value_StreamBufferHandlingMode) -get_framegrabber_param (AcqHandle, '[Stream]StreamAnnounceBufferMinimum', Value_StreamAnnounceBufferMinimum) -get_framegrabber_param (AcqHandle, '[Stream]StreamThreadPriority', Value_StreamThreadPriority) -get_framegrabber_param (AcqHandle, '[Stream]StreamAuxiliaryBufferCount', Value_StreamAuxiliaryBufferCount) - -get_framegrabber_param (AcqHandle, 'image_available', Value_image_available) -get_framegrabber_param (AcqHandle, 'image_width', Value_image_width) -get_framegrabber_param (AcqHandle, 'image_height', Value_image_height) -get_framegrabber_param (AcqHandle, 'num_buffers', Value_num_buffers) -get_framegrabber_param (AcqHandle, 'tl_displayname', Value_tl_displayname) -get_framegrabber_param (AcqHandle, 'tl_filename', Value_tl_filename) -get_framegrabber_param (AcqHandle, 'tl_id', Value_tl_id) -get_framegrabber_param (AcqHandle, 'tl_model', Value_tl_model) -get_framegrabber_param (AcqHandle, 'tl_pathname', Value_tl_pathname) -get_framegrabber_param (AcqHandle, 'num_buffers_await_delivery', Value_num_buffers_await_delivery) -get_framegrabber_param (AcqHandle, 'num_buffers_underrun', Value_num_buffers_underrun) - - - - - - diff --git a/source/hdev/Procedures/get_first_available_zivid_device.hdvp b/source/hdev/Procedures/get_first_available_zivid_device.hdvp deleted file mode 100644 index 41b4bc6..0000000 --- a/source/hdev/Procedures/get_first_available_zivid_device.hdvp +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - -* This procedure returns the first Zivid device from the input -* tuple of devices. The input tuple 'Devices' is typically returned -* by info_framegrabber function as follows: -* 'info_framegrabber ('GenICamTL','device', Information, Devices)' - -for i := 0 to |Devices| by 1 - SplitDevices := split(split(Devices[i], '|'), ':') - if(SplitDevices[2]{0:4} == 'Zivid') - Device := SplitDevices[2]{0:strlen(SplitDevices[2])-2} - break - endif -endfor -return () - - - - - - - - - diff --git a/source/hdev/Procedures/get_zivid_sample_data_dir.hdvp b/source/hdev/Procedures/get_zivid_sample_data_dir.hdvp deleted file mode 100644 index fc68dc2..0000000 --- a/source/hdev/Procedures/get_zivid_sample_data_dir.hdvp +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - -* This procedure returns the path of ZIVID DATA depending on your operating system. -* This is used to get data, e.g. camera settings, for some halcon samples. -* - -get_system ('operating_system', OSName) - -if (OSName{0:2} == 'Win') - ZIVID_SAMPLE_DATA_DIR := environment('ProgramData') + '/Zivid' -else - ZIVID_SAMPLE_DATA_DIR := '/usr/share/Zivid/data' -endif -return () - - - - - - - - - - -