×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Focus Range on WP8

    Hello guys,

    Well this week I had an interest in the Imaging(Obviously), and I have a small little question regarding the Manual Focus on the camera, is there a way to change the range of the Focus ? like giving him a "value" between 0-100?

    After searching I only found that we can give it a "rectangle" to focus on (I hope that I did not search well)

    this is what I want to do for example let suppose [+] is our camera:
    given a value of 10 it will focus the nearest object
    [+]----> Object1
    a value of 40
    [+]-------------->Object2
    a value of 90
    [+]------------------------->Object3

    (I know that there is a Wiki article participating in the competition which shows how to focus manualy, but isn't there something ready to use in the API ?)

    Thank you !

  2. #2
    Nokia Developer Champion
    Join Date
    Nov 2011
    Location
    la bouexiere, france
    Posts
    419

    Re: Focus Range on WP8

    Hi.
    I don't understand what you try to do...

    You want give a focus rect + a focus Range to parameters auto focus?

  3. #3
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    427

    Re: Focus Range on WP8

    You could simply use some multiplication factor to translate from the 0 - 1000 range to the 0 - 100 range. You have to be aware though that not all devices have a 0 - 1000 focus range. For HTC devices it is different (all Nokia's I've tried have 0 - 1000, but the HTC 8X is 0 - 44) and Samsung devices don't allow you to focus manually at all (reporting 0 - 0 and crashing when trying to set it to anything so the rectangle is the only way to do it there).

    Or are you trying to use the Auto-Focus but only allowing the Auto-Focus to do focusing in the range from 0 - 100 instead of the full 0 - 1000?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2011
    Location
    Portugal
    Posts
    919

    Re: Focus Range on WP8

    You should use GetSupportedPropertyRange to get the minimum and maximum supported range for each property, including focus position. In this case to get the AutoFocusRange property. Then you can do a conversion from your scale to the supported scale.

    For example lets assume that the supported scale is 0-1000 and you want to convert to your scale.

    To get the match for your mid position 50, you would do something like:

    50 x 1000 / 100 = 500

    To get the match for your mid position 35, you would do something like:

    35 x 1000 / 100 = 350

    If you want to convert from the camera supported values to your own:

    500 x 100 / 1000 = 50
    350 x 100 / 1000 = 35

    That easy

  5. #5
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Re: Focus Range on WP8

    Hello guys and thanks for your answers

    My problem is how to set the focus range instead of using the focus Rectangle, I can't find a property FocusRange or something like that to change

    Ps : the range value between 0-100 was just an example lol

  6. #6
    Nokia Developer Moderator
    Join Date
    Feb 2011
    Location
    Portugal
    Posts
    919

    Re: Focus Range on WP8

    Quote Originally Posted by Loukt View Post
    Hello guys and thanks for your answers

    My problem is how to set the focus range instead of using the focus Rectangle, I can't find a property FocusRange or something like that to change

    Ps : the range value between 0-100 was just an example lol

    You need to use the manual focus to do that. Problem is that not all devices support that. The lumia 920 allows it but I've read somewhere that at least some devices from other brands does not support it.

    For that you will need to do something like this:

    Code:
    photoCaptureDevice.SetProperty(KnownCameraGeneralProperties.ManualFocusPosition, focusPosition);
    Where photoCaptureDevice is an object of type Windows.Phone.Media.Capture.PhotoCaptureDevice and focusPosition is the position withing a valid range.

  7. #7
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Re: Focus Range on WP8

    That's exactly what I needed,
    (doesn't matter for other devices, I focus only on Lumia phones when thinking about the camera)

    Thanks a lot everyone !
    Last edited by Loukt; 2013-08-09 at 12:56.

  8. #8
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    427

    Re: Focus Range on WP8

    That might be ok for Demo applications but given that you can't limit distribution of your Apps to the Lumia range having issues with other devices can hurt your App in the Marketplace. It also might lead to trouble during Marketplace certification. Therefore you absolutely should check for the focus ranges before manipulating them and display an error message if they lack the required range.

    I'm using manual focusing in one of my Apps and it doesn't work on the Huawei and Samsung devices (with the Samsung I just confirmed that it's still not working with GDR2).

  9. #9
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Re: Focus Range on WP8

    Quote Originally Posted by SB Dev View Post
    That might be ok for Demo applications but given that you can't limit distribution of your Apps to the Lumia range having issues with other devices can hurt your App in the Marketplace. It also might lead to trouble during Marketplace certification. Therefore you absolutely should check for the focus ranges before manipulating them and display an error message if they lack the required range.

    I'm using manual focusing in one of my Apps and it doesn't work on the Huawei and Samsung devices (with the Samsung I just confirmed that it's still not working with GDR2).
    Don't worry, I already thought about it, now the remaining question is : if the app require the manual focus, how am I going to tell other devices users that the app is useless for them ?

    Dear buyer,
    Thank you for buying the app, you may want to know that it's useless for you unless you get a Lumia phone,
    Sincerely
    Yassine,

  10. #10
    Nokia Developer Champion
    Join Date
    Sep 2012
    Location
    Morocco
    Posts
    292

    Re: Focus Range on WP8

    Hi guys,

    These two days I tried different approaches, but unfortunately . zero result (and tonight it wouldn't let me sleep)
    I know the code is a real mess, but it's just for testing purpose.


    So now I have a slider on the viewfinderBrush, and when I slide it I want it to change the focus manually

    here is the snippet I'm using, I tried with the first and second approach(the commented Part2), took pictures with 3 different positions for focus (0 , 500 and 1000) but the pictures were the same.
    am I missing something ?

    Code:
     
            private async void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
            {
                var range = PhotoCaptureDevice.GetSupportedPropertyRange(CameraSensorLocation.Back,KnownCameraGeneralProperties.ManualFocusPosition);
                var slidy = (sender as Slider);
                
                //some math tricks 
                Double b = ((UInt32)range.Max - (UInt32)range.Min ) / (slidy.Maximum- slidy.Minimum);
                double X = e.NewValue*b;
    
                this.captureDevice.SetProperty(KnownCameraPhotoProperties.LockedAutoFocusParameters, AutoFocusParameters.Focus); // added this hoping it would work but no.
                this.captureDevice.SetProperty(KnownCameraGeneralProperties.ManualFocusPosition, X);
    
                
    /* //Part2 testing            
                seq = captureDevice.CreateCaptureSequence(1);
                seq.Frames[0].CaptureStream = captureStream1.AsOutputStream();
    
                seq.Frames[0].DesiredProperties[KnownCameraGeneralProperties.ManualFocusPosition] = X;
                seq.Frames[0].DesiredProperties[KnownCameraPhotoProperties.LockedAutoFocusParameters] = AutoFocusParameters.Focus;
                
                seq.Frames[0].DesiredProperties[KnownCameraGeneralProperties.ManualFocusPosition] = X;
                await captureDevice.PrepareCaptureSequenceAsync(seq);
    */
            }
    Edit Solved:

    forgot to call the FocusAsync() method... now it's working just fine !

    Code:
     
            private async void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
            {
                var range = PhotoCaptureDevice.GetSupportedPropertyRange(CameraSensorLocation.Back,KnownCameraGeneralProperties.ManualFocusPosition);
                var slidy = (sender as Slider);
                
                //some math tricks 
                Double b = ((UInt32)range.Max - (UInt32)range.Min ) / (slidy.Maximum- slidy.Minimum);
                double X = e.NewValue*b;
                this.captureDevice.SetProperty(KnownCameraGeneralProperties.ManualFocusPosition, X);
    
                captureDevice.FocusAsync();
            }
    Thanks
    Last edited by Loukt; 2013-08-13 at 07:20.

Similar Threads

  1. Focus range in FP1
    By Larsson73 in forum Symbian Media (Closed)
    Replies: 7
    Last Post: 2009-10-06, 07:43
  2. Focus range for camera in S60 5.0
    By rayabhik in forum Series 40 & S60 Platform Feedback Archive
    Replies: 1
    Last Post: 2009-07-23, 12:51
  3. Replies: 0
    Last Post: 2008-03-25, 11:33
  4. Focus range and Depth of Field
    By tomcwh in forum Mobile Java Media (Graphics & Sounds)
    Replies: 1
    Last Post: 2007-03-13, 01:26
  5. Bluetooth range
    By thefrozenrose in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-10-14, 15:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •