編程相機控制參數,編程相機控制參數

在之前的擴展視圖系統 (EVS) 1.0 版本中,相機設備被視為只讀設備,因此不存在使應用程序能夠更改相機控制參數(例如變焦或亮度)的方法。

由於這可能會限制 EVS 應用程序的功能,新的 EVS 1.1 引入了新方法,並使應用程序能夠對多個相機控制參數進行編程,所有這些參數都在enum CameraParam中定義:

/**
 * EVS Camera Parameter
 */
enum CameraParam : uint32_t {
    /**
     * The brightness of image frames
     */
    BRIGHTNESS,
    /**
     * The contrast of image frames
     */
    CONTRAST,
    /**
     * Automatic gain/exposure control
     */
    AUTOGAIN,
    /**
     * Gain control
     */
    GAIN,
    /**
     * Automatic Whitebalance
     */
    AUTO_WHITE_BALANCE,
    /**
     * Manual white balance setting as a color temperature in Kelvin.
     */
    WHITE_BALANCE_TEMPERATURE,
    /**
     * Image sharpness adjustment
     */
    SHARPNESS,
    /**
     * Auto Exposure Control modes; auto, manual, shutter priority, or
     * aperture priority.
     */
    AUTO_EXPOSURE,
    /**
     * Manual exposure time of the camera
     */
    ABSOLUTE_EXPOSURE,
    /**
     * Set the focal point of the camera to the specified position. This
     * parameter may not be effective when auto focus is enabled.
     */
    ABSOLUTE_FOCUS,
    /**
     * Enables continuous automatic focus adjustments.
     */
    AUTO_FOCUS,
    /**
     * Specify the objective lens focal length as an absolute value.
     */
    ABSOLUTE_ZOOM,
};

方法定義為:

/**
 * Requests to be a master client.
 *
 * When multiple clients subscribe to a single camera hardware and one of
 * them adjusts a camera parameter such as the contrast, it may disturb
 * other clients' operations. Therefore, the client must call this method
 * to be a master client. Once it becomes a master, it will be able to
 * change camera parameters until either it dies or explicitly gives up the
 * role.
 *
 * @return result EvsResult::OK if a master role is granted.
 *                EvsResult::OWNERSHIP_LOST if there is already a
 *                master client.
 */
setMaster() generates (EvsResult result);

/**
 * Sets to be a master client forcibly.
 *
 * The client, which owns the display, has a high priority and can take over
 * a master role from other clients without the display.
 *
 * @param  display IEvsDisplay handle. If this is valid, the calling client
 *                 is considered as the high priority client and therefore
 *                 it would take over a master role.
 *
 * @return result  EvsResult::OK if a master role is granted.
 *                 EvsResult::OWNERSHIP_LOST if there is already a
 *                 master client with the display.
 */
forceMaster(IEvsDisplay display) generates (EvsResult result);

/**
 * Retires from a master client role.
 *
 * @return result EvsResult::OK if this call is successful.
 *                EvsResult::INVALID_ARG if the caller client is not a
 *                master client.
 */
unsetMaster() generates (EvsResult result);

/**
 * Retrieves a list of parameters this camera supports.
 *
 * @return params A list of CameraParam that this camera supports.
 */
getParameterList() generates (vec<CameraParam> params);

/**
 * Requests a valid value range of a camera parameter
 *
 * @param  id    The identifier of camera parameter, CameraParam enum.
 *
 * @return min   The lower bound of the valid parameter value range.
 * @return max   The upper bound of the valid parameter value range.
 * @return step  The resolution of values in valid range.
 */
getIntParameterRange(CameraParam id)
    generates (int32_t min, int32_t max, int32_t step);

/**
 * Requests to set a camera parameter.
 *
 * @param  id             The identifier of camera parameter,
 *                        CameraParam enum.
 *         value          A desired parameter value.
 * @return result         EvsResult::OK if it succeeds to set a parameter.
 *                        EvsResult::INVALID_ARG if either a requested
 *                        parameter is not supported or a given value is out
 *                        of bounds.
 *         effectiveValue A programmed parameter value. This may differ
 *                        from what the client gives if, for example, the
 *                        driver does not support a target parameter.
 */
setIntParameter(CameraParam id, int32_t value)
    generates (EvsResult result, int32_t effectiveValue);

/**
 * Retrieves a value of given camera parameter.
 *
 * @param  id     The identifier of camera parameter, CameraParam enum.
 * @return result EvsResult::OK if it succeeds to read a parameter.
 *                EvsResult::INVALID_ARG if either a requested parameter is
 *                not supported.
 *         value  A value of requested camera parameter.
 */
getIntParameter(CameraParam id) generates(EvsResult result, int32_t value);

getParameterList()返回客戶端可以讀取和寫入的參數列表( CameraParam枚舉)(如果客戶端是主設備), getIntParameterRange()有效值範圍和分辨率。當主客戶端更改相機參數時,同一相機硬件上的所有其他客戶端將通過獲取帶有參數 ID 和新值的PARAMETER_CHANGED事件來通知。

注意:傳感器驅動程序可能會以不同的方式處理無效參數值。它可能只是返回一個錯誤代碼或將值裁剪在有效範圍內並應用。因此, setIntParameter()方法返回一個有效值,客戶端可以使用該值來確認請求是如何處理的。

多個相機客戶端之間的請求仲裁

由於之前的 EVS 設計允許多個應用程序同時訂閱單個攝像頭硬件,因此一個應用程序可能會通過更改攝像頭參數來干擾其他應用程序的操作。此外,多個客戶端可能希望以不同的方式調整相同的參數,從而導致運行相機服務時出現意外行為。

為避免此類問題,EVS 管理器僅允許客戶端對相機參數進行編程。在嘗試調整任何相機參數之前,客戶端必須通過調用setMaster()方法成為主客戶端。如果失敗,則意味著該相機硬件上已經有一個活動的主客戶端。在當前主客戶端死亡,或通過unsetMaster()明確放棄主角色之前,不允許其他客戶端更改相機參數。當主客戶端返回其權限時,所有其他應用程序將通過MASTER_RELEASED事件得到通知。

高優先級客戶

EVS 管理器以高優先級處理擁有顯示器的客戶端,並允許它從當前主控中竊取主控角色。由於 EVS 顯示器所有權基於新近度,因此新客戶端甚至可以從當前客戶端接管顯示器。

高優先級客戶端必須調用IEvsCamera::forceMaster(sp<IEvsDisplay>& display)以獲得主角色。 EVS 管理器檢查給定顯示句柄的狀態,並且當(且僅當)其狀態有效並且DisplayState::NOT_OPENDisplayState::DEAD都沒有替換主控時。剛剛失去主角色的客戶端將收到MASTER_RELEASED事件的通知,並且必須正確處理。

,

在之前的擴展視圖系統 (EVS) 1.0 版本中,相機設備被視為只讀設備,因此不存在使應用程序能夠更改相機控制參數(例如變焦或亮度)的方法。

由於這可能會限制 EVS 應用程序的功能,新的 EVS 1.1 引入了新方法,並使應用程序能夠對多個相機控制參數進行編程,所有這些參數都在enum CameraParam中定義:

/**
 * EVS Camera Parameter
 */
enum CameraParam : uint32_t {
    /**
     * The brightness of image frames
     */
    BRIGHTNESS,
    /**
     * The contrast of image frames
     */
    CONTRAST,
    /**
     * Automatic gain/exposure control
     */
    AUTOGAIN,
    /**
     * Gain control
     */
    GAIN,
    /**
     * Automatic Whitebalance
     */
    AUTO_WHITE_BALANCE,
    /**
     * Manual white balance setting as a color temperature in Kelvin.
     */
    WHITE_BALANCE_TEMPERATURE,
    /**
     * Image sharpness adjustment
     */
    SHARPNESS,
    /**
     * Auto Exposure Control modes; auto, manual, shutter priority, or
     * aperture priority.
     */
    AUTO_EXPOSURE,
    /**
     * Manual exposure time of the camera
     */
    ABSOLUTE_EXPOSURE,
    /**
     * Set the focal point of the camera to the specified position. This
     * parameter may not be effective when auto focus is enabled.
     */
    ABSOLUTE_FOCUS,
    /**
     * Enables continuous automatic focus adjustments.
     */
    AUTO_FOCUS,
    /**
     * Specify the objective lens focal length as an absolute value.
     */
    ABSOLUTE_ZOOM,
};

方法定義為:

/**
 * Requests to be a master client.
 *
 * When multiple clients subscribe to a single camera hardware and one of
 * them adjusts a camera parameter such as the contrast, it may disturb
 * other clients' operations. Therefore, the client must call this method
 * to be a master client. Once it becomes a master, it will be able to
 * change camera parameters until either it dies or explicitly gives up the
 * role.
 *
 * @return result EvsResult::OK if a master role is granted.
 *                EvsResult::OWNERSHIP_LOST if there is already a
 *                master client.
 */
setMaster() generates (EvsResult result);

/**
 * Sets to be a master client forcibly.
 *
 * The client, which owns the display, has a high priority and can take over
 * a master role from other clients without the display.
 *
 * @param  display IEvsDisplay handle. If this is valid, the calling client
 *                 is considered as the high priority client and therefore
 *                 it would take over a master role.
 *
 * @return result  EvsResult::OK if a master role is granted.
 *                 EvsResult::OWNERSHIP_LOST if there is already a
 *                 master client with the display.
 */
forceMaster(IEvsDisplay display) generates (EvsResult result);

/**
 * Retires from a master client role.
 *
 * @return result EvsResult::OK if this call is successful.
 *                EvsResult::INVALID_ARG if the caller client is not a
 *                master client.
 */
unsetMaster() generates (EvsResult result);

/**
 * Retrieves a list of parameters this camera supports.
 *
 * @return params A list of CameraParam that this camera supports.
 */
getParameterList() generates (vec<CameraParam> params);

/**
 * Requests a valid value range of a camera parameter
 *
 * @param  id    The identifier of camera parameter, CameraParam enum.
 *
 * @return min   The lower bound of the valid parameter value range.
 * @return max   The upper bound of the valid parameter value range.
 * @return step  The resolution of values in valid range.
 */
getIntParameterRange(CameraParam id)
    generates (int32_t min, int32_t max, int32_t step);

/**
 * Requests to set a camera parameter.
 *
 * @param  id             The identifier of camera parameter,
 *                        CameraParam enum.
 *         value          A desired parameter value.
 * @return result         EvsResult::OK if it succeeds to set a parameter.
 *                        EvsResult::INVALID_ARG if either a requested
 *                        parameter is not supported or a given value is out
 *                        of bounds.
 *         effectiveValue A programmed parameter value. This may differ
 *                        from what the client gives if, for example, the
 *                        driver does not support a target parameter.
 */
setIntParameter(CameraParam id, int32_t value)
    generates (EvsResult result, int32_t effectiveValue);

/**
 * Retrieves a value of given camera parameter.
 *
 * @param  id     The identifier of camera parameter, CameraParam enum.
 * @return result EvsResult::OK if it succeeds to read a parameter.
 *                EvsResult::INVALID_ARG if either a requested parameter is
 *                not supported.
 *         value  A value of requested camera parameter.
 */
getIntParameter(CameraParam id) generates(EvsResult result, int32_t value);

getParameterList()返回客戶端可以讀取和寫入的參數列表( CameraParam枚舉)(如果客戶端是主設備), getIntParameterRange()有效值範圍和分辨率。當主客戶端更改相機參數時,同一相機硬件上的所有其他客戶端將通過獲取帶有參數 ID 和新值的PARAMETER_CHANGED事件來通知。

注意:傳感器驅動程序可能會以不同的方式處理無效參數值。它可能只是返回一個錯誤代碼或將值裁剪在有效範圍內並應用。因此, setIntParameter()方法返回一個有效值,客戶端可以使用該值來確認請求是如何處理的。

多個相機客戶端之間的請求仲裁

由於之前的 EVS 設計允許多個應用程序同時訂閱單個攝像頭硬件,因此一個應用程序可能會通過更改攝像頭參數來干擾其他應用程序的操作。此外,多個客戶端可能希望以不同的方式調整相同的參數,從而導致運行相機服務時出現意外行為。

為避免此類問題,EVS 管理器僅允許客戶端對相機參數進行編程。在嘗試調整任何相機參數之前,客戶端必須通過調用setMaster()方法成為主客戶端。如果失敗,則意味著該相機硬件上已經有一個活動的主客戶端。在當前主客戶端死亡,或通過unsetMaster()明確放棄主角色之前,不允許其他客戶端更改相機參數。當主客戶端返回其權限時,所有其他應用程序將通過MASTER_RELEASED事件得到通知。

高優先級客戶

EVS 管理器以高優先級處理擁有顯示器的客戶端,並允許它從當前主控中竊取主控角色。由於 EVS 顯示器所有權基於新近度,因此新客戶端甚至可以從當前客戶端接管顯示器。

高優先級客戶端必須調用IEvsCamera::forceMaster(sp<IEvsDisplay>& display)以獲得主角色。 EVS 管理器檢查給定顯示句柄的狀態,並且當(且僅當)其狀態有效並且DisplayState::NOT_OPENDisplayState::DEAD都沒有替換主控時。剛剛失去主角色的客戶端將收到MASTER_RELEASED事件的通知,並且必須正確處理。