我正在使用一个现成的QT创建者代码(declarative-camera)来开发一个apk,在这个代码中,qt访问计算机的网络摄像头,我试图做一些更改,以便能够访问远程摄像头。
问题:如何使这个远程连接工作?它是一个ip摄像机,我连接到无线网络
注:QML代码
下面是一段代码:
states: [
State {
name: "PhotoCapture"
StateChangeScript {
script: {
camera.captureMode = Camera.CaptureStillImage
camera.start()
}
}
},
State {
name: "PhotoPreview"
},
State {
name: "VideoCapture"
StateChangeScript {
script: {
camera.captureMode = Camera.CaptureVideo
camera.start()
}
}
},
State {
name: "VideoPreview"
StateChangeScript {
script: {
camera.stop()
}
}
}
]
Timer {
interval: 200
running: true
repeat: true
onTriggered: {
image1.cache =false;
image1.source = "rtsp://admin:@192.168.1.10:554/h264/ch0/main/av_stream";
}
}
Camera {
id: camera
captureMode: Camera.CaptureStillImage
imageCapture {
onImageCaptured: {
photoPreview.source = preview
stillControls.previewAvailable = true
cameraUI.state = "PhotoPreview"
}
}
下面是一个完整的代码尝试使这个连接:
import QtQuick 2.0
import QtMultimedia 5.4
Rectangle {
id : cameraUI
width: 800
height: 480
color: "black"
state: "PhotoCapture"
states: [
State {
name: "PhotoCapture"
StateChangeScript {
script: {
camera.captureMode = Camera.CaptureStillImage
camera.start()
}
}
},
State {
name: "PhotoPreview"
},
State {
name: "VideoCapture"
StateChangeScript {
script: {
camera.captureMode = Camera.CaptureVideo
camera.start()
}
}
},
State {
name: "VideoPreview"
StateChangeScript {
script: {
camera.stop()
}
}
}
]
Timer {
interval: 200
running: true
repeat: true
onTriggered: {
image1.cache =false;
image1.source = "rtsp://admin:@192.168.1.10:554/h264/ch0/main/av_stream";
}
}
Camera {
id: camera
captureMode: Camera.CaptureStillImage
imageCapture {
onImageCaptured: {
photoPreview.source = preview
stillControls.previewAvailable = true
cameraUI.state = "PhotoPreview"
}
}
videoRecorder {
resolution: "640x480"
frameRate: 30
}
}
PhotoPreview {
id : photoPreview
anchors.fill : parent
onClosed: cameraUI.state = "PhotoCapture"
visible: cameraUI.state == "PhotoPreview"
focus: visible
}
VideoPreview {
id : videoPreview
anchors.fill : parent
onClosed: cameraUI.state = "VideoCapture"
visible: cameraUI.state == "VideoPreview"
focus: visible
//don't load recorded video if preview is invisible
source: visible ? camera.videoRecorder.actualLocation : ""
}
VideoOutput {
id: viewfinder
visible: cameraUI.state == "PhotoCapture" || cameraUI.state == "VideoCapture"
x: 0
y: 0
width: parent.width - stillControls.buttonsPanelWidth
height: parent.height
source: camera
autoOrientation: true
}
PhotoCaptureControls {
id: stillControls
anchors.fill: parent
camera: camera
visible: cameraUI.state == "PhotoCapture"
onPreviewSelected: cameraUI.state = "PhotoPreview"
onVideoModeSelected: cameraUI.state = "VideoCapture"
}
VideoCaptureControls {
id: videoControls
anchors.fill: parent
camera: camera
visible: cameraUI.state == "VideoCapture"
onPreviewSelected: cameraUI.state = "VideoPreview"
onPhotoModeSelected: cameraUI.state = "PhotoCapture"
}
}
1条答案
按热度按时间ljsrvy3e1#
你可以在python上使用opencv来连接你的远程摄像头,opencv有一个函数(videocapture),可以解决你的问题