Example #1
0
        /// <summary>
        ///   Project the edges of a 3D shape model into image coordinates.
        ///   Instance represents: Handle of the 3D shape model.
        /// </summary>
        /// <param name="camParam">Internal camera parameters.</param>
        /// <param name="pose">3D pose of the 3D shape model in the world coordinate system.</param>
        /// <param name="hiddenSurfaceRemoval">Remove hidden surfaces? Default: "true"</param>
        /// <param name="minFaceAngle">Smallest face angle for which the edge is displayed Default: 0.523599</param>
        /// <returns>Contour representation of the model view.</returns>
        public HXLDCont ProjectShapeModel3d(
            HCamPar camParam,
            HPose pose,
            string hiddenSurfaceRemoval,
            double minFaceAngle)
        {
            IntPtr proc = HalconAPI.PreCall(1055);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HData)camParam);
            HalconAPI.Store(proc, 2, (HData)pose);
            HalconAPI.StoreS(proc, 3, hiddenSurfaceRemoval);
            HalconAPI.StoreD(proc, 4, minFaceAngle);
            HalconAPI.InitOCT(proc, 1);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple((HTuple)((HData)camParam));
            HalconAPI.UnpinTuple((HTuple)((HData)pose));
            HXLDCont hxldCont;
            int      procResult = HXLDCont.LoadNew(proc, 1, err, out hxldCont);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(hxldCont);
        }
Example #2
0
        /// <summary>
        ///   Prepare a 3D object model for matching.
        ///   Modified instance represents: Handle of the 3D shape model.
        /// </summary>
        /// <param name="objectModel3D">Handle of the 3D object model.</param>
        /// <param name="camParam">Internal camera parameters.</param>
        /// <param name="refRotX">Reference orientation: Rotation around x-axis or x component of the Rodriguez vector (in radians or without unit). Default: 0</param>
        /// <param name="refRotY">Reference orientation: Rotation around y-axis or y component of the Rodriguez vector (in radians or without unit). Default: 0</param>
        /// <param name="refRotZ">Reference orientation: Rotation around z-axis or z component of the Rodriguez vector (in radians or without unit). Default: 0</param>
        /// <param name="orderOfRotation">Meaning of the rotation values of the reference orientation. Default: "gba"</param>
        /// <param name="longitudeMin">Minimum longitude of the model views. Default: -0.35</param>
        /// <param name="longitudeMax">Maximum longitude of the model views. Default: 0.35</param>
        /// <param name="latitudeMin">Minimum latitude of the model views. Default: -0.35</param>
        /// <param name="latitudeMax">Maximum latitude of the model views. Default: 0.35</param>
        /// <param name="camRollMin">Minimum camera roll angle of the model views. Default: -3.1416</param>
        /// <param name="camRollMax">Maximum camera roll angle of the model views. Default: 3.1416</param>
        /// <param name="distMin">Minimum camera-object-distance of the model views. Default: 0.3</param>
        /// <param name="distMax">Maximum camera-object-distance of the model views. Default: 0.4</param>
        /// <param name="minContrast">Minimum contrast of the objects in the search images. Default: 10</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>
        public void CreateShapeModel3d(
            HObjectModel3D objectModel3D,
            HCamPar camParam,
            double refRotX,
            double refRotY,
            double refRotZ,
            string orderOfRotation,
            double longitudeMin,
            double longitudeMax,
            double latitudeMin,
            double latitudeMax,
            double camRollMin,
            double camRollMax,
            double distMin,
            double distMax,
            int minContrast,
            HTuple genParamName,
            HTuple genParamValue)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(1059);

            HalconAPI.Store(proc, 0, (HTool)objectModel3D);
            HalconAPI.Store(proc, 1, (HData)camParam);
            HalconAPI.StoreD(proc, 2, refRotX);
            HalconAPI.StoreD(proc, 3, refRotY);
            HalconAPI.StoreD(proc, 4, refRotZ);
            HalconAPI.StoreS(proc, 5, orderOfRotation);
            HalconAPI.StoreD(proc, 6, longitudeMin);
            HalconAPI.StoreD(proc, 7, longitudeMax);
            HalconAPI.StoreD(proc, 8, latitudeMin);
            HalconAPI.StoreD(proc, 9, latitudeMax);
            HalconAPI.StoreD(proc, 10, camRollMin);
            HalconAPI.StoreD(proc, 11, camRollMax);
            HalconAPI.StoreD(proc, 12, distMin);
            HalconAPI.StoreD(proc, 13, distMax);
            HalconAPI.StoreI(proc, 14, minContrast);
            HalconAPI.Store(proc, 15, genParamName);
            HalconAPI.Store(proc, 16, genParamValue);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple((HTuple)((HData)camParam));
            HalconAPI.UnpinTuple(genParamName);
            HalconAPI.UnpinTuple(genParamValue);
            int procResult = this.Load(proc, 0, err);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)objectModel3D);
        }
