我已准备好连接IP摄像机的代码,但我不知道如何获取我捕获的信息并放入Java FX的窗口中进行显示,我使用OPENCV作为库来连接IP相机!!!!你能帮我完成学业吗?
package javaapplication1;
import org.opencv.core.Mat;
import org.opencv.videoio.VideoCapture;
public class App {
static {
String path = null;
try {
//I have copied dlls from opencv folder to my project folder
path = "C:\\Users\\danie\\Downloads\\opencv\\OPENCV";
System.load(path+"\\opencv_java341.dll");
System.load(path+"\\opencv_ffmpeg341_64.dll");
} catch (UnsatisfiedLinkError e) {
System.out.println("Error loading libs");
}
}
public static void main(String[] args) {
App app = new App();
//Address can be different. Check your cameras manual. :554 a standard RTSP port for cameras but it can be different
String addressString = "rtsp://192.168.1.205/user=admin_password=_channel=1_stream=0.sdp";
Mat mat = new Mat();
VideoCapture capturedVideo = new VideoCapture();
boolean isOpened = capturedVideo.open(addressString);
app.openRTSP(isOpened, capturedVideo, mat);
}
public void openRTSP(boolean isOpened, VideoCapture capturedVideo, Mat
cameraMat) {
if (isOpened) {
boolean tempBool = capturedVideo.read(cameraMat);
System.out.println("VideoCapture returned mat? "+tempBool);
if (!cameraMat.empty()) {
System.out.println("Print image size: "+cameraMat.size());
//processing image captured in cameraMat object
} else {
System.out.println("Mat is empty.");
}
} else {
System.out.println("Camera connection problem. Check addressString");
}
}
}