alexbsr   -  Mar 23, 2023

We are getting into a new era. Now AI is much smarter. It can generate some code now... I tried ChatGPT on this.

Prompt: what is white balance?
ChatGPT: White balance is a process used in photography and videography to adjust the colors in an image so that they appear as they would to the human eye under certain lighting conditions. Different light sources have different color temperatures, which can affect the appearance of colors in a photograph or video.

White balance works by calibrating the camera's settings to the color temperature of the light source in the scene. This helps ensure that whites appear as true whites, and that other colors are reproduced accurately. For example, if you are shooting indoors under artificial light, the white balance settings can be adjusted to make the colors in the image appear more natural and less yellow or orange.

Most digital cameras have automatic white balance settings, which attempt to adjust the color temperature based on the lighting conditions in the scene. However, in some situations, the automatic setting may not be sufficient, and the white balance may need to be manually adjusted to achieve the desired result.

Prompt: How about writing code to set the camera parameters to produce a similar white balance as a reference image? C++ + Opencv library
ChatGPT: Sure, here's an example of how to use OpenCV in C++ to set the camera parameters to produce a similar white balance as a reference image:



#include \

int main() {
  cv::VideoCapture cap(0);  // Open the default camera
  if (!cap.isOpened()) {
    return -1;
  }

  // Capture a reference image for white balance
  cv::Mat reference_img;
  cap >> reference_img;

  // Compute the reference image's average color
  cv::Scalar avg_color = cv::mean(reference_img);

  // Set the camera's white balance to the average color of the reference image
  cap.set(cv::CAP_PROP_WHITE_BALANCE_BLUE_U, avg_color.val[0]);
  cap.set(cv::CAP_PROP_WHITE_BALANCE_RED_V, avg_color.val[2]);

  // Continuously capture and display frames with the new white balance
  cv::Mat frame;
  while (true) {
    cap >> frame;
    if (frame.empty()) {
      break;
    }
    cv::imshow("Frame", frame);
    if (cv::waitKey(30) == 'q') {
      break;
    }
  }
  return 0;
}


In this example, we first capture a reference image from the camera to use as a basis for setting the white balance. We then compute the average color of the reference image using the cv::mean() function, and set the camera's white balance parameters accordingly using the cap.set() function. Finally, we continuously capture and display frames with the new white balance using a while loop.

Note that the exact camera properties and values needed to set the white balance may vary depending on the specific camera being used. You may need to experiment with different values to achieve the desired result.

by the way, all AI computing requires powerful AI hardware to support, particularly the Graphics Card. As a result, do not waste your old surplus GPU. You may sell GPU online for money..

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.