Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.69 KB | None | 0 0
  1.         static public void puzzle(Image<Bgr, byte> img, Image<Bgr, byte> imgCopy, out List<int[]> Pieces_positions, out List<int> Pieces_angle, int level)
  2.         {
  3.             Pieces_positions = new List<int[]>();
  4.             Pieces_angle = new List<int>();
  5.  
  6.             Dictionary<int, double[]> obj_list;
  7.             Dictionary<int, double[]>.Enumerator Enum;
  8.  
  9.             // Labeling of existing pieces
  10.             int[,] labels = ImageClass.Classification(img, true, false);
  11.  
  12.             if (labels != null)
  13.             {
  14.                 // Get a list of existing pieces properties according to their label
  15.                 obj_list = ImageClass.FindCorners(labels, img.Width, img.Height);
  16.                 Console.WriteLine("Pieces Labeled");
  17.  
  18.                 // Rotate the pieces that require it.
  19.                 ImageClass.RotatePieces(img, imgCopy, labels, obj_list);
  20.  
  21.                 // Merge all the pieces
  22.                 Image<Bgr, byte> img_aux = img.Copy();
  23.                 ImageClass.JoinPieces(img, img_aux, obj_list);
  24.                 Console.WriteLine("All Pieces Merged");
  25.  
  26.                 img_aux.CopyTo(imgCopy); // DEBUG
  27.  
  28.                 // Finish - Update out parameters
  29.                 Enum = obj_list.GetEnumerator();
  30.  
  31.                 int[] sqr;
  32.                 double[] piece;
  33.                 while (Enum.MoveNext())
  34.                 {
  35.                     piece = Enum.Current.Value;
  36.                     sqr = new int[4] { (int)piece[0], (int)piece[1], (int)piece[2], (int)piece[3] };
  37.                     Pieces_positions.Add(sqr);
  38.                     Pieces_angle.Add((int)piece[4]);
  39.                 }
  40.             } // End of Label != null
  41.         } // End of Puzzle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement