AI Detection & Video Message

Last Updated on : 2025-07-14 02:02:12download

Tuya IoT Cloud leverages advanced AI analytics to achieve precise object recognition, including but not limited to birds and packages. The app’s message center intuitively shows detection results through video playback, significantly enhancing the user experience.

Development guide

For more information, see ty_sdk_motion_detect.c.

API description

Initialize

/**
 * @brief        rule module init
 * @param[in]    result_cb callback of cloud result
 * @param[in]    video_msg_cb  callback of video ms
 * @return       error code
 * - OPRT_OK     success
 * - Others      failure
 */
OPERATE_RET tuya_ipc_rule_init(IN RULE_AI_RESULT_CB ai_result_cb, IN RULE_VIDEO_MSG_CB video_msg_cb);

Parameters

Parameter Description
ai_result_cb The results of cloud-based AI detection.
video_msg_cb The results of video messages.

Trigger events

After an event is triggered, the device uploads images and videos to the cloud for target detection.

/**
 * @brief        trigger event for rule module
 * @param[in]    event refer to NOTIFICATION_NAME_E
 * @param[out]   sn  event identification, used to distinguish different events
 * @return       error code
 * - OPRT_OK     success
 * - Others      failure
 */
OPERATE_RET tuya_ipc_rule_trigger_event(IN INT_T event, OUT UINT_T *sn);

Parameters

Parameter Description
event The event type.
sn The sequence number of the specified event, used to distinguish different events.

Report events

Report smart events

/**
 * @brief        report ai message
 * @param[in]    ai_result     ai result
 * @param[in]    is_notify  show in message center if TRUE
 * @return       error code
 * - OPRT_OK     success
 * - Others      failure
 */
OPERATE_RET tuya_ipc_rule_report_ai_msg(IN CHAR_T *ai_result, IN BOOL_T is_notify);

Report smart events and video messages

/**
 * @brief        report ai message and video message
 * @param[in]    ai_result  ai result
 * @param[in]    video_msg  video message
 * @param[in]    is_notify  show in message center if TRUE
 * @return       error code
 * - OPRT_OK     success
 * - Others      failure
 */
OPERATE_RET tuya_ipc_rule_report_ai_msg_with_video_msg(IN CHAR_T *ai_result, IN CHAR_T *video_msg, IN BOOL_T is_notify);

Report smart events when no target is detected

/**
 * @brief        report event if ai result is not detected
 * @param[in]    event      refer to NOTIFICATION_NAME_E
 * @param[in]    ai_result  ai result
 * @param[in]    is_notify  show in message center if TRUE
 */
OPERATE_RET tuya_ipc_rule_report_event(IN INT_T event, IN CHAR_T *ai_result, IN BOOL_T is_notify);

Report smart events and video messages when no target is detected

/**
 * @brief        report event with video msg if ai result is not detected
 * @param[in]    event      refer to NOTIFICATION_NAME_E
 * @param[in]    ai_result  ai result
 * @param[in]    video_msg  video message
 * @param[in]    is_notify  show in message center if TRUE
 */
OPERATE_RET tuya_ipc_rule_report_event_with_video_msg(IN INT_T event, IN CHAR_T *ai_result, IN CHAR_T *video_msg, IN BOOL_T is_notify);