I am using the script below to apply settings changes to an ispstream from an OAK-1 Max USB camera. I can change any combination of settings except for brightness and the stream behaves accordingly. But when I try to change brightness with any other setting, the resultant video has a strong flicker. This is a video I captured of the phenomenon.
$$
import time
from fractions import Fraction
import depthai as dai
import av
pipeline = dai.Pipeline()
camRgb = pipeline.create(dai.node.ColorCamera)
camRgb.setResolution(dai.ColorCameraProperties.SensorResolution.THE_4_K)
width, height = camRgb.getVideoSize()
camRgb.setFps(10)
imageManip = pipeline.create(dai.node.ImageManip)
frame_size = width * height * 1.5
imageManip.setMaxOutputFrameSize(int(frame_size))
imageManip.initialConfig.setFrameType(dai.ImgFrame.Type.NV12)
camRgb.isp.link(imageManip.inputImage)
videoEnc = pipeline.create(dai.node.VideoEncoder)
videoEnc.setDefaultProfilePreset(10, dai.VideoEncoderProperties.Profile.H264_MAIN)
imageManip.out.link(videoEnc.input)
xoutEnc = pipeline.create(dai.node.XLinkOut)
xoutEnc.setStreamName('video')
videoEnc.bitstream.link(xoutEnc.input)
controlIn = pipeline.create(dai.node.XLinkIn)
controlIn.setStreamName('control')
controlIn.out.link(camRgb.inputControl)
ctrl = dai.CameraControl()
with dai.Device(pipeline, dai.DeviceInfo("184430109118E1F400"), maxUsbSpeed=dai.UsbSpeed.HIGH) as device:
controlQueue = device.getInputQueue('control')
ctrl = dai.CameraControl()
###############
comment either one out to remove flicker
ctrl.setBrightness(-5)
ctrl.setSharpness(4)
################################
controlQueue.send(ctrl)
videoQueue = device.getOutputQueue('video', maxSize=30, blocking=True)
output_container = av.open("video.mp4", 'w')
stream = output_container.add_stream("h264", rate=Fraction(camRgb.getFps()))
stream.time_base = Fraction(1, 1000 * 1000)
start = time.time()
print("Recording...ctrl+c to stop\n")
try:
while True:
data = videoQueue.get().getData()
packet = av.Packet(data)
packet.pts = int((time.time() - start) * 1000 * 1000)
output_container.mux_one(packet)
except KeyboardInterrupt:
pass
output_container.close()
$$