תכנת פרמטרי בקרת מצלמה, תכנת פרמטרי בקרת מצלמה

במהדורה הקודמת של 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) שלקוח יכול לקרוא ולכתוב (אם הלקוח הוא מאסטר), ו- getIntParameterRange() מעביר את טווח הערכים והרזולוציה החוקיים. כאשר לקוח מאסטר משנה פרמטר של מצלמה, כל שאר הלקוחות באותה חומרת מצלמה מקבלים הודעה על ידי קבלת אירוע PARAMETER_CHANGED עם מזהה פרמטר וערך חדש.

הערה: מנהל ההתקן של החיישן עשוי לטפל בערכי פרמטרים לא חוקיים בצורה שונה. זה יכול פשוט להחזיר קוד שגיאה או לחתוך את הערך בטווח החוקי ולהחיל. לכן, שיטת setIntParameter() מחזירה ערך אפקטיבי והלקוח יכול להשתמש בערך זה כדי לאשר כיצד טופלה הבקשה.

בקש בוררות בין מספר לקוחות מצלמה

מכיוון שהעיצוב הקודם של EVS אפשר למספר אפליקציות להירשם בו זמנית לחומרת מצלמה אחת, ייתכן שאפליקציה אחת יכולה להפריע לפעולות של אפליקציות אחרות על ידי שינוי פרמטר של מצלמה. כמו כן, ייתכן שמספר לקוחות ירצו להתאים את אותו פרמטר בצורה שונה ובכך לגרום להתנהגויות בלתי צפויות בהפעלת שירותי מצלמה.

כדי למנוע בעיות כאלה, מנהל ה-EVS מאפשר לאותו לקוח מאסטר לתכנת פרמטר של מצלמה. לפני ניסיון להתאים פרמטר כלשהו של מצלמה, הלקוח חייב להפוך ללקוח מאסטר על ידי קריאה לשיטת setMaster() . אם זה נכשל, אז זה אומר שכבר קיים לקוח מאסטר פעיל בחומרת המצלמה הזו. עד שהלקוח הראשי הנוכחי ימות, או מוותר במפורש על תפקיד מאסטר באמצעות 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) שלקוח יכול לקרוא ולכתוב (אם הלקוח הוא מאסטר), ו- getIntParameterRange() מעביר את טווח הערכים והרזולוציה החוקיים. כאשר לקוח מאסטר משנה פרמטר של מצלמה, כל שאר הלקוחות באותה חומרת מצלמה מקבלים הודעה על ידי קבלת אירוע PARAMETER_CHANGED עם מזהה פרמטר וערך חדש.

הערה: מנהל ההתקן של החיישן עשוי לטפל בערכי פרמטרים לא חוקיים בצורה שונה. זה יכול פשוט להחזיר קוד שגיאה או לחתוך את הערך בטווח החוקי ולהחיל. לכן, שיטת setIntParameter() מחזירה ערך אפקטיבי והלקוח יכול להשתמש בערך זה כדי לאשר כיצד טופלה הבקשה.

בקש בוררות בין מספר לקוחות מצלמה

מכיוון שהעיצוב הקודם של EVS אפשר למספר אפליקציות להירשם בו זמנית לחומרת מצלמה אחת, ייתכן שאפליקציה אחת יכולה להפריע לפעולות של אפליקציות אחרות על ידי שינוי פרמטר של מצלמה. כמו כן, ייתכן שמספר לקוחות ירצו להתאים את אותו פרמטר בצורה שונה ובכך לגרום להתנהגויות בלתי צפויות בהפעלת שירותי מצלמה.

כדי למנוע בעיות כאלה, מנהל ה-EVS מאפשר לאותו לקוח מאסטר לתכנת פרמטר של מצלמה. לפני ניסיון להתאים פרמטר כלשהו של מצלמה, הלקוח חייב להפוך ללקוח מאסטר על ידי קריאה לשיטת setMaster() . אם זה נכשל, אז זה אומר שכבר קיים לקוח מאסטר פעיל בחומרת המצלמה הזו. עד שהלקוח הראשי הנוכחי ימות, או מוותר במפורש על תפקיד מאסטר באמצעות unsetMaster() , אף לקוח אחר אינו רשאי לשנות פרמטר של מצלמה. כאשר לקוח מאסטר מחזיר את ההרשאה שלו, כל שאר האפליקציות מקבלות הודעה על ידי אירוע MASTER_RELEASED .

לקוחות עם עדיפות גבוהה

מנהל ה-EVS מטפל בעדיפות גבוהה בלקוח שבבעלותו התצוגה ומאפשר לו לגנוב תפקיד מאסטר ממאסטר נוכחי. מכיוון שבעלות על תצוגה על EVS מבוססת על עדכניות, הלקוח החדש יכול אפילו להשתלט על הלקוח הנוכחי עם התצוגה.

לקוחות בעדיפות גבוהה חייבים להתקשר IEvsCamera::forceMaster(sp<IEvsDisplay>& display) כדי להשיג תפקיד ראשי. מנהל ה-EVS בוחן את המצב של ידית תצוגה נתונה, ואם ( ורק אם ) המצב שלו חוקי ולא DisplayState::NOT_OPEN ולא DisplayState::DEAD מחליפים מאסטר. הלקוח, שרק מאבד את תפקיד המאסטר, מקבל הודעה על ידי אירוע MASTER_RELEASED ועליו לטפל בזה כראוי.