برنامه پارامترهای کنترل دوربین، پارامترهای کنترل دوربین برنامه

در نسخه قبلی Extended View System (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. When it becomes a master, it can
 * 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 enum) که یک کلاینت می‌تواند بخواند و بنویسد (اگر کلاینت Master باشد)، و getIntParameterRange() محدوده مقدار و وضوح معتبر را رله می‌کند. هنگامی که یک سرویس گیرنده اصلی یک پارامتر دوربین را تغییر می دهد، همه مشتریان دیگر در همان سخت افزار دوربین با دریافت یک رویداد PARAMETER_CHANGED با شناسه پارامتر و مقدار جدید مطلع می شوند.

توجه: درایور سنسور ممکن است مقادیر پارامترهای نامعتبر را به طور متفاوتی مدیریت کند. ممکن است به سادگی یک کد خطا را برگرداند یا مقدار را در محدوده معتبر بریده و اعمال کند. بنابراین، متد setIntParameter() یک مقدار موثر برمی گرداند و کلاینت می تواند از این مقدار برای تایید نحوه رسیدگی به درخواست استفاده کند.

درخواست داوری بین چندین مشتری دوربین

از آنجایی که طراحی قبلی EVS به چندین برنامه اجازه می‌داد تا به طور همزمان در یک سخت‌افزار دوربین مشترک شوند، این امکان وجود دارد که یک برنامه بتواند با تغییر پارامتر دوربین، عملکرد سایر برنامه‌ها را مختل کند. همچنین، چندین مشتری ممکن است بخواهند یک پارامتر مشابه را به طور متفاوت تنظیم کنند و در نتیجه باعث ایجاد رفتارهای غیرمنتظره در اجرای خدمات دوربین شوند.

برای جلوگیری از چنین مشکلاتی، مدیر EVS به مشتری اصلی اجازه می دهد تا پارامتر دوربین را برنامه ریزی کند. قبل از تلاش برای تنظیم هر پارامتر دوربین، کلاینت باید با فراخوانی متد setMaster() به یک مشتری اصلی تبدیل شود. اگر این کار انجام نشد، به این معنی است که در حال حاضر یک Master Client فعال در آن سخت افزار دوربین وجود دارد. تا زمانی که کلاینت اصلی فعلی از بین برود، یا صراحتاً نقش اصلی را از طریق unsetMaster() رها کند، هیچ کلاینت دیگری مجاز به تغییر پارامتر دوربین نیست. وقتی یک کلاینت اصلی امتیاز خود را برمی گرداند، همه برنامه های دیگر توسط یک رویداد MASTER_RELEASED مطلع می شوند.

مشتریان با اولویت بالا

مدیر EVS مشتری صاحب نمایشگر را با اولویت بالا کنترل می کند و به آن اجازه می دهد تا نقش اصلی را از استاد فعلی بدزدد. از آنجایی که مالکیت صفحه نمایش EVS بر اساس تازگی است، مشتری جدید حتی می تواند با نمایشگر از مشتری فعلی استفاده کند.

مشتریان با اولویت بالا باید IEvsCamera::forceMaster(sp<IEvsDisplay>& display) برای دستیابی به نقش اصلی تماس بگیرند. مدیر EVS وضعیت یک دسته نمایشگر معین را بررسی می‌کند و اگر ( و فقط اگر ) وضعیت آن معتبر است و نه DisplayState::NOT_OPEN و نه DisplayState::DEAD جایگزین اصلی نمی‌شوند. مشتری، که نقش اصلی را از دست می دهد، توسط یک رویداد MASTER_RELEASED مطلع می شود و باید به درستی این موضوع را مدیریت کند.

،

در نسخه قبلی Extended View System (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. When it becomes a master, it can
 * 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 enum) که یک کلاینت می‌تواند بخواند و بنویسد (اگر کلاینت Master باشد)، و getIntParameterRange() محدوده مقدار و وضوح معتبر را رله می‌کند. هنگامی که یک سرویس گیرنده اصلی یک پارامتر دوربین را تغییر می دهد، همه مشتریان دیگر در همان سخت افزار دوربین با دریافت یک رویداد PARAMETER_CHANGED با شناسه پارامتر و مقدار جدید مطلع می شوند.

توجه: درایور سنسور ممکن است مقادیر پارامترهای نامعتبر را به طور متفاوتی مدیریت کند. ممکن است به سادگی یک کد خطا را برگرداند یا مقدار را در محدوده معتبر بریده و اعمال کند. بنابراین، متد setIntParameter() یک مقدار موثر برمی گرداند و کلاینت می تواند از این مقدار برای تایید نحوه رسیدگی به درخواست استفاده کند.

درخواست داوری بین چندین مشتری دوربین

از آنجایی که طراحی قبلی EVS به چندین برنامه اجازه می‌داد تا به طور همزمان در یک سخت‌افزار دوربین مشترک شوند، این امکان وجود دارد که یک برنامه بتواند با تغییر پارامتر دوربین، عملکرد سایر برنامه‌ها را مختل کند. همچنین، چندین مشتری ممکن است بخواهند یک پارامتر مشابه را به طور متفاوت تنظیم کنند و در نتیجه باعث ایجاد رفتارهای غیرمنتظره در اجرای خدمات دوربین شوند.

برای جلوگیری از چنین مشکلاتی، مدیر EVS به مشتری اصلی اجازه می دهد تا پارامتر دوربین را برنامه ریزی کند. قبل از تلاش برای تنظیم هر پارامتر دوربین، کلاینت باید با فراخوانی متد setMaster() به یک مشتری اصلی تبدیل شود. اگر این کار انجام نشد، به این معنی است که در حال حاضر یک Master Client فعال در آن سخت افزار دوربین وجود دارد. تا زمانی که کلاینت اصلی فعلی از بین برود، یا صراحتاً نقش اصلی را از طریق unsetMaster() رها کند، هیچ کلاینت دیگری مجاز به تغییر پارامتر دوربین نیست. وقتی یک کلاینت اصلی امتیاز خود را برمی گرداند، همه برنامه های دیگر توسط یک رویداد MASTER_RELEASED مطلع می شوند.

مشتریان با اولویت بالا

مدیر EVS مشتری مالک نمایشگر را با اولویت بالا کنترل می کند و به آن اجازه می دهد تا نقش اصلی را از استاد فعلی بدزدد. از آنجایی که مالکیت نمایشگر EVS بر اساس تازگی است، مشتری جدید حتی می‌تواند با نمایشگر از مشتری فعلی استفاده کند.

مشتریان با اولویت بالا باید با IEvsCamera::forceMaster(sp<IEvsDisplay>& display) تماس بگیرند تا به نقش اصلی دست یابند. مدیر EVS وضعیت یک دسته نمایش داده شده را بررسی می کند و اگر ( و فقط اگر ) وضعیت آن معتبر باشد و نه DisplayState::NOT_OPEN و نه DisplayState::DEAD جایگزین اصلی نمی شوند. مشتری، که نقش اصلی را از دست می دهد، توسط یک رویداد MASTER_RELEASED مطلع می شود و باید به درستی این موضوع را مدیریت کند.