import QtQuick 2.3
import QtQuick.Controls 1.2
import QtMultimedia 5.5
ApplicationWindow {
visible: true
width: 640
height: 480
title: qsTr("Hello World")
Item {
width: parent.width
height: parent.height
Camera {
id: camera
imageProcessing.whiteBalanceMode: CameraImageProcessing.WhiteBalanceFlash
exposure {
exposureCompensation: -1.0
exposureMode: Camera.ExposurePortrait
}
flash.mode: Camera.FlashRedEyeReduction
imageCapture {
onImageCaptured: {
photoPreview.source = preview // Show the preview in an Image
}
onCaptureFailed: {
console.log("Camera disconnect");
}
}
onAvailabilityChanged: {
if(camera.availability!=Camera.Available)
{
console.log("Camera disconnect");
}
}
onCameraStateChanged: {
if(camera.cameraState==Camera.UnloadedStatus){
console.log("Camera disconnect nedaaa");
}
}
onCameraStatusChanged: {
if(camera.cameraStatus!=Camera.ActiveStatus){
console.log("Camera disconnect");
}
if (cameraStatus == Camera.ActiveStatus) {
var fr = camera.supportedViewfinderFrameRateRanges();
fpsList.model = fr;
var res = camera.supportedViewfinderResolutions();
resolutionList.model = res;
}
}
onError: {
camera.unlock();
console.error("error: " + camera.errorString);
}
}
VideoOutput {
id: viewfinder
source: camera
anchors.fill: parent
focus : visible
}
Image {
id: photoPreview
}
Row{
Rectangle {
width: 200
height: 200
id: frame
color: "green"
ListView {
id:fpsList
height: 200
width:200
snapMode:ListView.SnapOneItem
highlightRangeMode :ListView.ApplyRange
highlight: Rectangle { color: "red"; radius: 5 }
delegate: Item {
height: 40
width:200
Text {
text: modelData.minimumFrameRate +" x "+modelData.maximumFrameRate
anchors.fill: parent
anchors.margins: 5
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
color: "white"
font.bold: true
style: Text.Raised
styleColor: "black"
font.pixelSize: 14
}
MouseArea {
anchors.fill: parent
onClicked: {
camera.viewfinder.minimumFrameRate = modelData.minimumFrameRate;
camera.viewfinder.maximumFrameRate = modelData.maximumFrameRate;
fpsList.currentIndex = index;
}
}
Component.onCompleted: {
if ((modelData.minimumFrameRate == camera.viewfinder.minimumFrameRate) && (modelData.maximumFrameRate == camera.viewfinder.maximumFrameRate)) {
fpsList.currentIndex = index;
}
}
}
add: Transition {
NumberAnimation { properties: "x,y"; from: 100; duration: 1000 }
}
addDisplaced: Transition {
NumberAnimation { properties: "x,y"; duration: 1000 }
}
displaced: Transition {
NumberAnimation { properties: "x,y"; duration: 1000 }
}
}
}
Rectangle {
width: 200
height: 200
id: hhh
color: "blue"
ListView {
id:cameraList
model: QtMultimedia.availableCameras
height: 200
width:200
snapMode:ListView.SnapOneItem
highlightRangeMode :ListView.ApplyRange
highlight: Rectangle { color: "red"; radius: 5 }
delegate: Item {
height: 40
width:200
Text {
text: modelData.displayName
anchors.fill: parent
anchors.margins: 5
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
color: "white"
font.bold: true
style: Text.Raised
styleColor: "black"
font.pixelSize: 14
}
MouseArea {
anchors.fill: parent
onClicked: {
cameraList.currentIndex = index
camera.deviceId = modelData.deviceId
//cameraList.selected(modelData.deviceId)
}
}
Component.onCompleted: {
if (modelData.displayName === camera.displayName) {
cameraList.currentIndex = index;
}
}
}
add: Transition {
NumberAnimation { properties: "x,y"; from: 100; duration: 1000 }
}
addDisplaced: Transition {
NumberAnimation { properties: "x,y"; duration: 1000 }
}
displaced: Transition {
NumberAnimation { properties: "x,y"; duration: 1000 }
}
}
}
Rectangle {
height: 200
width:200
color: "yellow"
ListView {
id:resolutionList
height: 200
width:200
highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
snapMode:ListView.SnapOneItem
highlightRangeMode :ListView.ApplyRange
delegate: Item {
height: 40
width:200
Text {
color:"green"
text: modelData.width + "x" + modelData.height
MouseArea {
anchors.fill: parent
onClicked: {
camera.stop();
camera.viewfinder.resolution = Qt.size(modelData.width, modelData.height);
camera.start();
resolutionList.currentIndex = index;
}
}
}
Component.onCompleted: {
if ((modelData.height == camera.viewfinder.resolution.height) && (modelData.width == camera.viewfinder.resolution.width)) {
resolutionList.currentIndex = index;
}
}
}
}
}
Button{
text: "stop"
onClicked: {
camera.stop();
}
}
Button{
id:btnStart
text: "start"
onClicked: {
camera.start();
}
}
}
}
}
Bookmarks