Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4625044
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:12:59+00:00 2026-05-22T03:12:59+00:00

I’m working on a simple video device and I’d like to introduce some standard

  • 0

I’m working on a simple video device and I’d like to introduce some standard cool camera features. Amongst all I’d like to introduce

  • Focus indicator
  • Auto focus
  • Auto exposure (ideal exposure time estimation)

Right now I’m looking for some examples, how these features can be implemented. Do you have any useful links?

EDIT :
Ok, I will use standard CCD camera, which can provide me ~ 20fps in ~1MPix resolution. I’m planning to write it in C#, in case of performance issues, I’ll use C++. I’ll have lens + CCD camera + motor.

EDIT :
I’d like to see some more detailed algorithm description. I’m sure some have to be taught in university courses, but I have troubles finding some. For focus indicator I’ve tried a primitive approach, but in some cases it failed.

 int verticalPoints = 0, horizontalPoints = 0;
 ///Calculate the vertical differences
 for (int x = 0; x < toAnalyze.Width; x++)
 {
     for (int y = 1; y < toAnalyze.Height; y++)
     {
        byte* pixel = (byte*)data.Scan0 + y * stride + x;
        verticalDiff += Math.Abs(*pixel - *(pixel - stride));;
     }         
  }
  verticalDiff /= toAnalyze.Width * (toAnalyze.Height-1);
  ///Calculate horizontal differences
  for (int y = 0; y < toAnalyze.Height; y++)
  {
     for (int x = 1; x < toAnalyze.Width; x++)
     {
        byte* pixel = (byte*)data.Scan0 + y * stride + x;
        horizontalDiff += Math.Abs(*pixel - *(pixel - 1));
     }
   }
   horizontalDiff /= (toAnalyze.Width-1) * toAnalyze.Height;
   ///And return the average value
   return(verticalDiff + horizontalDiff) / 2;

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T03:12:59+00:00Added an answer on May 22, 2026 at 3:12 am

    Just to inform you. I am working on a professional forensic 5 Megapixel digital camera software in WPF. In DotNet not C++. There are some threading issus to know but it works perfectly fast. More performant because GPU is used.

    Jerry did a good work with his answer.
    Focus detection is “Contrast detection based on time / frames”. Logic is simple, to keep it performant it is not easy.
    Auto Focus detection

    To check the exposure time, it is easy if you have created the histogram of image. Image histogram
    In any case you need to do it for

    • Red channel
    • Green channel
    • Blue channel
    • Gain
    • Exposure time

    This mix makes it a bit more complicated because you also can use Color gain channels to increase brightness of image. RGB image digital. Luminance can have the same result like with “Gain” and “Exposure” time.

    If you calculate the exposure time automatically, keep good in mind that you need a frame to calculate it and as smaller the exposure time as more frames you will get. That means, if you want to have a good algorithm, always try to have a very small exposure time and increase it slowly. Not use a linear algorithm where you decrease the value slowly.

    There are also more methodes for digital cameras like Pixel Binning Pixel Binning to increase framerate to get quick focus results.

    Here is a sample of how focus can work to generate a focus intensity image :

     Private Sub GetFocusValue(ByRef C1 As Color, ByVal LCol1 As List(Of Color), ByVal LCol2 As List(Of Color), ByVal AmplifierPercent As Single)
            Dim MaxDiff1 As Integer = 0
            Dim MaxDiff2 As Integer = 0
            Dim Factor As Single = 0
            Dim D As Integer
    
            Dim LR1 As New List(Of Integer)
            Dim LR2 As New List(Of Integer)
            Dim LG1 As New List(Of Integer)
            Dim LG2 As New List(Of Integer)
            Dim LB1 As New List(Of Integer)
            Dim LB2 As New List(Of Integer)
    
            For Each C As Color In LCol1
                LR1.Add(C.R)
                LG1.Add(C.G)
                LB1.Add(C.B)
            Next
    
    
            For Each C As Color In LCol2
                LR2.Add(C.R)
                LG2.Add(C.G)
                LB2.Add(C.B)
            Next
    
    
    
            MaxDiff1 = Me.GetMaxDiff(LR1)
            MaxDiff1 = Math.Max(MaxDiff1, Me.GetMaxDiff(LG1))
            MaxDiff1 = Math.Max(MaxDiff1, Me.GetMaxDiff(LB1))
    
    
            MaxDiff2 = Me.GetMaxDiff(LR2)
            MaxDiff2 = Math.Max(MaxDiff2, Me.GetMaxDiff(LG2))
            MaxDiff2 = Math.Max(MaxDiff2, Me.GetMaxDiff(LB2))
    
    
    
            If MaxDiff1 > MaxDiff2 Then
                D = MaxDiff1 - MaxDiff2
                Factor = D / 255
                Factor = Factor / (AmplifierPercent / 100)
                Factor = Math.Min(Factor, 1)
                Factor = 1 - Factor 'invert result
                'TB.Math.Swap(MaxDiff1, MaxDiff2)
                'Factor = 255 'the original BM1 is better
            Else
                D = MaxDiff2 - MaxDiff1
                Factor = D / 255
                Factor = Factor * (AmplifierPercent / 100)
                Factor = Math.Min(Factor, 1)
                'Factor = 0 'the BM2 is better
            End If
            Factor = Factor * 255
    
    
    
            C1 = Color.FromArgb(Convert.ToByte(Factor), C1.R, C1.G, C1.B)
    
    
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I want use html5's new tag to play a wav file (currently only supported
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.