Example #3
0
        /// <summary>
        ///   Set type and initial parameters of a camera in a calibration data model.
        ///   Instance represents: Handle of a calibration data model.
        /// </summary>
        /// <param name="cameraIdx">Camera index. Default: 0</param>
        /// <param name="cameraType">Type of the camera. Default: []</param>
        /// <param name="cameraParam">Initial camera internal parameters.</param>
        public void SetCalibDataCamParam(HTuple cameraIdx, string cameraType, HCamPar cameraParam)
        {
            IntPtr proc = HalconAPI.PreCall(1979);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, cameraIdx);
            HalconAPI.StoreS(proc, 2, cameraType);
            HalconAPI.Store(proc, 3, (HData)cameraParam);
            int procResult = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple(cameraIdx);
            HalconAPI.UnpinTuple((HTuple)((HData)cameraParam));
            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
        }
Example #4
0
        /// <summary>
        ///   Add a camera to a 3D scene.
        ///   Instance represents: Handle of the 3D scene.
        /// </summary>
        /// <param name="cameraParam">Parameters of the new camera.</param>
        /// <returns>Index of the new camera in the 3D scene.</returns>
        public int AddScene3dCamera(HCamPar cameraParam)
        {
            IntPtr proc = HalconAPI.PreCall(1218);

            this.Store(proc, 0);
            HalconAPI.Store(proc, 1, (HData)cameraParam);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple((HTuple)((HData)cameraParam));
            int intValue;
            int procResult = HalconAPI.LoadI(proc, 0, err, out intValue);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            return(intValue);
        }
Example #5
0
        /// <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);
        }
Example #6
0
        /// <summary>
        ///   Create a descriptor model for calibrated perspective matching.
        ///   Modified instance represents: The handle to the descriptor model.
        /// </summary>
        /// <param name="template">Input image whose domain will be used to create the model.</param>
        /// <param name="camParam">The parameters of the internal orientation of the camera.</param>
        /// <param name="referencePose">The reference pose of the object in the reference image.</param>
        /// <param name="detectorType">The type of the detector. Default: "lepetit"</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="seed">The seed for the random number generator. Default: 42</param>
        public void CreateCalibDescriptorModel(
            HImage template,
            HCamPar camParam,
            HPose referencePose,
            string detectorType,
            HTuple detectorParamName,
            HTuple detectorParamValue,
            HTuple descriptorParamName,
            HTuple descriptorParamValue,
            int seed)
        {
            this.Dispose();
            IntPtr proc = HalconAPI.PreCall(952);

            HalconAPI.Store(proc, 1, (HObjectBase)template);
            HalconAPI.Store(proc, 0, (HData)camParam);
            HalconAPI.Store(proc, 1, (HData)referencePose);
            HalconAPI.StoreS(proc, 2, detectorType);
            HalconAPI.Store(proc, 3, detectorParamName);
            HalconAPI.Store(proc, 4, detectorParamValue);
            HalconAPI.Store(proc, 5, descriptorParamName);
            HalconAPI.Store(proc, 6, descriptorParamValue);
            HalconAPI.StoreI(proc, 7, seed);
            HalconAPI.InitOCT(proc, 0);
            int err = HalconAPI.CallProcedure(proc);

            HalconAPI.UnpinTuple((HTuple)((HData)camParam));
            HalconAPI.UnpinTuple((HTuple)((HData)referencePose));
            HalconAPI.UnpinTuple(detectorParamName);
            HalconAPI.UnpinTuple(detectorParamValue);
            HalconAPI.UnpinTuple(descriptorParamName);
            HalconAPI.UnpinTuple(descriptorParamValue);
            int procResult = this.Load(proc, 0, err);

            HalconAPI.PostCall(proc, procResult);
            GC.KeepAlive((object)this);
            GC.KeepAlive((object)template);
        }