public void RectangleTests() { int area = 12; int perimeter = 14; Assert.AreEqual(area, Rec1.GetArea()); Assert.AreEqual(perimeter, Rec1.GetPerimeter()); area = 20; perimeter = 18; Assert.AreEqual(area, Rec2.GetArea()); Assert.AreEqual(perimeter, Rec2.GetPerimeter()); area = 50; perimeter = 30; Assert.AreEqual(area, Rec3.GetArea()); Assert.AreEqual(perimeter, Rec3.GetPerimeter()); area = 24; perimeter = 20; Assert.AreEqual(area, Rec4.GetArea()); Assert.AreEqual(perimeter, Rec4.GetPerimeter()); area = 63; perimeter = 32; Assert.AreEqual(area, Rec5.GetArea()); Assert.AreEqual(perimeter, Rec5.GetPerimeter()); }
public void HashMatchWithMultikeysAndProbeResidual() { Rec1[] records1 = new Rec1[] { new Rec1(1, 1), new Rec1(1, 2), new Rec1(2, 1), new Rec1(2, 2), }; Rec1[] records2 = new Rec1[] { new Rec1(1, 2), }; Query query = new Query(); query.DataContext.Tables.Add(records1, "Records1"); query.DataContext.Tables.Add(records2, "Records2"); query.Text = @" SELECT * FROM Records2 r2, Records1 r1 WHERE r1.Key = r2.Key AND r1.SecKey = r2.SecKey "; DataTable result = query.ExecuteDataTable(); Assert.AreEqual(1, result.Rows.Count); Assert.AreEqual(1, result.Rows[0][0]); Assert.AreEqual(2, result.Rows[0][1]); Assert.AreEqual(1, result.Rows[0][2]); Assert.AreEqual(2, result.Rows[0][3]); }
public void ReccursionTest() { Rec1 rec = faker.Create <Rec1>(); if (rec.A.B == null) { logger.Info("ReccursionTest compled succesfully: object are equal"); } else { logger.Info("ReccursionTest compled not succesfully: object are't equal"); } Assert.AreEqual(null, rec.A.B); }
public void RectangleTests() { int area = 12; int perimeter = 14; Assert.AreEqual(area, Rec1.GetArea()); Assert.AreEqual(perimeter, Rec1.GetPerimeter()); area = 20; perimeter = 18; Assert.AreEqual(area, Rec2.GetArea()); Assert.AreEqual(perimeter, Rec2.GetPerimeter()); }
public void ReccursionTest() { Rec1 rec = _faker.Create <Rec1>(); object expected = null; var actual = rec.A.B; if (actual == expected) { _logger.Info($"ReccursionTest complete succesfully => {expected} == {actual}"); } else { _logger.Info($"ReccursionTest complete not succesfully => {expected} != {actual}"); } Assert.AreEqual(null, rec.A.B); }
bool patternRightFound; // True if chessboard found in image #endregion /********************************************************** * Calculates calibration transformatons and saves them. **********************************************************/ public void Calibration() { string imagesPath = calibrationPath.Text; if (imageCalibration != true) { try { FileStorage fs = new FileStorage(calibrationPath.Text, FileStorage.Mode.Read); fs["rmapx1"].ReadMat(rmapx1); fs["rmapy1"].ReadMat(rmapy1); fs["rmapx2"].ReadMat(rmapx2); fs["rmapy2"].ReadMat(rmapy2); string rec1Str = fs["Rec1"].ReadString(); string rec2Str = fs["Rec2"].ReadString(); int idx1 = rec1Str.IndexOf('='); int idx2 = rec1Str.IndexOf(','); int x = Convert.ToInt32(rec1Str.Substring(idx1 + 1, idx2 - idx1 - 1)); idx1 = rec1Str.IndexOf('=', idx2); idx2 = rec1Str.IndexOf(',', idx1); int y = Convert.ToInt32(rec1Str.Substring(idx1 + 1, idx2 - idx1 - 1)); idx1 = rec1Str.IndexOf('=', idx2); idx2 = rec1Str.IndexOf(',', idx1); int w = Convert.ToInt32(rec1Str.Substring(idx1 + 1, idx2 - idx1 - 1)); idx1 = rec1Str.IndexOf('=', idx2); idx2 = rec1Str.Length; int h = Convert.ToInt32(rec1Str.Substring(idx1 + 1, idx2 - idx1 - 1)); Rec1 = new Rectangle(x, y, w, h); idx1 = rec2Str.IndexOf('='); idx2 = rec2Str.IndexOf(','); x = Convert.ToInt32(rec2Str.Substring(idx1 + 1, idx2 - idx1 - 1)); idx1 = rec2Str.IndexOf('=', idx2); idx2 = rec2Str.IndexOf(',', idx1); y = Convert.ToInt32(rec2Str.Substring(idx1 + 1, idx2 - idx1 - 1)); idx1 = rec2Str.IndexOf('=', idx2); idx2 = rec2Str.IndexOf(',', idx1); w = Convert.ToInt32(rec2Str.Substring(idx1 + 1, idx2 - idx1 - 1)); idx1 = rec2Str.IndexOf('=', idx2); idx2 = rec2Str.Length; h = Convert.ToInt32(rec2Str.Substring(idx1 + 1, idx2 - idx1 - 1)); Rec2 = new Rectangle(x, y, w, h); MessageBox.Show("Transformation maps loaded successfully"); } catch (Exception) { MessageBox.Show("Error: Problem loading Transformation maps"); Environment.Exit(1); } } if (imageCalibration == true) { for (int i = 0; i < bufferLength * 2; i++) { chessFrameL = CvInvoke.Imread(imagesPath + "\\camera1\\image_" + i.ToString() + ".jpg"); chessFrameR = CvInvoke.Imread(imagesPath + "\\camera2\\image_" + i.ToString() + ".jpg"); patternLeftFound = CvInvoke.FindChessboardCorners(chessFrameL, patternSize, cornersVecLeft, CalibCbType.NormalizeImage | CalibCbType.AdaptiveThresh); patternRightFound = CvInvoke.FindChessboardCorners(chessFrameR, patternSize, cornersVecRight, CalibCbType.NormalizeImage | CalibCbType.AdaptiveThresh); if (patternLeftFound && patternRightFound) { CvInvoke.CvtColor(chessFrameL, grayLeft, ColorConversion.Bgr2Gray); CvInvoke.CvtColor(chessFrameR, grayRight, ColorConversion.Bgr2Gray); CvInvoke.DrawChessboardCorners(chessFrameL, patternSize, cornersVecLeft, patternLeftFound); CvInvoke.DrawChessboardCorners(chessFrameR, patternSize, cornersVecRight, patternRightFound); CvInvoke.Imshow("Calibration image left", chessFrameL); CvInvoke.Imshow("Calibration image right", chessFrameR); //chessFrameL.Save(desktop + "\\Left_" + i + ".jpg"); //chessFrameR.Save(desktop + "\\Right" + i + ".jpg"); CvInvoke.WaitKey(10); imagePoints1[bufferSavepoint] = cornersVecLeft.ToArray(); imagePoints2[bufferSavepoint] = cornersVecRight.ToArray(); bufferSavepoint++; if (bufferSavepoint == bufferLength) { break; } } } CvInvoke.DestroyAllWindows(); //fill the MCvPoint3D32f with correct mesurments for (int k = 0; k < bufferLength; k++) { //Fill our objects list with the real world mesurments for the intrinsic calculations List <MCvPoint3D32f> object_list = new List <MCvPoint3D32f>(); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { object_list.Add(new MCvPoint3D32f(j * 20.0F, i * 20.0F, 0.0F)); } } cornersObjectPoints[k] = object_list.ToArray(); } CvInvoke.CalibrateCamera(cornersObjectPoints, imagePoints1, chessFrameL.Size, camMat1, dist1, CalibType.Default, new MCvTermCriteria(200, 1e-5), out rvecs, out tvecs); CvInvoke.CalibrateCamera(cornersObjectPoints, imagePoints2, chessFrameL.Size, camMat2, dist2, CalibType.Default, new MCvTermCriteria(200, 1e-5), out rvecs, out tvecs); CvInvoke.StereoCalibrate(cornersObjectPoints, imagePoints1, imagePoints2, camMat1, dist1, camMat2, dist2, chessFrameL.Size, R, T, essential, fundamental, CalibType.FixAspectRatio | CalibType.ZeroTangentDist | CalibType.SameFocalLength | CalibType.RationalModel | CalibType.UseIntrinsicGuess | CalibType.FixK3 | CalibType.FixK4 | CalibType.FixK5, new MCvTermCriteria(100, 1e-5)); CvInvoke.StereoRectify(camMat1, dist1, camMat2, dist2, chessFrameL.Size, R, T, R1, R2, P1, P2, Q, StereoRectifyType.CalibZeroDisparity, 0, chessFrameL.Size, ref Rec1, ref Rec2); // Create transformation maps CvInvoke.InitUndistortRectifyMap(camMat1, dist1, R1, P1, chessFrameL.Size, DepthType.Cv32F, rmapx1, rmapy1); CvInvoke.InitUndistortRectifyMap(camMat2, dist2, R2, P2, chessFrameL.Size, DepthType.Cv32F, rmapx2, rmapy2); MessageBox.Show("Calibration has ended\n Connect to TELLO access point"); try { FileStorage fs = new FileStorage(calibrationPath.Text + "\\calibMaps.xml", FileStorage.Mode.Write); fs.Write(rmapx1, "rmapx1"); fs.Write(rmapy1, "rmapy1"); fs.Write(rmapx2, "rmapx2"); fs.Write(rmapy2, "rmapy2"); fs.Write(Rec1.ToString(), "Rec1"); fs.Write(Rec2.ToString(), "Rec2"); MessageBox.Show("Transformation maps saved successfully"); } catch (Exception) { MessageBox.Show("Error: Problem saving Transformation maps"); Environment.Exit(1); } } }