Last Updated on : 2024-06-25 03:42:46download
This topic describes the APIs used to switch between day and night mode and how the internal process works.
The switchable day and night mode of an IPC is implemented by turning on or off the infrared cut (IR cut) filter.
In day mode, the IR cut filter is turned on to block IR and let only the visible light pass through, resulting in the production of color images.
In night mode, the IR cut filter is turned off to capture visible and IR light, resulting in black-and-white images.
The component measures ambient light using either the light sensor hardware or software-based image brightness with the image signal processor (ISP). It then determines the current day/night status and notifies other components to control the IR light, IR cut filter, and DSP modes for day/night mode switching.
Components
tkl_media
: used to get the software-based light level. It loads image effects for day/night mode and controls frame rate, as well as switching between the color and black-and-white modes.app_sys_msg
: used to send the command for switching between day and night mode.app_user_event
: used to receive and execute the command for switching between day and night mode.app_sys_ad
: used to get the light level from the light sensor hardware.TY_SYS_DN_ATTR_S
and the callback to invoke when the peripheral parameters are returned to get the light level.ty_sys_dn_switch_init
.typedef struct TY_SYS_DN_ATTR_
{
unsigned int u32lock_time; ///< The duration to lock the IR cut filter after it is repeatedly switched on/off five times within one minute. The value 0 means not to lock the IR cut filter.
unsigned int u32trigger_interval; ///< The interval to check whether to switch to day/night mode, in seconds. It cannot be set to 0.
unsigned int u32trigger_times; ///< The number of consecutive times day/night mode is repeatedly switched. It cannot be set to 0.
int s32day2night_threshold; ///< Day to night threshold.
int s32night2day_threshold; ///< Night to day threshold.
int whiteled_patch1; ///< Supplemental white light.
int whiteled_patch2; ///< Supplemental white light.
TKL_ISP_DN_MODE_E e32init_mode; ///< Initial mode (day mode by default).
TY_GET_PERIPHERAL_PARAM_CB get_peripheral_param_cb; ///< (Required) Get the peripheral parameters.
} TY_SYS_DN_ATTR_S;
Initialize day/night mode switching and start the thread accordingly. Be sure to set the input parameter get_peripheral_param_cb
and the initial mode. u32trigger_interval
and u32trigger_times
cannot be set to 0
.
/**
* @brief
*
* @param dn_attr
* @return int
*/
int ty_sys_dn_switch_init(TY_SYS_DN_ATTR_S *dn_attr);
/**
* @brief Enable day/night mode switching.
*
* @param on_off 0-off 1-on
*/
void ty_sys_dn_set_enable(bool on_off);
/**
* @brief Get the on/off status of day/night mode.
*
* @param on_off 0-off 1-on
*/
void ty_sys_dn_get_enable(bool *on_off);
/**
* @brief
*
* @param mode day and night mode
*/
void ty_sys_dn_set_config_mode(TKL_ISP_DN_MODE_E mode);
/**
* @brief
*
* @param mode
*/
void ty_sys_dn_get_config_mode(TKL_ISP_DN_MODE_E *mode);
/**
* @brief
*
* @return int
*/
int ty_sys_dn_get_cur_mode(void);
/**
* @brief Get the current day/night switching mode.
*
* @param mode
*/
void ty_sys_dn_get_cur_mode_config(TKL_ISP_DN_MODE_E *mode);
/**
* @brief Initialize the color mode.
*
* @param dn_attr
* @param color_mode_init
* @return int
*/
int ty_sys_dn_color_mode_init(TY_SYS_DN_ATTR_S *dn_attr, int color_mode_init);
/**
* @brief Turn siren on/off.
*
* @param status
* @return int
*/
int ty_sys_siren_switch(int status);
/**
* @brief Set the day/night mode threshold.
*
* @param s32day2night_threshold Day to night threshold.
* @param s32night2day_threshold Night to day threshold.
* @return void
*/
void ty_user_dn_threshold_set(int s32day2night_threshold, int s32night2day_threshold);
/**
* @brief Set the white light trigger event and the light on-time.
*
* @param human_flag Human shape event.
* @param flight_warn_on_off Sub-device alert detection on/off event.
* @param whiteled_time The white light on-time.
* @return int
*/
void ty_user_dn_light(int human_flag, int flight_warn_on_off, int whiteled_time);
Check the setting of the IR cut filter and ensure that it is turned on in day mode to block IR and let only the visible light pass through.
Check if the day/night mode threshold is correct. Consider the following factors and adjust the threshold if needed.
The reflector reflects IR light back into the lens, causing inaccurate raw data to be fed to the algorithm for day/night mode switching. The algorithm determines that the night to day threshold is not met and keeps the IPC in night mode.
First, try removing the reflective object or changing the position of the IPC. If that does not work, consider modifying the day/night mode threshold.
The reflector reflects IR light back into the lens, causing inaccurate raw data to be fed to the algorithm for day/night mode switching. Therefore, the IPC repeatedly toggles between day and night mode.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback