Skip to content

Commit 65fc07f

Browse files
authored
更新 ege 源码至 25.11 (#9)
1 parent eb8fcfb commit 65fc07f

475 files changed

Lines changed: 11098 additions & 196663 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

bundle/ege_bundle/include/ege.h

Lines changed: 170 additions & 124 deletions
Large diffs are not rendered by default.

bundle/ege_bundle/include/ege.zh_CN.h

Lines changed: 200 additions & 131 deletions
Large diffs are not rendered by default.

bundle/ege_bundle/include/ege/camera_capture.h

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#endif
1717

1818
#include "ege.h"
19+
#include <memory>
1920

2021
/// 强制相机输出格式为 BGRA, 适配 ege::Image.
2122
/// FrameOrientation 限制为 TopToBottom, 适配 ege::Image.
@@ -44,15 +45,12 @@ bool hasCameraCaptureModule();
4445
class CameraFrame
4546
{
4647
protected:
47-
/// @brief 请使用 release 方法来回收, 不要直接 delete.
48+
/// @brief CameraFrame 的生命周期由 shared_ptr 完全管理, 请勿手动释放或 delete.
4849
virtual ~CameraFrame() = 0;
4950

5051
public:
5152
CameraFrame();
5253

53-
/// @brief 请使用 release 方法来回收, 不要直接 delete.
54-
virtual void release() = 0;
55-
5654
/**
5755
* @brief 获取 CameraFrame 对应的 ege::IMAGE. 这里的 PIMAGE 是一个指针,
5856
* 但是它的内存是分配在 CameraFrame 内部的.
@@ -70,7 +68,7 @@ class CameraFrame
7068
* 可以用在类似于拍照之后继续进行更多处理的场景.
7169
*
7270
* @return 一个指向 ege::IMAGE 的指针, 或者 nullptr (如果没有数据).
73-
* @note 这个方法内部无缓存, 请注意释放内存.
71+
* @note 这个方法内部无缓存, 请注意释放内存. 也就是说调用者需要负责释放这个 IMAGE.
7472
*/
7573
virtual PIMAGE copyImage() = 0;
7674

@@ -103,6 +101,32 @@ class CameraCapture
103101
// ... 后面也许会添加更多信息, 比如相机支持的分辨率, 像素格式等.
104102
};
105103

104+
struct ResolutionInfo
105+
{
106+
int width; ///< 分辨率宽度
107+
int height; ///< 分辨率高度
108+
};
109+
110+
struct ResolutionList
111+
{
112+
ResolutionList() = default;
113+
114+
ResolutionList(ResolutionInfo* _info, int _count) : info(_info), count(_count) {}
115+
116+
ResolutionList(const ResolutionList&) = delete;
117+
118+
ResolutionList(ResolutionList&& r) : info(r.info), count(r.count)
119+
{
120+
const_cast<ResolutionInfo*&>(r.info) = nullptr;
121+
const_cast<int&>(r.count) = 0;
122+
}
123+
124+
ResolutionList& operator=(const ResolutionList&) = delete;
125+
~ResolutionList();
126+
const ResolutionInfo* info = nullptr; ///< 分辨率信息(数组)
127+
const int count = 0; ///< 分辨率数量
128+
};
129+
106130
struct DeviceList
107131
{
108132
DeviceList() = default;
@@ -133,6 +157,13 @@ class CameraCapture
133157
*/
134158
DeviceList findDeviceNames();
135159

160+
/**
161+
* @brief 获取当前相机设备支持的分辨率列表.
162+
* @note 必须在 `open` 成功之后调用, 否则返回空列表.
163+
* @return ResolutionList 对象, 包含所有支持的分辨率.
164+
*/
165+
ResolutionList getDeviceSupportedResolutions();
166+
136167
/**
137168
* @brief 设置期望的相机分辨率. 相机不一定支持这个物理分辨率, 只是会尽可能找一个跟这个分辨率接近的.
138169
* @note 不设置的话会随便给一个。 如果要获取真实的分辨率, 请在获得帧数据之后,直接从帧数据中获取.
@@ -206,11 +237,13 @@ class CameraCapture
206237
* @brief 获取当前帧数据.
207238
* @param timeout 超时等待时间, 单位毫秒. 0 表示不等待, 直接返回.
208239
*
209-
* @return 当前帧数据的指针. 如果等待超时或者没有数据, 返回 nullptr.
210-
* 注意, 使用者在不使用的时候需要调用 CameraFrame::release() 来释放.
211-
* 否则会造成内存泄漏.
240+
* @return 当前帧数据的 shared_ptr. 如果等待超时或者没有数据, 返回空的 shared_ptr.
241+
* 无需手动释放, shared_ptr 会自动管理生命周期.
242+
*
243+
* @note BREAKING CHANGE: 返回类型已从 CameraFrame* 改为 std::shared_ptr<CameraFrame>.
244+
* 请更新代码以使用 shared_ptr 语义。这一改动提升了内存安全性和资源自动管理能力.
212245
*/
213-
CameraFrame* grabFrame(unsigned int timeoutInMs = 0);
246+
std::shared_ptr<CameraFrame> grabFrame(unsigned int timeoutInMs = 0);
214247

215248
////////////////////////////////////////////////
216249

0 commit comments

Comments
 (0)