Java源码示例:org.bytedeco.javacv.ProjectiveDevice

示例1
@Deprecated
public static ProjectiveDeviceP loadProjectiveDevice(String filename, int id) throws Exception {
    ProjectiveDeviceP p = new ProjectiveDeviceP();
    try {
        ProjectiveDevice[] camDev = ProjectiveDevice.read(filename);
        if (camDev.length <= id) {
            throw new Exception("No projective device with the id " + id + " in the calibration file: " + filename);
        }
        ProjectiveDevice projectiveDevice = camDev[id];
        p.device = projectiveDevice;
        loadParameters(projectiveDevice, p);
    } catch (Exception e) {
        throw new Exception("Error reading the calibration file : " + filename + " \n" + e);
    }
    return p;
}
 
示例2
/**
 * Create a Geometric Calibrator for a given resolution.
 *
 * @param width
 * @param height
 * @param name
 * @return
 */
public static GeometricCalibratorP createGeometricCalibrator(int width, int height, String name) {
    ProjectiveDevice d = new ProjectiveDevice(name);
    d.imageWidth = width;
    d.imageHeight = height;
    d.setSettings(new ProjectiveDevice.CalibrationSettings());

    return new GeometricCalibratorP(d);
}
 
示例3
public static ProjectiveDeviceP createDevice(float fx, float fy, float cx, float cy, int w, int h,
            float k1, float k2, float k3, float k4, float k5) {
        ProjectiveDeviceP p = new ProjectiveDeviceP();
        // Do not update the handle distorsions ?
//        p.handleDistorsion = false;
        p.w = w;
        p.h = h;
        p.intrinsics = new PMatrix3D(fx, 0, cx, 0,
                0, fy, cy, 0,
                0, 0, 0, 0,
                0, 0, 0, 0);
        p.updateFromIntrinsics();

        p.device = new ProjectiveDevice("device");
        ProjectiveDevice d = p.device;

        d.cameraMatrix = CvMat.create(3, 3);

        d.cameraMatrix.put(fx, 0.0, cx,
                0.0, fy, cy,
                0.0, 0.0, 1);

        d.imageWidth = w;
        d.imageHeight = h;
        d.distortionCoeffs = CvMat.create(1, 5);
        d.distortionCoeffs.put(0, k1);
        d.distortionCoeffs.put(1, k2);
        d.distortionCoeffs.put(2, k3);
        d.distortionCoeffs.put(3, k4);
        d.distortionCoeffs.put(4, k5);
        p.handleDistorsion = true;

        return p;
    }
 
示例4
public static void loadParameters(ProjectiveDevice dev, ProjectiveDeviceP p) {
    double[] camMat = dev.cameraMatrix.get();

    p.handleDistorsion = dev.distortionCoeffs != null;

    p.intrinsics = new PMatrix3D((float) camMat[0], (float) camMat[1], (float) camMat[2], 0,
            (float) camMat[3], (float) camMat[4], (float) camMat[5], 0,
            (float) camMat[6], (float) camMat[7], (float) camMat[8], 0,
            0, 0, 0, 1);

    p.w = dev.imageWidth;
    p.h = dev.imageHeight;

    p.updateFromIntrinsics();

    p.hasExtrinsics = dev.R != null && dev.T != null;

    if (p.hasExtrinsics()) {
        double[] projR = dev.R.get();
        double[] projT = dev.T.get();

        p.extrinsics = new PMatrix3D((float) projR[0], (float) projR[1], (float) projR[2], (float) projT[0],
                (float) projR[3], (float) projR[4], (float) projR[5], (float) projT[1],
                (float) projR[6], (float) projR[7], (float) projR[8], (float) projT[2],
                0, 0, 0, 1);
    }
    p.device = dev;
}
 
示例5
public RealityAugmentor(Settings settings,
         ObjectFinder  .Settings objectFinderSettings,
         MarkerDetector.Settings markerDetectorSettings,
         VirtualBall   .Settings virtualBallSettings,
         ProjectiveDevice camera, ProjectiveDevice projector,
         int channels) throws Exception {
    setSettings(settings);
    this.objectFinderSettings   = objectFinderSettings;
    this.markerDetectorSettings = markerDetectorSettings;
    this.virtualBallSettings    = virtualBallSettings;
    this.camera    = camera;
    this.projector = projector;
    this.channels  = channels;
}
 
示例6
/**
 * Create a calibrator with default settings.
 *
 * @param projectiveDevice
 */
public GeometricCalibratorP(ProjectiveDevice projectiveDevice) {

    // MarkerDetector.settings is not used
    super(new GeometricCalibrator.Settings(), new MarkerDetector.Settings(), null, projectiveDevice);
}
 
示例7
public ProjectiveDevice getProjectiveDevice() {
    return this.projectiveDevice;
}
 
示例8
public ProjectiveDevice getDevice() {
    return this.device;
}
 
示例9
public void writeParameters(File file) {
    ProjectiveDevice.write(file.getAbsolutePath(), cameraDevices, projectorDevices);
}
 
示例10
/**
 * Requires a ProjectiveDevice with image size set in the ProjectiveDevice.
 *
 * @param settings
 * @param projectiveDevice
 */
public GeometricCalibratorP(Settings settings, ProjectiveDevice projectiveDevice) {
    super(settings, null, null, projectiveDevice);
}