ตั้งแต่วันที่ 27 มีนาคม 2025 เป็นต้นไป เราขอแนะนำให้ใช้ android-latest-release
แทน aosp-main
เพื่อสร้างและมีส่วนร่วมใน AOSP โปรดดูข้อมูลเพิ่มเติมที่หัวข้อการเปลี่ยนแปลงใน AOSP
พารามิเตอร์การควบคุมกล้องของโปรแกรม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
ใน 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
และต้องจัดการเรื่องนี้อย่างเหมาะสม
ตัวอย่างเนื้อหาและโค้ดในหน้าเว็บนี้ขึ้นอยู่กับใบอนุญาตที่อธิบายไว้ในใบอนุญาตการใช้เนื้อหา Java และ OpenJDK เป็นเครื่องหมายการค้าหรือเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2025-07-27 UTC"],[],[],null,["# Program camera control parameters\n\nIn the previous Extended View System (EVS) 1.0 release, camera devices were\nconsidered read-only devices and, therefore, no method existed that would enable\nthe app to change camera control parameters such as zoom or brightness.\n\nAs this could constrain the capability of EVS apps, the new EVS 1.1\nintroduces new methods and enables the app to program several camera\ncontrol parameters, all of which are defined in `enum CameraParam`: \n\n```gdscript\n/**\n * EVS Camera Parameter\n */\nenum CameraParam : uint32_t {\n /**\n * The brightness of image frames\n */\n BRIGHTNESS,\n /**\n * The contrast of image frames\n */\n CONTRAST,\n /**\n * Automatic gain/exposure control\n */\n AUTOGAIN,\n /**\n * Gain control\n */\n GAIN,\n /**\n * Automatic Whitebalance\n */\n AUTO_WHITE_BALANCE,\n /**\n * Manual white balance setting as a color temperature in Kelvin.\n */\n WHITE_BALANCE_TEMPERATURE,\n /**\n * Image sharpness adjustment\n */\n SHARPNESS,\n /**\n * Auto Exposure Control modes; auto, manual, shutter priority, or\n * aperture priority.\n */\n AUTO_EXPOSURE,\n /**\n * Manual exposure time of the camera\n */\n ABSOLUTE_EXPOSURE,\n /**\n * Set the focal point of the camera to the specified position. This\n * parameter may not be effective when auto focus is enabled.\n */\n ABSOLUTE_FOCUS,\n /**\n * Enables continuous automatic focus adjustments.\n */\n AUTO_FOCUS,\n /**\n * Specify the objective lens focal length as an absolute value.\n */\n ABSOLUTE_ZOOM,\n};\n```\n\nMethods are defined as: \n\n```gdscript\n/**\n * Requests to be a master client.\n *\n * When multiple clients subscribe to a single camera hardware and one of\n * them adjusts a camera parameter such as the contrast, it may disturb\n * other clients' operations. Therefore, the client must call this method\n * to be a master client. When it becomes a master, it can\n * change camera parameters until either it dies or explicitly gives up the\n * role.\n *\n * @return result EvsResult::OK if a master role is granted.\n * EvsResult::OWNERSHIP_LOST if there is already a\n * master client.\n */\nsetMaster() generates (EvsResult result);\n\n/**\n * Sets to be a master client forcibly.\n *\n * The client, which owns the display, has a high priority and can take over\n * a master role from other clients without the display.\n *\n * @param display IEvsDisplay handle. If this is valid, the calling client\n * is considered as the high priority client and therefore\n * it would take over a master role.\n *\n * @return result EvsResult::OK if a master role is granted.\n * EvsResult::OWNERSHIP_LOST if there is already a\n * master client with the display.\n */\nforceMaster(IEvsDisplay display) generates (EvsResult result);\n\n/**\n * Retires from a master client role.\n *\n * @return result EvsResult::OK if this call is successful.\n * EvsResult::INVALID_ARG if the caller client is not a\n * master client.\n */\nunsetMaster() generates (EvsResult result);\n\n/**\n * Retrieves a list of parameters this camera supports.\n *\n * @return params A list of CameraParam that this camera supports.\n */\ngetParameterList() generates (vec\u003cCameraParam\u003e params);\n\n/**\n * Requests a valid value range of a camera parameter\n *\n * @param id The identifier of camera parameter, CameraParam enum.\n *\n * @return min The lower bound of the valid parameter value range.\n * @return max The upper bound of the valid parameter value range.\n * @return step The resolution of values in valid range.\n */\ngetIntParameterRange(CameraParam id)\n generates (int32_t min, int32_t max, int32_t step);\n\n/**\n * Requests to set a camera parameter.\n *\n * @param id The identifier of camera parameter,\n * CameraParam enum.\n * value A desired parameter value.\n * @return result EvsResult::OK if it succeeds to set a parameter.\n * EvsResult::INVALID_ARG if either a requested\n * parameter is not supported or a given value is out\n * of bounds.\n * effectiveValue A programmed parameter value. This may differ\n * from what the client gives if, for example, the\n * driver does not support a target parameter.\n */\nsetIntParameter(CameraParam id, int32_t value)\n generates (EvsResult result, int32_t effectiveValue);\n\n/**\n * Retrieves a value of given camera parameter.\n *\n * @param id The identifier of camera parameter, CameraParam enum.\n * @return result EvsResult::OK if it succeeds to read a parameter.\n * EvsResult::INVALID_ARG if either a requested parameter is\n * not supported.\n * value A value of requested camera parameter.\n */\ngetIntParameter(CameraParam id) generates(EvsResult result, int32_t value);\n```\n\n`getParameterList()` returns a list of parameters\n(`CameraParam` enum) a client can read and write (if the client is a master),\nand `getIntParameterRange()` relays the valid value range and resolution.\nWhen a master client changes a camera parameter, all other clients on the same camera\nhardware are notified by getting a `PARAMETER_CHANGED` event with a\nparameter ID and new value.\n\n**Note:** The sensor driver may handle invalid parameter\nvalues differently. It may simply return an error code or clip the value in the\nvalid range and apply. Therefore, the `setIntParameter()` method returns\nan effective value and the client can use this value to confirm how the request was\nhandled.\n\nRequest arbitration between multiple camera clients\n---------------------------------------------------\n\nBecause the previous EVS design allowed multiple apps to simultaneously\nsubscribe to a single camera hardware, it is possible that one app can\ndisturb the operations of other apps by changing a camera parameter. Also,\nmultiple clients may want to adjust the same parameter differently and thereby\ncause unexpected behaviors in running camera services.\n\nTo avoid such problems, the EVS manager allows that only *master* client\nto program a camera parameter. Before trying to adjust any camera parameter, the client\n**MUST** become a master client by calling the `setMaster()`\nmethod. If this fails, then it means there is already an active master client\non that camera hardware. Until the current master client dies, or explicitly\ngives up a master role through `unsetMaster()`, no other client is\npermitted to change a camera parameter. When a master client returns its privilege,\nall other apps are notified by a `MASTER_RELEASED` event.\n\n### Clients with high priority\n\nThe EVS manager handles the client that owns the display with the high\npriority and allows it to steal a master role from a current master. Because EVS\ndisplay ownership is based on recency, the new client can even take over from the\ncurrent client with the display.\n\nHigh priority clients must call `IEvsCamera::forceMaster(sp\u003cIEvsDisplay\u003e& display)`\nto attain a master role. The EVS manager examines the state of a given display\nhandle and, if (*and only if* ) its state is valid and neither\n`DisplayState::NOT_OPEN` nor `DisplayState::DEAD`\nreplaces a master. The client, which just loses the master role, is\nnotified by a `MASTER_RELEASED` event and **MUST** handle\nthis properly."]]