Search code examples
raspberry-picameraraspberry-pi4

Raspberry Pi camera image color are diffrent from real colors


I am new to Raspberry Pi and I am using a 5 megapixel Raspberry Pi camera version 1.3 and I have taken pictures with it. But the color of the pictures taken is different from the actual color of the object. I wanted to know why this is happening? And how to make the images closer to the real color? Thanks

Raspberry Pi camera image:

enter image description here

Actual image(using a phone)

enter image description here

my Raspberry Pi camera Config:

from picamera.array import PiRGBArray
from picamera import PiCamera
import time
import cv2
import operationFramesFuncShape
camera = PiCamera()
camera.resolution = (980, 480)
camera.framerate = 32
camera.rotation = -90
rawCapture = PiRGBArray(camera, size=(980, 480))
# allow the camera to warmup
time.sleep(0.1)

g = camera.awb_gains
camera.awb_mode = 'off'
camera.awb_gains = g
oclass = operationFramesFuncShape.objectFrameClass()
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
  # grab the raw NumPy array representing the image, then initialize the timestamp
  # and occupied/unoccupied text
  image = frame.array

Solution

  • did you try to adjust white balance? Please try: camera.awb_gains = (1.5, 1.5) and adjust valuse to your needs.

    Also why you assign g = camera.awb_gains and then camera.awb_gains = g ?