Kamera kontrol parametrelerini programlayın, Kamera kontrol parametrelerini programlayın

Önceki Genişletilmiş Görünüm Sistemi (EVS) 1.0 sürümünde, kamera cihazları salt okunur cihazlar olarak kabul ediliyordu ve bu nedenle uygulamanın yakınlaştırma veya parlaklık gibi kamera kontrol parametrelerini değiştirmesine olanak sağlayacak hiçbir yöntem mevcut değildi.

Bu, EVS uygulamalarının kapasitesini sınırlayabileceğinden, yeni EVS 1.1 yeni yöntemler sunar ve uygulamanın, tümü enum CameraParam tanımlanan çeşitli kamera kontrol parametrelerini programlamasını sağlar:

/**
 * 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,
};

Yöntemler şu şekilde tanımlanır:

/**
 * 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() bir istemcinin okuyabileceği ve yazabileceği (istemci bir ana öğeyse) parametrelerin bir listesini ( CameraParam enum) döndürür ve getIntParameterRange() , geçerli değer aralığını ve çözünürlüğü aktarır. Ana istemci bir kamera parametresini değiştirdiğinde, aynı kamera donanımı üzerindeki tüm diğer istemciler, parametre kimliği ve yeni değer içeren bir PARAMETER_CHANGED olayı alınarak bilgilendirilir.

Not: Sensör sürücüsü geçersiz parametre değerlerini farklı şekilde işleyebilir. Basitçe bir hata kodu döndürebilir veya değeri geçerli aralıkta kırpabilir ve uygulayabilir. Bu nedenle setIntParameter() yöntemi etkili bir değer döndürür ve istemci bu değeri, isteğin nasıl işlendiğini doğrulamak için kullanabilir.

Birden fazla kamera istemcisi arasında tahkim talebinde bulunun

Önceki EVS tasarımı birden fazla uygulamanın aynı anda tek bir kamera donanımına abone olmasına izin verdiğinden, bir uygulamanın bir kamera parametresini değiştirerek diğer uygulamaların işlemlerini bozması mümkündür. Ayrıca, birden fazla istemci aynı parametreyi farklı şekilde ayarlamak isteyebilir ve bu nedenle kamera hizmetlerinin çalıştırılmasında beklenmeyen davranışlara neden olabilir.

Bu tür sorunları önlemek için, EVS yöneticisi yalnızca ana istemcinin bir kamera parametresini programlamasına izin verir. Herhangi bir kamera parametresini ayarlamaya çalışmadan önce, istemcinin setMaster() yöntemini çağırarak ana istemci haline gelmesi ZORUNLUDUR . Bu başarısız olursa, o kamera donanımında zaten aktif bir ana istemcinin olduğu anlamına gelir. Geçerli ana istemci ölene kadar veya unsetMaster() yoluyla ana rolünden açıkça vazgeçene kadar, başka hiçbir istemcinin bir kamera parametresini değiştirmesine izin verilmez. Bir ana istemci ayrıcalığını geri verdiğinde, diğer tüm uygulamalar bir MASTER_RELEASED olayıyla bilgilendirilir.

Yüksek öncelikli müşteriler

EVS yöneticisi, ekranın sahibi olan istemciyi yüksek öncelikli olarak yönetir ve mevcut bir yöneticiden yönetici rolünü çalmasına izin verir. EVS ekran sahipliği yeniliğe dayalı olduğundan, yeni istemci, ekranı mevcut istemciden bile devralabilir.

Yüksek öncelikli istemcilerin bir ana rol elde etmek için IEvsCamera::forceMaster(sp<IEvsDisplay>& display) çağırması gerekir. EVS yöneticisi, belirli bir ekran tanıtıcısının durumunu inceler ve eğer ( ve yalnızca eğer ) durumu geçerliyse ve ne DisplayState::NOT_OPEN ne de DisplayState::DEAD bir ana bilgisayarın yerini almaz. Ana rolünü kaybeden istemci, MASTER_RELEASED olayıyla bilgilendirilir ve bunu doğru şekilde ele alması GEREKİR .

,

Önceki Genişletilmiş Görünüm Sistemi (EVS) 1.0 sürümünde, kamera cihazları salt okunur cihazlar olarak kabul ediliyordu ve bu nedenle uygulamanın yakınlaştırma veya parlaklık gibi kamera kontrol parametrelerini değiştirmesine olanak sağlayacak hiçbir yöntem mevcut değildi.

Bu, EVS uygulamalarının kapasitesini sınırlayabileceğinden, yeni EVS 1.1 yeni yöntemler sunar ve uygulamanın, tümü enum CameraParam tanımlanan çeşitli kamera kontrol parametrelerini programlamasını sağlar:

/**
 * 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,
};

Yöntemler şu şekilde tanımlanır:

/**
 * 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() bir istemcinin okuyabileceği ve yazabileceği (istemci bir ana öğeyse) parametrelerin bir listesini ( CameraParam enum) döndürür ve getIntParameterRange() geçerli değer aralığını ve çözünürlüğü aktarır. Ana istemci bir kamera parametresini değiştirdiğinde, aynı kamera donanımı üzerindeki tüm diğer istemciler, parametre kimliği ve yeni değer içeren bir PARAMETER_CHANGED olayı alınarak bilgilendirilir.

Not: Sensör sürücüsü geçersiz parametre değerlerini farklı şekilde işleyebilir. Basitçe bir hata kodu döndürebilir veya değeri geçerli aralıkta kırpabilir ve uygulayabilir. Bu nedenle setIntParameter() yöntemi etkili bir değer döndürür ve istemci bu değeri, isteğin nasıl işlendiğini doğrulamak için kullanabilir.

Birden fazla kamera istemcisi arasında tahkim talebinde bulunun

Önceki EVS tasarımı birden fazla uygulamanın aynı anda tek bir kamera donanımına abone olmasına izin verdiğinden, bir uygulamanın bir kamera parametresini değiştirerek diğer uygulamaların işlemlerini bozması mümkündür. Ayrıca, birden fazla istemci aynı parametreyi farklı şekilde ayarlamak isteyebilir ve bu nedenle kamera hizmetlerinin çalıştırılmasında beklenmeyen davranışlara neden olabilir.

Bu tür sorunları önlemek için, EVS yöneticisi yalnızca ana istemcinin bir kamera parametresini programlamasına izin verir. Herhangi bir kamera parametresini ayarlamaya çalışmadan önce, istemcinin setMaster() yöntemini çağırarak ana istemci haline gelmesi ZORUNLUDUR . Bu başarısız olursa, o kamera donanımında zaten aktif bir ana istemcinin olduğu anlamına gelir. Mevcut ana istemci ölene kadar veya unsetMaster() yoluyla ana rolünden açıkça vazgeçene kadar, başka hiçbir istemcinin bir kamera parametresini değiştirmesine izin verilmez. Bir ana istemci ayrıcalığını geri verdiğinde, diğer tüm uygulamalar bir MASTER_RELEASED olayıyla bilgilendirilir.

Yüksek öncelikli müşteriler

EVS yöneticisi, ekranın sahibi olan istemciyi yüksek öncelikli olarak yönetir ve mevcut bir yöneticiden yönetici rolünü çalmasına izin verir. EVS ekran sahipliği yeniliğe dayalı olduğundan, yeni istemci, ekranı mevcut istemciden bile devralabilir.

Yüksek öncelikli istemcilerin bir ana rol elde etmek için IEvsCamera::forceMaster(sp<IEvsDisplay>& display) çağırması gerekir. EVS yöneticisi, belirli bir ekran tanıtıcısının durumunu inceler ve eğer ( ve yalnızca eğer ) durumu geçerliyse ve ne DisplayState::NOT_OPEN ne de DisplayState::DEAD bir ana bilgisayarın yerini almaz. Ana rolünü kaybeden istemci, MASTER_RELEASED olayıyla bilgilendirilir ve bunu doğru şekilde ele alması GEREKİR .