PDA

View Full Version : qml change the resolution before camera capture picture



neda
3rd May 2016, 06:39
Hi
I want to display video with low resolution and capture image with the camera's highest resolution.
I used this code but the image was captured from camera with low resolution.


var w=camera.viewfinder.resolution.width;
var h=camera.viewfinder.resolution.height;
setMaxResulotion();
camera.imageCapture.capture()
camera.viewfinder.resolution.width = w;
camera.viewfinder.resolution.height = h;

anda_skoa
3rd May 2016, 08:50
What does setMaxResulotion() do?

If w/h are the low resolution values, have you tried setting them after the capture has been done?

Cheers,
_

neda
3rd May 2016, 08:58
What does setMaxResulotion() do?
_

Set max Resulotion for camera.



If w/h are the low resolution values, have you tried setting them after the capture has been done?
_

Yes. I want after capture camera will have the same low resolution

1- camera ( low-resolution)
2- capture (take a photo from camera with highest resolution)
3-camera (the same low resolution in step 1)

video => low-resolution , imageCapture=>highest resolution

anda_skoa
3rd May 2016, 09:01
Set max Resulotion for camera.

And you have verified that this works?



Yes. I want after capture camera will have the same low resolution
Have you tried setting these values after the capture has finished?

Cheers,
_

neda
3rd May 2016, 09:09
And you have verified that this works?
_


function setMaxResulotion(){
var res = camera.supportedViewfinderResolutions();
camera.viewfinder.resolution.width = res[res.length-1].width;
camera.viewfinder.resolution.height = res[res.length-1].height;

for(var i=0;i<res.length;i++)
{
if(res[i].width>camera.viewfinder.resolution.width)
{
camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height)
}
else if(res[i].width===camera.viewfinder.resolution.width){

if(res[i].height>camera.viewfinder.resolution.height)
{
camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
}
}
}
}




Have you tried setting these values after the capture has finished?
_
I tried capture with highest resolution.
But I have this error when use "setMaxResulotion" function:

QCameraImageCapture error: "Camera not ready for capture"


var w=camera.viewfinder.resolution.width;
console.log("w1:"+w) //=> low resolution.width
var h=camera.viewfinder.resolution.height;
setMaxResulotion();//set highest resolution
console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height
camera.imageCapture.capture() // error : QCameraImageCapture error: "Camera not ready for capture"
camera.viewfinder.resolution.width = w;
console.log("w1:"+camera.viewfinder.resolution.width ) == > //output = qml: w1:-1
camera.viewfinder.resolution.height = h;

anda_skoa
3rd May 2016, 09:36
Yes,



I tried capture with highest resolution.
But I have this error when use "setMaxResulotion" function:

QCameraImageCapture error: "Camera not ready for capture"

I am confused.
You are saying it works, but also saying it doesn't?

Btw, I think it is easier to just calculate the image size in your "set maximum" function and use that for comparison between offered resolutions.
E.g. something like


var largestSize = 0;
for(var i=0;i<res.length;i++) {
var currentSize = res[i].width * res[i].height;
if (currentSize > largestSize) {
largestSize = currentSize;
camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
}
}






camera.viewfinder.resolution.width = w;
console.log("w1:"+camera.viewfinder.resolution.width ) == > //output = qml: w1:-1
camera.viewfinder.resolution.height = h;
What I meant was: don't do this after the call to capture(), do this once capture has finished.

Cheers,
_

neda
3rd May 2016, 10:49
I am confused.
You are saying it works, but also saying it doesn't?
_

Excuse me
I mean, "setMaxResulotion" function works
And the camera is set to the highest resolution after this code:

setMaxResulotion();//set highest resolution
console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height



Btw, I think it is easier to just calculate the image size in your "set maximum" function and use that for comparison between offered resolutions.
E.g. something like


var largestSize = 0;
for(var i=0;i<res.length;i++) {
var currentSize = res[i].width * res[i].height;
if (currentSize > largestSize) {
largestSize = currentSize;
camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
}
}



What I meant was: don't do this after the call to capture(), do this once capture has finished.

_

I update my code:

MyToolButton{
iconSource:"images/photo.png"
tooltip: "save photo"
onClicked: {
var res = camera.supportedViewfinderResolutions();
var largestSize = 0;
for(var i=0;i<res.length;i++) {
var currentSize = res[i].width * res[i].height;
if (currentSize > largestSize) {
largestSize = currentSize;
camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
}
}
camera.imageCapture.capture()

saveImageFileDialog.open();
}
}


But I have still the same error.

QCameraImageCapture error: "Camera not ready for capture"

anda_skoa
3rd May 2016, 11:38
Excuse me
I mean, "setMaxResulotion" function works
And the camera is set to the highest resolution after this code:

setMaxResulotion();//set highest resolution
console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height

well, the properties have the expected values, but I see that I was asking not precisely enough.
What I meant was "does it work", i.e. does the camera capture at the set resolution.

It seems it doesn't.

Does it work if you don't change the resolution?
If yes, does it work if you change to the first offered resolution?
etc.

Cheers,
_

neda
3rd May 2016, 12:20
Thank you,
When I put "console.log" after change resolution of camera I see resolution of camera is correct(in application output window)


var res = camera.supportedViewfinderResolutions();
var largestSize = 0;
for(var i=0;i<res.length;i++) {
var currentSize = res[i].width * res[i].height;
if (currentSize > largestSize) {
largestSize = currentSize;
camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
}
}
console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height


Then when this line of code runs I have this error:

camera.imageCapture.capture()
QCameraImageCapture error: "Camera not ready for capture"

anda_skoa
3rd May 2016, 12:47
Thank you,
When I put "console.log" after change resolution of camera I see resolution of camera is correct(in application output window)

Is this some kind of unintentional double post?
I think all that information is already in comment #7

Cheers,
_

neda
4th May 2016, 05:56
Does it work if you don't change the resolution?
_
Yes. When I run just "camera.imageCapture.capture()", it work. If I submit capture button after change the resolution every thing is OK. But when I put "change the resolution of camera" before "camera.imageCapture.capture()", it does not work.

Button1 = > Change the resolution = > Is OK
Button2 = > Image Capture => Is OK . If Button2 = > Change the resolution and Image Capture : It does not work




If yes, does it work if you change to the first offered resolution?
_
First offered resolution of camera is highest resolution. (I change the resolution of camera to lower resolution in start of program).
Did you mean? If yes,it does not work.

var res = camera.supportedViewfinderResolutions();
camera.viewfinder.resolution = Qt.size(res[res.length-1].width,res[res.length-1].height);
camera.imageCapture.capture()

anda_skoa
4th May 2016, 09:38
Yes. When I run just "camera.imageCapture.capture()", it work. If I submit capture button after change the resolution every thing is OK. But when I put "change the resolution of camera" before "camera.imageCapture.capture()", it does not work.

Button1 = > Change the resolution = > Is OK
Button2 = > Image Capture => Is OK . If Button2 = > Change the resolution and Image Capture : It does not work

Ok, this is an important data point.
So what you are seeing is that changing the resolution within the same function that calls capture doesn't work but if you have two user interactions triggering them separately, even if immediately after each other, it works.

Maybe check if the camera status changes when you change the resolution.
If not you could try delaying the call to capture() with a timer.

Cheers,
_

lindseynicole010
15th March 2018, 07:47
This feature rich application is accessible for numerous stages, for example, iOS, Android, Windows and Mac. Two separate applications together offer wonderful home security administrations. With the assistance of the camera application, your gadget would transform into a camera. Utilizing the other application, you can surveil it. A portion of the mentionable highlights of AtHome Camera are remote observing, facial acknowledgment, multi-see camera offices, time-pass recording and some more. In the event that you need, you can get the equipment cameras offered with the applications also. The application is accessible for nothing however not the equipment cameras! With a couple of fundamental yet urgent highlights, IP Webcam is a straightforward and simple to-utilize application and a prevalent section in this rundown of home security applications. Utilizing this application, your telephone would transform into a remote camera. Live video spilling, VLC player bolster, movement recognition, bolster for video visit, Dropbox, FTP servers and so forth are a portion of the real highlights of IP Webcam. You can get this application without spending a solitary penny.
Thanks& regards,
Lindsey Nicole
Security Cameras Toronto (http://www.viewtech.ca/) | Security Cameras Vancouver (http://www.viewtech.ca/)