public void performCompleteMeasurement(MeasurementPoint meas_point) throws RadiometryException { try { if (CameraHeadMeasurementPoint.class.isInstance(meas_point)) { CameraHeadMeasurementPoint _camera_point = (CameraHeadMeasurementPoint) meas_point; int _width = captureDevice.getImageWidth(); int _height = captureDevice.getImageHeight(); _camera_point.setMeasurementImage(new BufferedImage(_width, _height, RASTER_TYPE)); capturedImage = captureDevice.captureImage(capturedImage); int _capt_index = 0; WritableRaster _raster = _camera_point.getMeasurementImage().getRaster(); for (int _row = 0; _row < _height; _row++) { for (int _col = 0; _col < _width; _col++) { int _value = capturedImage[_capt_index++]; _raster.setSample(_col, _row, 0, _value); } } } else { throw new RadiometryException( "Bad MeasurementPoint type : " + meas_point.getClass().getName()); } } catch (ImageCaptureException _e) { throw new RadiometryException("Camera error", _e); } }
public void loadMeasurementPart( MeasurementPoint meas_point, String part_name, InputStream part_stream) throws RadiometryException { try { if (!part_name.startsWith(PART_NAME)) { throw new RadiometryException( "Bad part name : " + part_name + " instead of beginning with " + PART_NAME); } BufferedImage _read_img = ImageIO.read(part_stream); if (_read_img == null) { throw new RadiometryException("Cannot read that kind of image"); } if (_read_img.getType() != RASTER_TYPE) { // convert to the right image type BufferedImage _converted_img = new BufferedImage(_read_img.getWidth(), _read_img.getHeight(), RASTER_TYPE); for (int _conv_lgn = 0; _conv_lgn < _read_img.getHeight(); _conv_lgn++) { for (int _conv_row = 0; _conv_row < _read_img.getWidth(); _conv_row++) { _converted_img.setRGB(_conv_row, _conv_lgn, _read_img.getRGB(_conv_row, _conv_lgn)); } } _read_img = _converted_img; // throw new RadiometryException("wrong measurement part image type : " + // _read_img.getType() + " instead of" + RASTER_TYPE); } if (CameraHeadMeasurementPoint.class.isInstance(meas_point)) { ((CameraHeadMeasurementPoint) meas_point).setMeasurementImage(_read_img); } else { throw new RadiometryException( "bad MeasurementPoint type : " + meas_point.getClass().getName()); } } catch (IOException _e) { throw new RadiometryException("cannot retrieve saved image", _e); } }
public void saveMeasurementPart( MeasurementPoint meas_point, String part_name, OutputStream part_stream) throws RadiometryException { if (!part_name.startsWith(PART_NAME)) { throw new RadiometryException( "Bad part name : " + part_name + " instead of beginning with " + PART_NAME); } try { if (CameraHeadMeasurementPoint.class.isInstance(meas_point)) { if (!ImageIO.write( ((CameraHeadMeasurementPoint) meas_point).getMeasurementImage(), imageFormatUnformalName, part_stream)) { throw new RadiometryException( "Cannot write image : error writing " + imageFormatUnformalName + " image type"); } } else { throw new RadiometryException( "Bad MeasurementPoint type : " + meas_point.getClass().getName()); } } catch (IOException _e) { throw new RadiometryException("Cannot write image", _e); } }