Click here to Skip to main content
15,887,987 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am able to set the Exposure manually using below code(cap.Exposure = -5;) and I want to set the Exposure as an Auto from my application after below function closed/terminated. Because Exposure is reflecting for all Camera applications after closed below project. Thanks in advance.


What I have tried:

C#
using OpenCvSharp;
public void StartCamera()
{
VideoCapture cap = new VideoCapture(0);
cap.Set(3, 1920);
cap.Set(4, 1080);
cap.Exposure = -5;
using (Mat image = new Mat())
{
    try
    {
        while (true)
        {
            cap.Read(image);
            if (image.Empty())
                break;
            var img = image.Clone();
            Bitmap bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(img);
            BitmapImage bitmapImageObjSnapShot;
            bitmapImageObjSnapShot = bitmap.ToBitmapImage();
            videoPlayerImage.Source = bitmapImageObjSnapShot;
            img.Release();
        }
    }
    catch (Exception Ex)
    {

    }
}
cap.Release();
}
Posted
Updated 9-Jul-18 23:10pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900