Results 1 to 13 of 13

Thread: qml change the resolution before camera capture picture

  1. #1
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default qml change the resolution before camera capture picture

    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.

    Qt Code:
    1. var w=camera.viewfinder.resolution.width;
    2. var h=camera.viewfinder.resolution.height;
    3. setMaxResulotion();
    4. camera.imageCapture.capture()
    5. camera.viewfinder.resolution.width = w;
    6. camera.viewfinder.resolution.height = h;
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qml change the resolution before camera capture picture

    What does setMaxResulotion() do?

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

    Cheers,
    _

  3. #3
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by anda_skoa View Post
    What does setMaxResulotion() do?
    _
    Set max Resulotion for camera.

    Quote Originally Posted by anda_skoa View Post
    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
    Last edited by neda; 3rd May 2016 at 10:03.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by neda View Post
    Set max Resulotion for camera.
    And you have verified that this works?

    Quote Originally Posted by neda View Post
    Yes. I want after capture camera will have the same low resolution
    Have you tried setting these values after the capture has finished?

    Cheers,
    _

  5. #5
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by anda_skoa View Post
    And you have verified that this works?
    _
    Qt Code:
    1. function setMaxResulotion(){
    2. var res = camera.supportedViewfinderResolutions();
    3. camera.viewfinder.resolution.width = res[res.length-1].width;
    4. camera.viewfinder.resolution.height = res[res.length-1].height;
    5.  
    6. for(var i=0;i<res.length;i++)
    7. {
    8. if(res[i].width>camera.viewfinder.resolution.width)
    9. {
    10. camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height)
    11. }
    12. else if(res[i].width===camera.viewfinder.resolution.width){
    13.  
    14. if(res[i].height>camera.viewfinder.resolution.height)
    15. {
    16. camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
    17. }
    18. }
    19. }
    20. }
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by anda_skoa View Post
    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:
    Qt Code:
    1. QCameraImageCapture error: "Camera not ready for capture"
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. var w=camera.viewfinder.resolution.width;
    2. console.log("w1:"+w) //=> low resolution.width
    3. var h=camera.viewfinder.resolution.height;
    4. setMaxResulotion();//set highest resolution
    5. console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
    6. console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height
    7. camera.imageCapture.capture() // error : QCameraImageCapture error: "Camera not ready for capture"
    8. camera.viewfinder.resolution.width = w;
    9. console.log("w1:"+camera.viewfinder.resolution.width ) == > //output = qml: w1:-1
    10. camera.viewfinder.resolution.height = h;
    To copy to clipboard, switch view to plain text mode 
    Last edited by neda; 3rd May 2016 at 11:29.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by neda View Post
    Yes,
    Quote Originally Posted by neda View Post
    I tried capture with highest resolution.
    But I have this error when use "setMaxResulotion" function:
    Qt Code:
    1. QCameraImageCapture error: "Camera not ready for capture"
    To copy to clipboard, switch view to plain text mode 
    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
    Qt Code:
    1. var largestSize = 0;
    2. for(var i=0;i<res.length;i++) {
    3. var currentSize = res[i].width * res[i].height;
    4. if (currentSize > largestSize) {
    5. largestSize = currentSize;
    6. camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by neda View Post
    Qt Code:
    1. camera.viewfinder.resolution.width = w;
    2. console.log("w1:"+camera.viewfinder.resolution.width ) == > //output = qml: w1:-1
    3. camera.viewfinder.resolution.height = h;
    To copy to clipboard, switch view to plain text mode 
    What I meant was: don't do this after the call to capture(), do this once capture has finished.

    Cheers,
    _

  7. #7
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by anda_skoa View Post
    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:
    Qt Code:
    1. setMaxResulotion();//set highest resolution
    2. console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
    3. console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by anda_skoa View Post
    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
    Qt Code:
    1. var largestSize = 0;
    2. for(var i=0;i<res.length;i++) {
    3. var currentSize = res[i].width * res[i].height;
    4. if (currentSize > largestSize) {
    5. largestSize = currentSize;
    6. camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
    7. }
    8. }
    To copy to clipboard, switch view to plain text mode 


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

    _
    I update my code:
    Qt Code:
    1. MyToolButton{
    2. iconSource:"images/photo.png"
    3. tooltip: "save photo"
    4. onClicked: {
    5. var res = camera.supportedViewfinderResolutions();
    6. var largestSize = 0;
    7. for(var i=0;i<res.length;i++) {
    8. var currentSize = res[i].width * res[i].height;
    9. if (currentSize > largestSize) {
    10. largestSize = currentSize;
    11. camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
    12. }
    13. }
    14. camera.imageCapture.capture()
    15.  
    16. saveImageFileDialog.open();
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 

    But I have still the same error.
    QCameraImageCapture error: "Camera not ready for capture"

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by neda View Post
    Excuse me
    I mean, "setMaxResulotion" function works
    And the camera is set to the highest resolution after this code:
    Qt Code:
    1. setMaxResulotion();//set highest resolution
    2. console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
    3. console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height
    To copy to clipboard, switch view to plain text mode 
    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,
    _

  9. #9
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qml change the resolution before camera capture picture

    Thank you,
    When I put "console.log" after change resolution of camera I see resolution of camera is correct(in application output window)
    Qt Code:
    1. var res = camera.supportedViewfinderResolutions();
    2. var largestSize = 0;
    3. for(var i=0;i<res.length;i++) {
    4. var currentSize = res[i].width * res[i].height;
    5. if (currentSize > largestSize) {
    6. largestSize = currentSize;
    7. camera.viewfinder.resolution = Qt.size(res[i].width,res[i].height);
    8. }
    9. }
    10. console.log("w2:"+camera.viewfinder.resolution.width) //=> ok : highest resolution.width
    11. console.log("h2:"+camera.viewfinder.resolution.height)//=> ok : highest resolution.height
    To copy to clipboard, switch view to plain text mode 

    Then when this line of code runs I have this error:
    Qt Code:
    1. camera.imageCapture.capture()
    To copy to clipboard, switch view to plain text mode 
    QCameraImageCapture error: "Camera not ready for capture"

  10. #10
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by neda View Post
    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,
    _

  11. The following user says thank you to anda_skoa for this useful post:

    neda (4th May 2016)

  12. #11
    Join Date
    Jan 2016
    Posts
    81
    Thanks
    31
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by anda_skoa View Post
    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


    Quote Originally Posted by anda_skoa View Post
    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.
    Qt Code:
    1. var res = camera.supportedViewfinderResolutions();
    2. camera.viewfinder.resolution = Qt.size(res[res.length-1].width,res[res.length-1].height);
    3. camera.imageCapture.capture()
    To copy to clipboard, switch view to plain text mode 
    Last edited by neda; 4th May 2016 at 07:18.

  13. #12
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qml change the resolution before camera capture picture

    Quote Originally Posted by neda View Post
    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,
    _

  14. The following user says thank you to anda_skoa for this useful post:

    neda (4th May 2016)

  15. #13
    Join Date
    Mar 2018
    Posts
    1
    Qt products
    Platforms
    Windows

    Default Re: qml change the resolution before camera capture picture

    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 | Security Cameras Vancouver

Similar Threads

  1. How to change the app resolution
    By roseicollis in forum Newbie
    Replies: 10
    Last Post: 23rd January 2015, 12:11
  2. display camera capture on label->setpixmap
    By mdaud in forum Qt Programming
    Replies: 3
    Last Post: 21st June 2013, 21:50
  3. Replies: 0
    Last Post: 12th June 2013, 07:44
  4. capture video from DV camera
    By ekkondela in forum Newbie
    Replies: 1
    Last Post: 7th March 2010, 10:38
  5. Replies: 0
    Last Post: 7th August 2009, 20:21

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.