Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static public void puzzle(Image<Bgr, byte> img, Image<Bgr, byte> imgCopy, out List<int[]> Pieces_positions, out List<int> Pieces_angle, int level)
- {
- Pieces_positions = new List<int[]>();
- Pieces_angle = new List<int>();
- Dictionary<int, double[]> obj_list;
- Dictionary<int, double[]>.Enumerator Enum;
- // Labeling of existing pieces
- int[,] labels = ImageClass.Classification(img, true, false);
- if (labels != null)
- {
- // Get a list of existing pieces properties according to their label
- obj_list = ImageClass.FindCorners(labels, img.Width, img.Height);
- Console.WriteLine("Pieces Labeled");
- // Rotate the pieces that require it.
- ImageClass.RotatePieces(img, imgCopy, labels, obj_list);
- // Merge all the pieces
- Image<Bgr, byte> img_aux = img.Copy();
- ImageClass.JoinPieces(img, img_aux, obj_list);
- Console.WriteLine("All Pieces Merged");
- img_aux.CopyTo(imgCopy); // DEBUG
- // Finish - Update out parameters
- Enum = obj_list.GetEnumerator();
- int[] sqr;
- double[] piece;
- while (Enum.MoveNext())
- {
- piece = Enum.Current.Value;
- sqr = new int[4] { (int)piece[0], (int)piece[1], (int)piece[2], (int)piece[3] };
- Pieces_positions.Add(sqr);
- Pieces_angle.Add((int)piece[4]);
- }
- } // End of Label != null
- } // End of Puzzle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement