-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCameraItem.qml
54 lines (44 loc) · 1.33 KB
/
CameraItem.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import QtQuick 2.0
import QtMultimedia 5.8
import CameraFilter 1.0
VideoOutput {
id: root
// height: width
source: camera
filters: [cameraFilter]
signal fatalError
signal sizeChanged
// signal captureImage(QtObject image)
property var captureReady:camera.imageCapture.ready
onHeightChanged: root.sizeChanged()
Camera {
id: camera
// deviceId: QtMultimedia.availableCameras[1].deviceId
captureMode: Camera.CaptureStillImage
onError: {
if (Camera.NoError != error) {
console.log("[qmlvideo] CameraItem.onError error " + error + " errorString " + errorString)
root.fatalError()
}
}
imageCapture.onImageCaptured: {
// root.captureImage(preview);
}
}
CameraFilter{
id: cameraFilter
}
function start() { camera.start() }
function stop() { camera.stop() }
function switchCamera(deviceid){
for (var i = 0; i < QtMultimedia.availableCameras.length; ++i){
if (deviceid == QtMultimedia.availableCameras[i].deviceId){
camera.deviceId = deviceid
}
}
}
function captureCamera(){
camera.captureMode = Camera.CaptureStillImage
camera.imageCapture.captureToLocation("D:/Test/qtopencv.jpg")
}
}