/// <summary> /// Gets the camera parameters corresponding to /// the supplied calibration image. /// </summary> /// <returns>Camera parameters</returns> public HTuple getCameraParams(CalibImage image) { HTuple campar; int paramsListSize = 8; int offset = 0; bool areaScanPoly = false; if (mCameraType == CalibrationAssistant.CAMERA_TYP_AREA_SCAN_POLY) { paramsListSize = 12; offset = 4; areaScanPoly = true; } paramsListSize += (mCameraType == CalibrationAssistant.CAMERA_TYP_LINE_SCAN) ? 3 : 0; campar = new HTuple(paramsListSize); campar[0] = (isTelecentric ? 0.0 : ((double)mFocalLength / 1000000.0)); if (areaScanPoly) { campar[1] = mK1; campar[2] = mK2; campar[3] = mK3; campar[4] = mP1; campar[5] = mP2; } else { campar[1] = mKappa; } campar[2 + offset] = (double)mCellWidth / 1000000000.0; // Sx -width -> * 10^ -9 campar[3 + offset] = (double)mCellHeight / 1000000000.0; // Sy -height -> * 10^ -9 campar[4 + offset] = image.Width * 0.5; // x -principal point campar[5 + offset] = image.Height * 0.5; // y -principal point campar[6 + offset] = image.Width; // imagewidth campar[7 + offset] = image.Height; // imageheight if (paramsListSize == 11) { campar[8] = mMotionVx / 1000000.0; campar[9] = mMotionVy / 1000000.0; campar[10] = mMotionVz / 1000000.0; campar[5 + offset] = 0; // y -principal point = 0 for line scan camera } return campar; }
/// <summary> /// Add a new calibration image to the list <c>CalibData</c>. /// The image is read from the location <c>filename</c> /// and a new calibration image instance is then /// generated, embedding this image. /// As a preparation step prior to the calibration process, the /// basic information for the calibration image are determined, /// in terms of: detection of the region plate and the marks /// and pose. /// </summary> /// <returns> /// Instance of a calibration image model created for /// the calibration image, supplied by <c>filename</c> /// </returns> public CalibImage addImage(string filename) { //HImage image = null; CalibImage data = null; try { //image = new HImage(filename); data = new CalibImage(filename, this); CalibData.Add(data); data.UpdateCaltab(true); mCanCalib = (mCanCalib && (data.CanCalibFlag == 0)); mCalibValid = false; } catch (HOperatorException e) { mErrorMessage = e.Message; NotifyCalibObserver(CalibrationAssistant.ERR_READING_FILE); } return data; }
/// <summary> /// Calls the actual <c>addQualityIssue</c> /// method, with the feature list obtained from the /// calibration image <c>cImg</c> /// </summary> /// <param name="cImg"> /// Calibration image model, which has been tested for /// the quality feature defined with <c>type</c> /// </param> /// <param name="type"> /// Constant starting with QUALITY_* describing one of the quality /// features /// </param> /// <param name="score"> /// Score determined for the quality feature /// </param> public void addQualityIssue(CalibImage cImg, int type, double score) { ArrayList qList = cImg.GetQualityIssueList(); addQualityIssue(qList, type, score); }
/// <summary> /// Tests different quality features for the calibration image /// <c>cImg</c> /// </summary> /// <returns> /// Returns a value indicating the success or failure /// of the quality assessment /// </returns> public bool testQualityIssues(CalibImage cImg) { ArrayList qList; HObject markContours; HObject plateRegion; HImage mImg; HTuple score, score2, contrast; int numRegions, numContours; bool qualityFailure; mImg = cImg.GetImage(); qList = cImg.GetQualityIssueList(); procedure = new QualityProcedures(); contrast = new HTuple(); qualityFailure = false; // DescriptionFileName = mDescrFileName; ; try { procedure.find_caltab_edges(mImg, out plateRegion, out markContours, new HTuple(mDescrFileName)); numRegions = plateRegion.CountObj(); numContours = markContours.CountObj(); if (mImageTests < QUALITY_ISSUE_TEST_NONE) { if (numRegions == 0) { qualityFailure = true; } else { procedure.eval_caltab_overexposure(mImg, plateRegion, out score); addQualityIssue(qList, QUALITY_ISSUE_IMG_EXPOSURE, score.D); } if (numContours == 0) { qualityFailure = true; } else { procedure.eval_caltab_contrast_homogeneity(mImg, markContours, out contrast, out score, out score2); addQualityIssue(qList, QUALITY_ISSUE_IMG_CONTRAST, score.D); addQualityIssue(qList, QUALITY_ISSUE_IMG_HOMOGENEITY, score2.D); procedure.eval_caltab_size(mImg, plateRegion, markContours, out score); addQualityIssue(qList, QUALITY_ISSUE_IMG_CALTAB_SIZE, score.D); } if (mImageTests == QUALITY_ISSUE_TEST_ALL) { procedure.eval_caltab_focus(mImg, markContours, contrast, out score); addQualityIssue(qList, QUALITY_ISSUE_IMG_FOCUS, score.D); } } } catch (HOperatorException e) { throw (e); } return qualityFailure; }