【问题标题】:I need to use my drones camera instead of my webcam我需要使用我的无人机相机而不是我的网络摄像头
【发布时间】:2016-06-23 14:42:12
【问题描述】:

我正在尝试使用我的无人机摄像头而不是我的网络摄像头。我在 Eclipse 的 java 中使用 YADrone API 和 OpenCV。

package Drone;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.videoio.VideoCapture;
import org.opencv.videoio.Videoio;

import de.yadrone.base.IARDrone;    

public class Video{

static {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
}

private JFrame frame;
private JLabel imageLabel;

public static void main(String[] args) {
    Video app = new Video();
    app.initGUI();
    IARDrone drone = null;
    app.runMainLoop(args, drone);
}

private void initGUI() {
    frame = new JFrame("Camera Input Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(700, 450);
    imageLabel = new JLabel();
    frame.add(imageLabel);
    frame.setVisible(true);
}

private void runMainLoop(String[] args, final IARDrone drone) {
    ImageProcessor imageProcessor = new ImageProcessor();
    Mat camMatImage = new Mat();
    Image tempImage;
    VideoCapture capture = new VideoCapture(0);
    capture.set(Videoio.CAP_PROP_FRAME_WIDTH, 800);
    capture.set(Videoio.CAP_PROP_FRAME_HEIGHT, 800);
    if (capture.isOpened()) {
        while (true) {
            capture.read(camMatImage);
            if (!camMatImage.empty()) {
                tempImage = imageProcessor.toBufferedImage(camMatImage);
                ImageIcon imageIcon = new ImageIcon(tempImage, "Captured video");
                imageLabel.setIcon(imageIcon);
                frame.pack(); // this will resize the window to fit the
                                // image
            } else {
                System.out.println(" -- Frame not captured -- Break!");
                break;
            }
        }
    } else {
        System.out.println("Couldn't open capture.");
    }
}
}

当通过 wifi 连接到无人机 (Parrot AR 2.0) 时,它仍然瞄准我笔记本电脑上的网络摄像头。我应该如何瞄准无人机相机而不是笔记本电脑上的网络摄像头?任何帮助将不胜感激:)

【问题讨论】:

  • VideoCapture(0) 打开默认摄像头。尝试使用其他设备 ID,或使用正确的连接字符串

标签: java eclipse opencv


【解决方案1】:

这里有一个 NodeJs 示例。 https://github.com/paulhayes/copterface 主要思想是使用API​​(在本例中为Node Ar Drone)捕获视频,并将图像帧发送到OpenCV。在您的情况下,您需要使用 api 访问 Java 中的无人机摄像头,然后将其发送到您的 OpenCV 代码。 你可以使用来自developer.parrot.com的AR DRone APi

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-02
    • 1970-01-01
    • 2018-11-14
    • 1970-01-01
    • 2011-12-21
    • 2012-05-26
    相关资源
    最近更新 更多