/// <summary>Convert a dual quaternion to a 3D pose.</summary> /// <param name="dualQuaternion">Unit dual quaternion.</param> /// <returns>3D pose.</returns> public static HPose[] DualQuatToPose(HDualQuaternion[] dualQuaternion) { HTuple htuple = HData.ConcatArray((HData[])dualQuaternion); IntPtr proc = HalconAPI.PreCall(2064); HalconAPI.Store(proc, 0, htuple); HalconAPI.InitOCT(proc, 0); int err = HalconAPI.CallProcedure(proc); HalconAPI.UnpinTuple(htuple); HTuple tuple; int procResult = HTuple.LoadNew(proc, 0, err, out tuple); HalconAPI.PostCall(proc, procResult); return(HPose.SplitArray(tuple)); }
/// <summary> /// Find the best matches of a calibrated descriptor model in an image and return their 3D pose. /// Instance represents: The handle to the descriptor model. /// </summary> /// <param name="image">Input image where the model should be found.</param> /// <param name="detectorParamName">The detector's parameter names. Default: []</param> /// <param name="detectorParamValue">Values of the detector's parameters. Default: []</param> /// <param name="descriptorParamName">The descriptor's parameter names. Default: []</param> /// <param name="descriptorParamValue">Values of the descriptor's parameters. Default: []</param> /// <param name="minScore">Minimum score of the instances of the models to be found. Default: 0.2</param> /// <param name="numMatches">Maximal number of found instances. Default: 1</param> /// <param name="camParam">Camera parameter (inner orientation) obtained from camera calibration.</param> /// <param name="scoreType">Score type to be evaluated in Score. Default: "num_points"</param> /// <param name="score">Score of the found instances according to the ScoreType input.</param> /// <returns>3D pose of the object.</returns> public HPose[] FindCalibDescriptorModel( HImage image, HTuple detectorParamName, HTuple detectorParamValue, HTuple descriptorParamName, HTuple descriptorParamValue, HTuple minScore, int numMatches, HCamPar camParam, HTuple scoreType, out HTuple score) { IntPtr proc = HalconAPI.PreCall(948); this.Store(proc, 0); HalconAPI.Store(proc, 1, (HObjectBase)image); HalconAPI.Store(proc, 1, detectorParamName); HalconAPI.Store(proc, 2, detectorParamValue); HalconAPI.Store(proc, 3, descriptorParamName); HalconAPI.Store(proc, 4, descriptorParamValue); HalconAPI.Store(proc, 5, minScore); HalconAPI.StoreI(proc, 6, numMatches); HalconAPI.Store(proc, 7, (HData)camParam); HalconAPI.Store(proc, 8, scoreType); HalconAPI.InitOCT(proc, 0); HalconAPI.InitOCT(proc, 1); int err1 = HalconAPI.CallProcedure(proc); HalconAPI.UnpinTuple(detectorParamName); HalconAPI.UnpinTuple(detectorParamValue); HalconAPI.UnpinTuple(descriptorParamName); HalconAPI.UnpinTuple(descriptorParamValue); HalconAPI.UnpinTuple(minScore); HalconAPI.UnpinTuple((HTuple)((HData)camParam)); HalconAPI.UnpinTuple(scoreType); HTuple tuple; int err2 = HTuple.LoadNew(proc, 0, err1, out tuple); int procResult = HTuple.LoadNew(proc, 1, err2, out score); HalconAPI.PostCall(proc, procResult); HPose[] hposeArray = HPose.SplitArray(tuple); GC.KeepAlive((object)this); GC.KeepAlive((object)image); return(hposeArray); }
/// <summary>Refine the pose of a surface model in a 3D scene and in images.</summary> /// <param name="image">Images of the scene.</param> /// <param name="surfaceModelID">Handle of the surface model.</param> /// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param> /// <param name="initialPose">Initial pose of the surface model in the scene.</param> /// <param name="minScore">Minimum score of the returned poses. Default: 0</param> /// <param name="returnResultHandle">Enable returning a result handle in SurfaceMatchingResultID. Default: "false"</param> /// <param name="genParamName">Names of the generic parameters. Default: []</param> /// <param name="genParamValue">Values of the generic parameters. Default: []</param> /// <param name="score">Score of the found instances of the model.</param> /// <param name="surfaceMatchingResultID">Handle of the matching result, if enabled in ReturnResultHandle.</param> /// <returns>3D pose of the surface model in the scene.</returns> public static HPose[] RefineSurfaceModelPoseImage( HImage image, HSurfaceModel surfaceModelID, HObjectModel3D objectModel3D, HPose[] initialPose, HTuple minScore, string returnResultHandle, HTuple genParamName, HTuple genParamValue, out HTuple score, out HSurfaceMatchingResult[] surfaceMatchingResultID) { HTuple htuple = HData.ConcatArray((HData[])initialPose); IntPtr proc = HalconAPI.PreCall(2084); HalconAPI.Store(proc, 1, (HObjectBase)image); HalconAPI.Store(proc, 0, (HTool)surfaceModelID); HalconAPI.Store(proc, 1, (HTool)objectModel3D); HalconAPI.Store(proc, 2, htuple); HalconAPI.Store(proc, 3, minScore); HalconAPI.StoreS(proc, 4, returnResultHandle); HalconAPI.Store(proc, 5, genParamName); HalconAPI.Store(proc, 6, genParamValue); HalconAPI.InitOCT(proc, 0); HalconAPI.InitOCT(proc, 1); HalconAPI.InitOCT(proc, 2); int err1 = HalconAPI.CallProcedure(proc); HalconAPI.UnpinTuple(htuple); HalconAPI.UnpinTuple(minScore); HalconAPI.UnpinTuple(genParamName); HalconAPI.UnpinTuple(genParamValue); HTuple tuple; int err2 = HTuple.LoadNew(proc, 0, err1, out tuple); int err3 = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out score); int procResult = HSurfaceMatchingResult.LoadNew(proc, 2, err3, out surfaceMatchingResultID); HalconAPI.PostCall(proc, procResult); HPose[] hposeArray = HPose.SplitArray(tuple); GC.KeepAlive((object)image); GC.KeepAlive((object)surfaceModelID); GC.KeepAlive((object)objectModel3D); return(hposeArray); }
/// <summary>Find the best matches of a surface model in a 3D scene and images.</summary> /// <param name="image">Images of the scene.</param> /// <param name="surfaceModelID">Handle of the surface model.</param> /// <param name="objectModel3D">Handle of the 3D object model containing the scene.</param> /// <param name="relSamplingDistance">Scene sampling distance relative to the diameter of the surface model. Default: 0.05</param> /// <param name="keyPointFraction">Fraction of sampled scene points used as key points. Default: 0.2</param> /// <param name="minScore">Minimum score of the returned poses. Default: 0</param> /// <param name="returnResultHandle">Enable returning a result handle in SurfaceMatchingResultID. Default: "false"</param> /// <param name="genParamName">Names of the generic parameters. Default: []</param> /// <param name="genParamValue">Values of the generic parameters. Default: []</param> /// <param name="score">Score of the found instances of the surface model.</param> /// <param name="surfaceMatchingResultID">Handle of the matching result, if enabled in ReturnResultHandle.</param> /// <returns>3D pose of the surface model in the scene.</returns> public static HPose[] FindSurfaceModelImage( HImage image, HSurfaceModel surfaceModelID, HObjectModel3D objectModel3D, double relSamplingDistance, double keyPointFraction, HTuple minScore, string returnResultHandle, HTuple genParamName, HTuple genParamValue, out HTuple score, out HSurfaceMatchingResult[] surfaceMatchingResultID) { IntPtr proc = HalconAPI.PreCall(2069); HalconAPI.Store(proc, 1, (HObjectBase)image); HalconAPI.Store(proc, 0, (HTool)surfaceModelID); HalconAPI.Store(proc, 1, (HTool)objectModel3D); HalconAPI.StoreD(proc, 2, relSamplingDistance); HalconAPI.StoreD(proc, 3, keyPointFraction); HalconAPI.Store(proc, 4, minScore); HalconAPI.StoreS(proc, 5, returnResultHandle); HalconAPI.Store(proc, 6, genParamName); HalconAPI.Store(proc, 7, genParamValue); HalconAPI.InitOCT(proc, 0); HalconAPI.InitOCT(proc, 1); HalconAPI.InitOCT(proc, 2); int err1 = HalconAPI.CallProcedure(proc); HalconAPI.UnpinTuple(minScore); HalconAPI.UnpinTuple(genParamName); HalconAPI.UnpinTuple(genParamValue); HTuple tuple; int err2 = HTuple.LoadNew(proc, 0, err1, out tuple); int err3 = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out score); int procResult = HSurfaceMatchingResult.LoadNew(proc, 2, err3, out surfaceMatchingResultID); HalconAPI.PostCall(proc, procResult); HPose[] hposeArray = HPose.SplitArray(tuple); GC.KeepAlive((object)image); GC.KeepAlive((object)surfaceModelID); GC.KeepAlive((object)objectModel3D); return(hposeArray); }
/// <summary> /// Find the best matches of a 3D shape model in an image. /// Instance represents: Handle of the 3D shape model. /// </summary> /// <param name="image">Input image in which the model should be found.</param> /// <param name="minScore">Minimum score of the instances of the model to be found. Default: 0.7</param> /// <param name="greediness">"Greediness" of the search heuristic (0: safe but slow; 1: fast but matches may be missed). Default: 0.9</param> /// <param name="numLevels">Number of pyramid levels used in the matching (and lowest pyramid level to use if $|NumLevels| = 2$). Default: 0</param> /// <param name="genParamName">Names of (optional) parameters for controlling the behavior of the operator. Default: []</param> /// <param name="genParamValue">Values of the optional generic parameters. Default: []</param> /// <param name="covPose">6 standard deviations or 36 covariances of the pose parameters.</param> /// <param name="score">Score of the found instances of the 3D shape model.</param> /// <returns>3D pose of the 3D shape model.</returns> public HPose[] FindShapeModel3d( HImage image, double minScore, double greediness, HTuple numLevels, HTuple genParamName, HTuple genParamValue, out HTuple covPose, out HTuple score) { IntPtr proc = HalconAPI.PreCall(1058); this.Store(proc, 0); HalconAPI.Store(proc, 1, (HObjectBase)image); HalconAPI.StoreD(proc, 1, minScore); HalconAPI.StoreD(proc, 2, greediness); HalconAPI.Store(proc, 3, numLevels); HalconAPI.Store(proc, 4, genParamName); HalconAPI.Store(proc, 5, genParamValue); HalconAPI.InitOCT(proc, 0); HalconAPI.InitOCT(proc, 1); HalconAPI.InitOCT(proc, 2); int err1 = HalconAPI.CallProcedure(proc); HalconAPI.UnpinTuple(numLevels); HalconAPI.UnpinTuple(genParamName); HalconAPI.UnpinTuple(genParamValue); HTuple tuple; int err2 = HTuple.LoadNew(proc, 0, err1, out tuple); int err3 = HTuple.LoadNew(proc, 1, HTupleType.DOUBLE, err2, out covPose); int procResult = HTuple.LoadNew(proc, 2, HTupleType.DOUBLE, err3, out score); HalconAPI.PostCall(proc, procResult); HPose[] hposeArray = HPose.SplitArray(tuple); GC.KeepAlive((object)this); GC.KeepAlive((object)image); return(hposeArray); }