org.bytedeco.javacv.Marker Java Examples

The following examples show how to use org.bytedeco.javacv.Marker. 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: GeometricCalibratorP.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
     *  Add the markers, both the model and detected markers.
     *
     * @param model stored in a MarkerboardSvg object.
     * @param detected Found by a camera.
     */
    public void addMarkers(MarkerList model, DetectedMarker[] detected) {

        int maxLength = Math.min(model.size(), detected.length);

//        MarkerSvg[] om = new MarkerSvg[maxLength];
//        DetectedMarker[] im = new DetectedMarker[maxLength];
        Marker[] om = new Marker[maxLength];
        Marker[] im = new Marker[maxLength];

        int k = 0;

        for (MarkerSvg m1 : model.values()) {
            for (int i = 0; i < detected.length; i++) {
                DetectedMarker m2 = detected[i];
                if (m1.getId() == m2.getId() && m2.confidence == 1) {
                    om[k] = m1.copyAsMarker();
                    im[k] = m2.copyAsMarker();
                    k++;
                    break;
                }
            }
        }

        // matching markers
        if (k > 0) {
            
            // resize the array
            if (k < maxLength) {
                om = Arrays.copyOf(om, k);
                im = Arrays.copyOf(im, k);
            }
            this.getAllObjectMarkers().add(om);
            this.getAllImageMarkers().add(im);
        }

    }
 
Example #2
Source File: MarkerSvg.java    From PapARt with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Marker copyAsMarker() {
    double[] corners = new double[this.corners.length * 4];
    int k = 0;
    for (int i = 0; i < this.corners.length; i++) {
        corners[k++] = this.corners[i].x;
        corners[k++] = this.corners[i].y;
    }
    return new org.bytedeco.javacv.Marker(id, corners, 1.0);
}
 
Example #3
Source File: MainFrame.java    From procamcalib with GNU General Public License v2.0 5 votes vote down vote up
void loadSettings(File file) throws IOException, IntrospectionException, PropertyVetoException {
    if (file == null) {
        cameraSettings = null;
        projectorSettings = null;
        markerSettings = null;
        markerDetectorSettings = null;
        geometricCalibratorSettings = null;
        colorCalibratorSettings = null;
        calibrationFile = null;
        calibrationWorker = null;
    } else {
        XMLDecoder decoder = new XMLDecoder(new BufferedInputStream(new FileInputStream(file)));
        cameraSettings = (CameraSettings)decoder.readObject();
        projectorSettings = (ProjectorSettings)decoder.readObject();
        markerSettings = (Marker.ArraySettings)decoder.readObject();
        markerDetectorSettings = (MarkerDetector.Settings)decoder.readObject();
        geometricCalibratorSettings = (CalibrationWorker.GeometricSettings)decoder.readObject();
        colorCalibratorSettings = (CalibrationWorker.ColorSettings)decoder.readObject();
        try {
            String s = (String)decoder.readObject();
            calibrationFile = s == null ? null : new File(s);
        } catch (java.lang.ArrayIndexOutOfBoundsException ex) { }
        decoder.close();
    }

    settingsFile = file;
    if (settingsFile == null) {
        setTitle(PRO_CAM_CALIB);
    } else {
        setTitle(settingsFile.getName() + " - ProCamCalib");
    }

    buildSettingsView();
    updatePatterns(null);

    if (calibrationWorker == null) {
        statusLabel.setText("No calibration data.");
    }
}
 
Example #4
Source File: DetectedMarker.java    From PapARt with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Marker copyAsMarker() {
    return new org.bytedeco.javacv.Marker(id, corners, confidence);
}
 
Example #5
Source File: MainFrame.java    From procamcalib with GNU General Public License v2.0 4 votes vote down vote up
void buildSettingsView() throws IntrospectionException, PropertyVetoException {
        HashMap<String, Class<? extends PropertyEditor>> editors =
                new HashMap<String, Class<? extends PropertyEditor>>();
        editors.put("frameGrabber", FrameGrabber.PropertyEditor.class);

        // hide settings we do not need from the user...
        editors.put("triggerMode", null);
        editors.put("imageMode", null);
        editors.put("timeout", null);
        editors.put("deviceFilename", null);
        editors.put("useOpenGL", null);
//        editors.put("nominalDistance", null);

        if (cameraSettings == null) {
            cameraSettings = new CameraSettings();
            cameraSettings.setFrameGrabber(FrameGrabber.getDefault());
            cameraSettings.setQuantity(1);
        }
        cameraSettings.addPropertyChangeListener(this);
        BeanNode cameraNode = new CleanBeanNode<CameraSettings>
                (cameraSettings, editors, "Cameras");

        if (projectorSettings == null) {
            projectorSettings = new ProjectorSettings();
            projectorSettings.setQuantity(1);
        }
        projectorSettings.addPropertyChangeListener(this);
        BeanNode projectorNode = new CleanBeanNode<ProjectorSettings>
                (projectorSettings, editors, "Projectors");

        if (markerSettings == null) {
            markerSettings = new Marker.ArraySettings();
        }
        markerSettings.addPropertyChangeListener(this);
        BeanNode markerNode = new CleanBeanNode<Marker.ArraySettings>
                (markerSettings, null, "MarkerPatterns");

        if (markerDetectorSettings == null) {
            markerDetectorSettings = new MarkerDetector.Settings();
        }
        BeanNode detectorNode = new CleanBeanNode<MarkerDetector.Settings>
                (markerDetectorSettings, null, "MarkerDetector");

        if (geometricCalibratorSettings == null) {
            geometricCalibratorSettings = new CalibrationWorker.GeometricSettings();
        }
        BeanNode geometricCalibratorNode = new CleanBeanNode<CalibrationWorker.GeometricSettings>
                (geometricCalibratorSettings, null, "GeometricCalibrator");

        if (colorCalibratorSettings == null) {
            colorCalibratorSettings = new CalibrationWorker.ColorSettings();
        }
        colorCalibratorSettings.addPropertyChangeListener(this);
        BeanNode colorCalibratorNode = new CleanBeanNode<CalibrationWorker.ColorSettings>
                (colorCalibratorSettings, null, "ColorCalibrator");

        Children children = new Children.Array();
        children.add(new Node[] { cameraNode, projectorNode, markerNode, detectorNode, 
                geometricCalibratorNode, colorCalibratorNode });

        Node root = new AbstractNode(children);
        root.setName("Settings");
        manager.setRootContext(root);
    }