예제 #1
0
 private void ShowThread()
 {
     while (true)
     {
         int  count = int.MaxValue;
         bool check = false;
         while (count > 0)
         {
             ShowRequestArgument arg = null;
             lock (__lock)
             {
                 if (requestArguments.Count > 0)
                 {
                     arg = requestArguments.Dequeue();
                 }
                 count = requestArguments.Count;
             }
             if (arg != null)
             {
                 check = true;
                 Cv2.ImShow(arg.Title, arg.Frame);
                 Cv2.WaitKey(1);
             }
         }
         if (!check)
         {
             Cv2.WaitKey(1);
         }
     }
 }
예제 #2
0
        public void Show(string title, double scale = 1)
        {
            double[][] vector;
            vector = new double[Channels][];
            for (int c = 0; c < Channels; c++)
            {
                vector[c] = new double[Area];
            }
            BufferToFrame(ref vector);

            Mat[] frames = new Mat[Channels];
            for (int c = 0; c < Channels; c++)
            {
                frames[c] = new Mat(new Size(Width, Height), MatType.CV_64FC1);
                Marshal.Copy(vector[c], 0, frames[c].Data, Area);
                frames[c].ConvertTo(frames[c], MatType.CV_8UC1, byte.MaxValue);
            }
            var frame = new Mat();

            Cv2.Merge(frames, frame);

            if (scale != 1)
            {
                frame = frame.Resize(new Size(), scale, scale, InterpolationFlags.Area);
            }

            var arg = new ShowRequestArgument()
            {
                Title = title, Frame = frame
            };

            lock (__lock)
            {
                requestArguments.Enqueue(arg);
            }
        }