org.bytedeco.javacv.ProjectiveDevice Java Examples

The following examples show how to use org.bytedeco.javacv.ProjectiveDevice. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProjectiveDeviceP.java    From PapARt with GNU Lesser General Public License v3.0 6 votes vote down vote up
@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;
}
 
Example #2
Source File: GeometricCalibratorP.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #3
Source File: ProjectiveDeviceP.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
    }
 
Example #4
Source File: ProjectiveDeviceP.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #5
Source File: RealityAugmentor.java    From procamtracker with GNU General Public License v2.0 5 votes vote down vote up
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;
}
 
Example #6
Source File: GeometricCalibratorP.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * 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);
}
 
Example #7
Source File: ARDisplay.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ProjectiveDevice getProjectiveDevice() {
    return this.projectiveDevice;
}
 
Example #8
Source File: ProjectiveDeviceP.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
public ProjectiveDevice getDevice() {
    return this.device;
}
 
Example #9
Source File: CalibrationWorker.java    From procamcalib with GNU General Public License v2.0 4 votes vote down vote up
public void writeParameters(File file) {
    ProjectiveDevice.write(file.getAbsolutePath(), cameraDevices, projectorDevices);
}
 
Example #10
Source File: GeometricCalibratorP.java    From PapARt with GNU Lesser General Public License v3.0 2 votes vote down vote up
/**
 * 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);
}