Java Code Examples for org.bytedeco.javacv.CameraDevice#read()

The following examples show how to use org.bytedeco.javacv.CameraDevice#read() . 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
public static ProjectiveDeviceP loadCameraDevice(PApplet parent, String filename, int id) throws Exception {
    ProjectiveDeviceP p = new ProjectiveDeviceP();

    if (filename.endsWith(".yaml")) {
        CameraDevice[] camDev = CameraDevice.read(filename);
        if (camDev.length <= id) {
            throw new Exception("No camera device with the id " + id + " in the calibration file: " + filename);
        }
        CameraDevice cameraDevice = camDev[id];
        loadParameters(cameraDevice, p);
    }

    if (filename.endsWith((".xml"))) {
        ProjectiveDeviceCalibration calib = new ProjectiveDeviceCalibration();
        calib.loadFrom(parent, filename);
        loadParameters(calib, p);
    }

    return p;
}
 
Example 2
Source File: ARToolkitPlusUtils.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
static public void convertARParam2(PApplet pa, String inputYAML, String outputDAT) throws Exception {
        CameraDevice cam = null;

        // Hack 
        if (inputYAML.endsWith(".xml")) {
            convertARParamXML(pa, inputYAML, outputDAT);
            return;
        }

        CameraDevice[] c = CameraDevice.read(inputYAML);
        if (c.length > 0) {
            cam = c[0];
        }
        CameraDevice.Settings camSettings = (org.bytedeco.javacv.CameraDevice.Settings) cam.getSettings();
        int w = camSettings.getImageWidth();
        int h = camSettings.getImageHeight();

        double[] proj = cam.cameraMatrix.get();

        PrintWriter pw = pa.createWriter(outputDAT);

        StringBuffer sb = new StringBuffer();

//        byte[] buf = new byte[SIZE_OF_PARAM_SET];
//        ByteBuffer bb = ByteBuffer.wrap(buf);
//        bb.order(ByteOrder.BIG_ENDIAN);
//        bb.putInt(w);
//        bb.putInt(h);
        // From ARToolkitPlus...
//http://www.vision.caltech.edu/bouguetj/calib_doc/htmls/parameters.html
        sb.append("ARToolKitPlus_CamCal_Rev02\n");
        sb.append(w).append(" ").append(h).append(" ");

        // cx cy  fx fy  
        sb.append(proj[2]).append(" ").append(proj[5])
                .append(" ").append(proj[0]).
                append(" ").append(proj[4]).append(" ");

        // alpha_c  // skew factor  
        sb.append("0 ").append(" ");

        if (cam.distortionCoeffs != null) {
            double[] distort = cam.distortionCoeffs.get();
            // alpha_c ?  
//        sb.append("0 ");
            // kc(1 - x)  -> 6 values
            for (int i = 0; i < distort.length; i++) {
                sb.append(distort[i]).append(" ");
            }
            for (int i = distort.length; i < 6; i++) {
                sb.append("0 ");
            }
        } else {
            for (int i = 0; i < 6; i++) {
                sb.append("0 ");
            }
        }
        // undist iterations
        sb.append("10\n");

        pw.print(sb);
        pw.flush();
        pw.close();
    }
 
Example 3
Source File: CalibrationWorker.java    From procamcalib with GNU General Public License v2.0 4 votes vote down vote up
public void readParameters(File file) throws Exception {
    String f = file.getAbsolutePath();
    cameraDevices    = CameraDevice   .read(f);
    projectorDevices = ProjectorDevice.read(f);
}