Java 我需要用我的无人机摄像头而不是网络摄像头
我试着用我的无人机摄像头代替我的网络摄像头。我正在Eclipse中使用java中的YADrone API和OpenCVJava 我需要用我的无人机摄像头而不是网络摄像头,java,eclipse,opencv,Java,Eclipse,Opencv,我试着用我的无人机摄像头代替我的网络摄像头。我正在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 or
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)时,它仍然以我笔记本电脑上的网络摄像头为目标。我应该如何瞄准无人机摄像头而不是笔记本电脑上的网络摄像头?任何帮助都将不胜感激:)这里有一个NodeJs示例。 其主要思想是使用API(本例中为
Node Ar-Drone
)捕获视频,并将图像帧发送到OpenCV
。在您的情况下,您需要使用api在Java
中访问无人机摄像头,然后将其发送到OpenCV
代码。
您可以使用来自的AR无人机APi,这里是NodeJs中的一个示例。 其主要思想是使用API(本例中为
Node Ar-Drone
)捕获视频,并将图像帧发送到OpenCV
。在您的情况下,您需要使用api在Java
中访问无人机摄像头,然后将其发送到OpenCV
代码。
您可以从VideoCapture(0)使用AR无人机APi打开默认摄像机。尝试使用其他设备id,或使用正确的连接stringVideoCapture(0)打开默认相机。请尝试使用其他设备id或正确的连接字符串