Ask Your Question
1

How do I achieve cloudy white balance (~6,000K)

asked 2013-03-24 11:24:52 -0600

Dangthrimble gravatar image

I am using OpenCV to capture images on a Galaxy S2 but am finding the white balance is off. Using the phone's camera settings, the white balance I require is "Cloudy" (which I have found elsewhere equates to ~6,000K). Can I use the Android camera setting to set the white balance? If so, how? And if not, how else could I efficiently transform the image matrix to achieve the appropriate white balance?

edit retag flag offensive close merge delete

Comments

Does OpenCV bypass the Android camera and therefore also bypass the Android camera settings?

Dangthrimble gravatar imageDangthrimble ( 2013-03-24 11:51:42 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2013-03-25 07:43:42 -0600

You can change white balance settings for camera in different way. If you you use Java camera (JavaCameraView) you can use standard Android camera API like this. If you use VideoCapture, then you need to call set() method with CV_CAP_PROP_ANDROID_WHITE_BALANCE key. All possible white balance values are defined as enum with CV_CAP_ANDROID_WHITE_BALANCE_* keys in opencv2/highgui/highgui_c.h. White balance support in VideoCapture is experimental feature and you potentially can have problems with it. Also I recommend you to see tutorial-3 as example of custom camera settings.

edit flag offensive delete link more
0

answered 2013-03-30 06:52:14 -0600

Dangthrimble gravatar image

Using the OpenCV Tutorial 3 code (Camera Control) (see OpenCV4Android samples) I modified the colour effects methods to allow the setting of white balance:

public List<String> getWhiteBalanceList() {
    return mCamera.getParameters().getSupportedWhiteBalance();
}

public boolean isWhiteBalanceSupported() {
    return (mCamera.getParameters().getWhiteBalance() != null);
}

public String getWhiteBalance() {
    return mCamera.getParameters().getWhiteBalance();
}

public void setWhiteBalance(String whiteBalance) {
    Camera.Parameters params = mCamera.getParameters();
    params.setWhiteBalance(whiteBalance);
    mCamera.setParameters(params);
}

Once I knew that worked I was able to add a call to my main thread to set the correct white balance:

mOpenCvCameraView.setWhiteBalance(Parameters.WHITE_BALANCE_CLOUDY_DAYLIGHT);
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2013-03-24 11:24:52 -0600

Seen: 3,997 times

Last updated: Mar 30 '13