コード例 #1
0
ファイル: FileStorage.cs プロジェクト: yyp2003net/opencvsharp
 /// <summary>
 /// Writes data to a file storage.
 /// </summary>
 /// <param name="val"></param>
 public FileStorage Add(Point3f val)
 {
     ThrowIfDisposed();
     NativeMethods.core_FileStorage_shift_Point3f(ptr, val);
     GC.KeepAlive(this);
     return(this);
 }
コード例 #2
0
        public void AddPoint(OpenCvSharp.Point3f pt)
        {
            var z = pt.Z;

            if (float.IsNaN(Z))
            {
                Z = z;
            }

            if (z != Z)
            {
                throw new ArgumentException("Point not in same plane as other points in contour!");
            }
            ContourPoints.Add(new Point2f(pt.X, pt.Y));
        }
コード例 #3
0
 public static extern void core_Mat_push_back_Point3f(IntPtr self, Point3f v);
コード例 #4
0
 public static extern ExceptionStatus core_FileNode_read_Point3f(IntPtr node, out Point3f returnValue);
コード例 #5
0
 public static extern ExceptionStatus core_FileStorage_shift_Point3f(IntPtr fs, Point3f val);
コード例 #6
0
ファイル: Line3D.cs プロジェクト: 180D-FW-2020/Team13
        /// <summary>
        /// 指定した点と直線の距離を返す
        /// </summary>
        /// <param name="point"></param>
#else
        /// <summary>
        /// Returns the distance between this line and the specified point
        /// </summary>
        /// <param name="point"></param>
#endif
        public double Distance(Point3f point)
        {
            return(Distance(point.X, point.Y, point.Z));
        }
コード例 #7
0
ファイル: Line3D.cs プロジェクト: 180D-FW-2020/Team13
        /// <summary>
        ///
        /// </summary>
        /// <param name="point"></param>
#else
        /// <summary>
        ///
        /// </summary>
        /// <param name="point"></param>
#endif
        public Point3d PerpendicularFoot(Point3f point)
        {
            return(PerpendicularFoot(point.X, point.Y, point.Z));
        }
コード例 #8
0
 public static extern ExceptionStatus core_Mat_push_back_Point3f(IntPtr self, Point3f v);
コード例 #9
0
 public static extern void core_FileStorage_shift_Point3f(IntPtr fs, Point3f val);
コード例 #10
0
ファイル: MatOfT.cs プロジェクト: rajs1006/3D-Unity
 public static void Run(IntPtr ptr, Point3f v) => NativeMethods.core_Mat_push_back_Point3f(ptr, v);
コード例 #11
0
ファイル: DICOM2StructureSet.cs プロジェクト: zzti/Evil-DICOM
        public static StructureSetMeta ParseDICOM(string file)
        {
            var sm  = new StructureSetMeta();
            var dcm = DICOMObject.Read(file);
            var sel = dcm.GetSelector();

            var metas = sel.StructureSetROISequence.Items.Select(i =>
            {
                var meta         = new StructureMeta();
                meta.StructureId = i.GetSelector().ROIName?.Data;
                meta.ROINumber   = i.GetSelector().ROINumber.Data;
                return(meta);
            });

            foreach (var meta in metas)
            {
                try
                {
                    var comatch = sel.ROIContourSequence.Items.FirstOrDefault(i => i.GetSelector().ReferencedROINumber.Data == meta.ROINumber);
                    var romatch = sel.RTROIObservationsSequence.Items.FirstOrDefault(i => i.GetSelector().ReferencedROINumber.Data == meta.ROINumber);

                    var colorValues = comatch.GetSelector().ROIDisplayColor.Data_;
                    var color       = new Vec3b((byte)colorValues[0], (byte)colorValues[1], (byte)colorValues[2]);
                    var dicomType   = romatch.GetSelector().RTROIInterpretedType.Data;
                    var name        = romatch.GetSelector().ROIObservationLabel.Data;
                    meta.StructureName = name;
                    meta.Color         = new Scalar(colorValues[0], colorValues[1], colorValues[2]);

                    var hasContours = comatch.GetSelector().ContourSequence != null;
                    if (!hasContours)
                    {
                        continue;
                    }

                    //HAS CONTOURS - SET COLOR BYTES IN MATRIX
                    foreach (var slice in comatch.GetSelector().ContourSequence.Items)
                    {
                        var contours = slice.GetSelector().ContourData.Data_;
                        if (contours.Count % 3 != 0)
                        {
                            _logger.LogWarning($"Slice for structure {meta.StructureId} has {contours.Count} contour points. Not divisible by 3! Can't process."); continue;
                        }
                        try
                        {
                            var contour = new SliceContourMeta();
                            for (int i = 0; i < contours.Count; i += 3)
                            {
                                var contourPt = new OpenCvSharp.Point3f((float)contours[i + 0], (float)contours[i + 1], (float)contours[i + 2]);
                                contour.AddPoint(contourPt);
                            }
                            meta.SliceContours.Add(contour);
                            meta.DICOMType = dicomType;
                        }
                        catch (Exception e)
                        {
                            _logger.LogError(e.ToString());
                        }
                    }

                    //OrganizeContours - contours containing other contours (holes and fills) will be organized
                    //into children. All other contours are outermost contours and not children of any other
                    var slices = meta.SliceContours.GroupBy(s => s.Z).ToList();
                    foreach (var slice in slices)
                    {
                        var sliceContours = slice.OrderByDescending(s => s.CalculateArea()).ToList();
                        ContourHelper.OrganizeIntoChildren(sliceContours[0], sliceContours.Skip(1));
                    }
                    sm.Structures.Add(meta.StructureId, meta);
                }
                catch (Exception e)
                {
                    _logger.LogError(e, $"Could not add structure {meta.StructureId}");
                }
            }
            return(sm);
        }