//called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (FPinInDo[0]) { bool useVVVVCoords = FPinInCoordSystem[0] == TCoordinateSystem.VVVV; SpreadMax = Math.Max(FPinInObject.SliceCount, FPinInImage.SliceCount); FPinOutExtrinsics.SliceCount = SpreadMax; FPinOutStatus.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { try { if (FPinInObject[i].SliceCount == 0 || FPinInImage[i].SliceCount == 0) { throw new Exception("No datapoints"); } if (FPinInImage[i].SliceCount == 1) { throw new Exception("Only 1 image point is being input per board, check SliceCount!"); } if (FPinInObject[i].SliceCount == 1) { throw new Exception("Only 1 object point is being input per board, check SliceCount!"); } if (FPinInIntrinsics[i].intrinsics == null) { throw new Exception("Waiting for camera calibration intrinsics"); } ExtrinsicCameraParameters extrinsics = CameraCalibration.FindExtrinsicCameraParams2(MatrixUtils.ObjectPoints(FPinInObject[i], useVVVVCoords), MatrixUtils.ImagePoints(FPinInImage[i]), FPinInIntrinsics[i].intrinsics); FPinOutExtrinsics[i] = new Extrinsics(extrinsics); if (useVVVVCoords) { FPinOutView[i] = MatrixUtils.ConvertToVVVV(FPinOutExtrinsics[i].Matrix); } else { FPinOutView[i] = FPinOutExtrinsics[i].Matrix; } FPinOutStatus[i] = "OK"; } catch (Exception e) { FPinOutStatus[i] = e.Message; } } } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (FPinInDo[0]) { int nPointsPerImage = FPinInObject.SliceCount; if (nPointsPerImage == 0) { FStatus[0] = "Insufficient points"; return; } int nImages = Math.Max(FPinInImage1.SliceCount, FPinInImage2.SliceCount) / nPointsPerImage; CALIB_TYPE flags = CALIB_TYPE.DEFAULT; MCvTermCriteria termCrit = new MCvTermCriteria(100, 0.001); MCvPoint3D32f[][] objectPoints = new MCvPoint3D32f[nImages][]; PointF[][] imagePoints1 = new PointF[nImages][]; PointF[][] imagePoints2 = new PointF[nImages][]; Size imageSize = new Size((int)FPinInSensorSize[0].x, (int)FPinInSensorSize[0].y); ExtrinsicCameraParameters interCameraExtrinsics; Matrix <double> foundamentalMatrix; Matrix <double> essentialMatrix; IntrinsicCameraParameters intrinsics1 = FPinInIntrinsics1[0].intrinsics; IntrinsicCameraParameters intrinsics2 = FPinInIntrinsics2[0].intrinsics; imagePoints1 = MatrixUtils.ImagePoints(FPinInImage1, nPointsPerImage); imagePoints2 = MatrixUtils.ImagePoints(FPinInImage2, nPointsPerImage); for (int i = 0; i < nImages; i++) { objectPoints[i] = MatrixUtils.ObjectPoints(FPinInObject, true); } try { CameraCalibration.StereoCalibrate(objectPoints, imagePoints1, imagePoints2, intrinsics1, intrinsics2, imageSize, flags, termCrit, out interCameraExtrinsics, out foundamentalMatrix, out essentialMatrix); Extrinsics extrinsics = new Extrinsics(interCameraExtrinsics); FPinOutExtrinsics[0] = extrinsics; FPinOutTransform[0] = extrinsics.Matrix; FPinOutSuccess[0] = true; FStatus[0] = "OK"; } catch (Exception e) { FPinOutSuccess[0] = false; FStatus[0] = e.Message; } } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (FPinInDo[0]) { int nPointsPerImage = FPinInObject.SliceCount; if (nPointsPerImage == 0) { FStatus[0] = "Insufficient points"; return; } int nImages = Math.Max(FPinInImage1.SliceCount, FPinInImage2.SliceCount) / nPointsPerImage; CALIB_TYPE flags = CALIB_TYPE.DEFAULT; MCvTermCriteria termCrit = new MCvTermCriteria(100, 0.001); MCvPoint3D32f[][] objectPoints = new MCvPoint3D32f[nImages][]; PointF[][] imagePoints1 = new PointF[nImages][]; PointF[][] imagePoints2 = new PointF[nImages][]; Size imageSize = new Size( (int) FPinInSensorSize[0].x, (int) FPinInSensorSize[0].y); ExtrinsicCameraParameters interCameraExtrinsics; Matrix<double> foundamentalMatrix; Matrix<double> essentialMatrix; IntrinsicCameraParameters intrinsics1 = FPinInIntrinsics1[0].intrinsics; IntrinsicCameraParameters intrinsics2 = FPinInIntrinsics2[0].intrinsics; imagePoints1 = MatrixUtils.ImagePoints(FPinInImage1, nPointsPerImage); imagePoints2 = MatrixUtils.ImagePoints(FPinInImage2, nPointsPerImage); for (int i=0; i<nImages; i++) { objectPoints[i] = MatrixUtils.ObjectPoints(FPinInObject, true); } try { CameraCalibration.StereoCalibrate(objectPoints, imagePoints1, imagePoints2, intrinsics1, intrinsics2, imageSize, flags, termCrit, out interCameraExtrinsics, out foundamentalMatrix, out essentialMatrix); Extrinsics extrinsics = new Extrinsics(interCameraExtrinsics); FPinOutExtrinsics[0] = extrinsics; FPinOutTransform[0] = extrinsics.Matrix; FPinOutSuccess[0] = true; FStatus[0] = "OK"; } catch (Exception e) { FPinOutSuccess[0] = false; FStatus[0] = e.Message; } } }
//called when data for any output pin is requested public void Evaluate(int SpreadMax) { if (FPinInDo[0]) { bool useVVVVCoords = FPinInCoordSystem[0] == TCoordinateSystem.VVVV; SpreadMax = Math.Max(FPinInObject.SliceCount, FPinInImage.SliceCount); FPinOutExtrinsics.SliceCount = SpreadMax; FPinOutStatus.SliceCount = SpreadMax; for (int i = 0; i < SpreadMax; i++) { try { if (FPinInObject[i].SliceCount == 0 || FPinInImage[i].SliceCount == 0) throw new Exception("No datapoints"); if (FPinInImage[i].SliceCount == 1) throw new Exception("Only 1 image point is being input per board, check SliceCount!"); if (FPinInObject[i].SliceCount == 1) throw new Exception("Only 1 object point is being input per board, check SliceCount!"); if (FPinInIntrinsics[i].intrinsics == null) throw new Exception("Waiting for camera calibration intrinsics"); ExtrinsicCameraParameters extrinsics = CameraCalibration.FindExtrinsicCameraParams2(MatrixUtils.ObjectPoints(FPinInObject[i], useVVVVCoords), MatrixUtils.ImagePoints(FPinInImage[i]), FPinInIntrinsics[i].intrinsics); FPinOutExtrinsics[i] = new Extrinsics(extrinsics); if (useVVVVCoords) FPinOutView[i] = MatrixUtils.ConvertToVVVV(FPinOutExtrinsics[i].Matrix); else FPinOutView[i] = FPinOutExtrinsics[i].Matrix; FPinOutStatus[i] = "OK"; } catch (Exception e) { FPinOutStatus[i] = e.Message; } } } }