Programowanie parametrów sterowania kamerą. Programowanie parametrów sterowania kamerą

W poprzedniej wersji Extended View System (EVS) 1.0 urządzenia z kamerą były uznawane za urządzenia tylko do odczytu i dlatego nie istniała żadna metoda, która umożliwiałaby aplikacji zmianę parametrów sterowania kamerą, takich jak zoom czy jasność.

Ponieważ mogłoby to ograniczyć możliwości aplikacji EVS, nowa wersja EVS 1.1 wprowadza nowe metody i umożliwia aplikacji programowanie kilku parametrów sterowania kamerą, z których wszystkie są zdefiniowane w 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,
};

Metody definiuje się jako:

/**
 * 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() zwraca listę parametrów (wyliczenie CameraParam ), które klient może czytać i zapisywać (jeśli klient jest klientem głównym), a getIntParameterRange() przekazuje prawidłowy zakres wartości i rozdzielczość. Gdy klient główny zmieni parametr kamery, wszyscy pozostali klienci na tym samym sprzęcie kamery zostaną powiadomieni poprzez otrzymanie zdarzenia PARAMETER_CHANGED z identyfikatorem parametru i nową wartością.

Uwaga: sterownik czujnika może inaczej obsługiwać nieprawidłowe wartości parametrów. Może po prostu zwrócić kod błędu lub przyciąć wartość z prawidłowego zakresu i zastosować. Dlatego metoda setIntParameter() zwraca wartość efektywną, a klient może wykorzystać tę wartość do potwierdzenia sposobu obsługi żądania.

Zażądaj arbitrażu między wieloma klientami kamer

Ponieważ poprzedni projekt EVS umożliwiał wielu aplikacjom jednoczesne subskrybowanie jednej kamery, możliwe jest, że jedna aplikacja będzie zakłócać działanie innych aplikacji, zmieniając parametr kamery. Ponadto wielu klientów może chcieć dostosować ten sam parametr w różny sposób, co może spowodować nieoczekiwane zachowania podczas uruchamiania usług kamer.

Aby uniknąć takich problemów, menedżer EVS pozwala tylko klientowi głównemu programować parametry kamery. Przed próbą dostosowania dowolnego parametru kamery klient MUSI stać się klientem głównym, wywołując metodę setMaster() . Jeśli to się nie powiedzie, oznacza to, że na tym sprzęcie kamery znajduje się już aktywny klient główny. Dopóki bieżący klient główny nie umrze lub jawnie nie zrezygnuje z roli głównego poprzez unsetMaster() , żaden inny klient nie może zmieniać parametrów kamery. Gdy klient główny zwróci swoje uprawnienia, wszystkie pozostałe aplikacje zostaną powiadomione za pomocą zdarzenia MASTER_RELEASED .

Klienci z wysokim priorytetem

Menedżer EVS obsługuje klienta będącego właścicielem wyświetlacza o wysokim priorytecie i pozwala mu ukraść rolę mastera obecnemu masterowi. Ponieważ własność wyświetlacza EVS opiera się na aktualności, nowy klient może nawet przejąć obowiązki od obecnego klienta posiadającego wyświetlacz.

Klienci o wysokim priorytecie muszą wywołać IEvsCamera::forceMaster(sp<IEvsDisplay>& display) aby uzyskać rolę główną. Menedżer EVS sprawdza stan danego uchwytu wyświetlacza i jeśli ( i tylko wtedy ) jego stan jest prawidłowy i ani DisplayState::NOT_OPEN , ani DisplayState::DEAD nie zastępują wzorca. Klient, który właśnie traci rolę mastera, jest powiadamiany o zdarzeniu MASTER_RELEASED i MUSI sobie z tym odpowiednio poradzić.

,

W poprzedniej wersji Extended View System (EVS) 1.0 urządzenia z kamerą były uznawane za urządzenia tylko do odczytu i dlatego nie istniała żadna metoda, która umożliwiałaby aplikacji zmianę parametrów sterowania kamerą, takich jak zoom czy jasność.

Ponieważ mogłoby to ograniczyć możliwości aplikacji EVS, nowa wersja EVS 1.1 wprowadza nowe metody i umożliwia aplikacji programowanie kilku parametrów sterowania kamerą, z których wszystkie są zdefiniowane w 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,
};

Metody definiuje się jako:

/**
 * 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() zwraca listę parametrów (wyliczenie CameraParam ), które klient może czytać i zapisywać (jeśli klient jest klientem głównym), a getIntParameterRange() przekazuje prawidłowy zakres wartości i rozdzielczość. Gdy klient główny zmieni parametr kamery, wszyscy pozostali klienci na tym samym sprzęcie kamery zostaną powiadomieni poprzez otrzymanie zdarzenia PARAMETER_CHANGED z identyfikatorem parametru i nową wartością.

Uwaga: sterownik czujnika może inaczej obsługiwać nieprawidłowe wartości parametrów. Może po prostu zwrócić kod błędu lub przyciąć wartość z prawidłowego zakresu i zastosować. Dlatego metoda setIntParameter() zwraca wartość efektywną, a klient może wykorzystać tę wartość do potwierdzenia sposobu obsługi żądania.

Zażądaj arbitrażu między wieloma klientami kamer

Ponieważ poprzedni projekt EVS umożliwiał wielu aplikacjom jednoczesne subskrybowanie jednej kamery, możliwe jest, że jedna aplikacja będzie zakłócać działanie innych aplikacji, zmieniając parametr kamery. Ponadto wielu klientów może chcieć dostosować ten sam parametr w różny sposób, co może spowodować nieoczekiwane zachowania podczas uruchamiania usług kamer.

Aby uniknąć takich problemów, menedżer EVS pozwala tylko klientowi głównemu programować parametry kamery. Przed próbą dostosowania dowolnego parametru kamery klient MUSI stać się klientem głównym, wywołując metodę setMaster() . Jeśli to się nie powiedzie, oznacza to, że na tym sprzęcie kamery znajduje się już aktywny klient główny. Dopóki bieżący klient główny nie umrze lub jawnie nie zrezygnuje z roli głównego poprzez unsetMaster() , żaden inny klient nie może zmieniać parametrów kamery. Gdy klient główny zwróci swoje uprawnienia, wszystkie pozostałe aplikacje zostaną powiadomione za pomocą zdarzenia MASTER_RELEASED .

Klienci z wysokim priorytetem

Menedżer EVS obsługuje klienta będącego właścicielem wyświetlacza o wysokim priorytecie i pozwala mu ukraść rolę mastera obecnemu masterowi. Ponieważ własność wyświetlacza EVS opiera się na aktualności, nowy klient może nawet przejąć obowiązki od obecnego klienta posiadającego wyświetlacz.

Klienci o wysokim priorytecie muszą wywołać IEvsCamera::forceMaster(sp<IEvsDisplay>& display) aby uzyskać rolę główną. Menedżer EVS sprawdza stan danego uchwytu wyświetlacza i jeśli ( i tylko wtedy ) jego stan jest prawidłowy i ani DisplayState::NOT_OPEN , ani DisplayState::DEAD nie zastępują wzorca. Klient, który właśnie traci rolę mastera, jest powiadamiany o zdarzeniu MASTER_RELEASED i MUSI sobie z tym odpowiednio poradzić.