HarmonyOS Next开发----使用XComponent自定义绘制

XComponent组件作为一种绘制组件,通常用于满足用户复杂的自定义绘制需求,其主要有两种类型"surface和component。对于surface类型可以将相关数据传入XComponent单独拥有的NativeWindow来渲染画面。

由于上层UI是采用arkTS开发,那么想要使用XComponent的话,就需要一个桥接和native层交互,类似Android的JNI,鸿蒙应用可以使用napi接口来处理js和native层的交互。

1. 编写CMAKELists.txt文件
# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(XComponent) #项目名称set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
#头文件查找路径
include_directories(${NATIVERENDER_ROOT_PATH}${NATIVERENDER_ROOT_PATH}/include
)
# 编译目标so动态库
add_library(nativerender SHAREDsamples/minute_view.cppplugin/plugin_manager.cppcommon/HuMarketMinuteData.cppcommon/MinuteItem.cppnapi_init.cpp
)
# 查找需要的公共库
find_library(# Sets the name of the path variable.hilog-lib# Specifies the name of the NDK library that# you want CMake to locate.hilog_ndk.z
)
#编译so所需要的依赖
target_link_libraries(nativerender PUBLIClibc++.a${hilog-lib}libace_napi.z.solibace_ndk.z.solibnative_window.solibnative_drawing.so
)
2. Napi模块注册
#include <hilog/log.h>
#include "plugin/plugin_manager.h"
#include "common/log_common.h"EXTERN_C_START
static napi_value Init(napi_env env, napi_value exports)
{OH_LOG_Print(LOG_APP, LOG_INFO, LOG_PRINT_DOMAIN, "Init", "Init begins");if ((nullptr == env) || (nullptr == exports)) {OH_LOG_Print(LOG_APP, LOG_ERROR, LOG_PRINT_DOMAIN, "Init", "env or exports is null");return nullptr;}PluginManager::GetInstance()->Export(env, exports);return exports;
}
EXTERN_C_ENDstatic napi_module nativerenderModule = {.nm_version = 1,.nm_flags = 0,.nm_filename = nullptr,.nm_register_func = Init,.nm_modname = "nativerender",.nm_priv = ((void *)0),.reserved = { 0 }
};extern "C" __attribute__((constructor)) void RegisterModule(void)
{napi_module_register(&nativerenderModule);
}

定义napi_module信息,里面包含模块名称(和arkts侧使用时的libraryname要保持一致),加载模块时的回调函数即Init()。然后注册so模块napi_module_register(&nativerenderModule), 接口Init()函数会收到回调,在Init()有两个参数:

  • env: napi上下文环境;
  • exports: 用于挂载native函数将其导出,会通过js引擎绑定到js层的一个js对象;
3.解析XComponent组件的NativeXComponent实例
 if ((env == nullptr) || (exports == nullptr)) {DRAWING_LOGE("Export: env or exports is null");return;}napi_value exportInstance = nullptr;// 用来解析出被wrap了NativeXComponent指针的属性if (napi_get_named_property(env, exports, OH_NATIVE_XCOMPONENT_OBJ, &exportInstance) != napi_ok) {DRAWING_LOGE("Export: napi_get_named_property fail");return;}OH_NativeXComponent *nativeXComponent = nullptr;// 通过napi_unwrap接口,解析出NativeXComponent的实例指针if (napi_unwrap(env, exportInstance, reinterpret_cast<void **>(&nativeXComponent)) != napi_ok) {DRAWING_LOGE("Export: napi_unwrap fail");return;}char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {'\0'};uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1;if (OH_NativeXComponent_GetXComponentId(nativeXComponent, idStr, &idSize) != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {DRAWING_LOGE("Export: OH_NativeXComponent_GetXComponentId fail");return;}
4.注册XComponent事件回调
void MinuteView::RegisterCallback(OH_NativeXComponent *nativeXComponent) {DRAWING_LOGI("register callback");renderCallback_.OnSurfaceCreated = OnSurfaceCreatedCB;renderCallback_.OnSurfaceDestroyed = OnSurfaceDestroyedCB;renderCallback_.DispatchTouchEvent = nullptr;renderCallback_.OnSurfaceChanged = OnSurfaceChanged;// 注册XComponent事件回调OH_NativeXComponent_RegisterCallback(nativeXComponent, &renderCallback_);
}

在事件回调中可以获取组件的宽高信息:

tatic void OnSurfaceCreatedCB(OH_NativeXComponent *component, void *window) {DRAWING_LOGI("OnSurfaceCreatedCB");if ((component == nullptr) || (window == nullptr)) {DRAWING_LOGE("OnSurfaceCreatedCB: component or window is null");return;}char idStr[OH_XCOMPONENT_ID_LEN_MAX + 1] = {'\0'};uint64_t idSize = OH_XCOMPONENT_ID_LEN_MAX + 1;if (OH_NativeXComponent_GetXComponentId(component, idStr, &idSize) != OH_NATIVEXCOMPONENT_RESULT_SUCCESS) {DRAWING_LOGE("OnSurfaceCreatedCB: Unable to get XComponent id");return;}std::string id(idStr);auto render = MinuteView::GetInstance(id);OHNativeWindow *nativeWindow = static_cast<OHNativeWindow *>(window);render->SetNativeWindow(nativeWindow);uint64_t width;uint64_t height;int32_t xSize = OH_NativeXComponent_GetXComponentSize(component, window, &width, &height);if ((xSize == OH_NATIVEXCOMPONENT_RESULT_SUCCESS) && (render != nullptr)) {render->SetHeight(height);render->SetWidth(width);}
}
5.导出Native函数
void MinuteView::Export(napi_env env, napi_value exports) {if ((env == nullptr) || (exports == nullptr)) {DRAWING_LOGE("Export: env or exports is null");return;}napi_property_descriptor desc[] = {{"draw", nullptr, MinuteView::NapiDraw, nullptr, nullptr, nullptr, napi_default, nullptr}};napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc);if (napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc) != napi_ok) {DRAWING_LOGE("Export: napi_define_properties failed");}
}
6.在NapiDraw中绘制分时图
  • 1.读取arkts侧透传过来的数据
vector<HuMarketMinuteData *> myVector;size_t argc = 3;napi_value args[3] = {nullptr};napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);napi_value vec = args[0];    // vectornapi_value vecNum = args[1]; // lengthuint32_t vecCNum = 0;napi_get_value_uint32(env, vecNum, &vecCNum);for (uint32_t i = 0; i < vecCNum; i++) {napi_value vecData;napi_get_element(env, vec, i, &vecData);HuMarketMinuteData *minuteData = new HuMarketMinuteData(&env, vecData);myVector.push_back(minuteData);}
#include "HuMarketMinuteData.h"
#include "common/MinuteItem.h"
#include "napi/native_api.h"
HuMarketMinuteData::HuMarketMinuteData(napi_env *env, napi_value value) {napi_value api_date, api_isDateChanged, api_yclosePrice, api_minuteItems;napi_get_named_property(*env, value, "date", &api_date);napi_get_named_property(*env, value, "isDateChanged", &api_isDateChanged);napi_get_named_property(*env, value, "yClosePrice", &api_yclosePrice);napi_get_named_property(*env, value, "minuteList", &api_minuteItems);uint32_t *uint32_date;napi_get_value_uint32(*env, api_date, uint32_date);date = int(*uint32_date);napi_get_value_double(*env, api_yclosePrice, &yClosePrice);uint32_t length;napi_get_array_length(*env, api_minuteItems, &length);for (uint32_t i = 0; i < length; i++) {napi_value api_minuteItem;napi_get_element(*env, api_minuteItems, i, &api_minuteItem);MinuteItem *minuteItem = new MinuteItem(env, api_minuteItem);minuteList.push_back(minuteItem);}
}
HuMarketMinuteData::~HuMarketMinuteData() {for (MinuteItem *item : minuteList) {delete item;item = nullptr;}
}
  • 2.绘制分时图
void MinuteView::Drawing2(vector<HuMarketMinuteData *>& minuteDatas) {if (nativeWindow_ == nullptr) {DRAWING_LOGE("nativeWindow_ is nullptr");return;}int ret = OH_NativeWindow_NativeWindowRequestBuffer(nativeWindow_, &buffer_, &fenceFd_);DRAWING_LOGI("request buffer ret = %{public}d", ret);bufferHandle_ = OH_NativeWindow_GetBufferHandleFromNative(buffer_);mappedAddr_ = static_cast<uint32_t *>(mmap(bufferHandle_->virAddr, bufferHandle_->size, PROT_READ | PROT_WRITE, MAP_SHARED, bufferHandle_->fd, 0));if (mappedAddr_ == MAP_FAILED) {DRAWING_LOGE("mmap failed");}// 创建一个bitmap对象cBitmap_ = OH_Drawing_BitmapCreate();// 定义bitmap的像素格式OH_Drawing_BitmapFormat cFormat{COLOR_FORMAT_RGBA_8888, ALPHA_FORMAT_OPAQUE};// 构造对应格式的bitmap,width的值必须为 bufferHandle->stride / 4OH_Drawing_BitmapBuild(cBitmap_, width_, height_, &cFormat);// 创建一个canvas对象cCanvas_ = OH_Drawing_CanvasCreate();// 将画布与bitmap绑定,画布画的内容会输出到绑定的bitmap内存中OH_Drawing_CanvasBind(cCanvas_, cBitmap_);// 清除画布内容OH_Drawing_CanvasClear(cCanvas_, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0xFF, 0xFF));float padding = 30, with = width_, height = height_ / 2;float ltX = padding, ltY = 1, rtX = with - padding,rtY = 1,lbX = padding,lbY = height - 1,rbX = with - padding,rbY = height - 1;// 创建一个path对象cPath_ = OH_Drawing_PathCreate();// 指定path的起始位置OH_Drawing_PathMoveTo(cPath_, ltX, ltY);// 用直线连接到目标点OH_Drawing_PathLineTo(cPath_, rtX, rtY);OH_Drawing_PathLineTo(cPath_, rbX, rbY);OH_Drawing_PathLineTo(cPath_, lbX, lbY);// 闭合形状,path绘制完毕OH_Drawing_PathClose(cPath_);OH_Drawing_PathMoveTo(cPath_, padding, height / 2);OH_Drawing_PathLineTo(cPath_, with - padding, height / 2);OH_Drawing_PathMoveTo(cPath_, with / 2, 1);OH_Drawing_PathLineTo(cPath_, with / 2, height - 1);// 创建一个画笔Pen对象,Pen对象用于形状的边框线绘制cPen_ = OH_Drawing_PenCreate();OH_Drawing_PenSetAntiAlias(cPen_, true);OH_Drawing_PenSetColor(cPen_, OH_Drawing_ColorSetArgb(0xFF, 0xE6, 0xE6, 0xE6));OH_Drawing_PenSetWidth(cPen_, 2.0);OH_Drawing_PenSetJoin(cPen_, LINE_ROUND_JOIN);// 将Pen画笔设置到canvas中OH_Drawing_CanvasAttachPen(cCanvas_, cPen_);OH_Drawing_CanvasDrawPath(cCanvas_, cPath_);double minPrice, maxPrice;computeMaxMin(minuteDatas, &minPrice, &maxPrice);OH_Drawing_Path *pricePath_ = OH_Drawing_PathCreate();OH_Drawing_Path *avgPath_ = OH_Drawing_PathCreate();// 指定path的起始位置HuMarketMinuteData *minuteData = minuteDatas[0];// 单位长度float unitHeight = height / (maxPrice - minPrice);float itemWidth = (with - 2 * padding) / (240 * minuteDatas.size());float pointX = padding;float pointY = 0;float avg_pointX = padding;float avg_pointY = 0;bool isFirst = true;float yClosePrice = 0;for (int i = 0; i < minuteDatas.size(); i++) {HuMarketMinuteData *minuteData = minuteDatas[i];if (i == 0) {yClosePrice = minuteData->yClosePrice;}if (minuteData != nullptr) {for (int j = 0; j < minuteData->minuteList.size(); j++) {MinuteItem *minuteItem = minuteData->minuteList[j];if (minuteItem != nullptr) {pointY = (maxPrice - minuteItem->nowPrice) * unitHeight;avg_pointY = (maxPrice - minuteItem->avgPrice) * unitHeight;if (isFirst) {isFirst = false;OH_Drawing_PathMoveTo(pricePath_, pointX, pointY);OH_Drawing_PathMoveTo(avgPath_, avg_pointX, avg_pointY);} else {OH_Drawing_PathLineTo(pricePath_, pointX, pointY);OH_Drawing_PathLineTo(avgPath_, avg_pointX, avg_pointY);}pointX += itemWidth;avg_pointX += itemWidth;}}}}// 创建一个画笔Pen对象,Pen对象用于形状的边框线绘制cPen_ = OH_Drawing_PenCreate();OH_Drawing_PenSetAntiAlias(cPen_, true);OH_Drawing_PenSetColor(cPen_, OH_Drawing_ColorSetArgb(0xFF, 0x22, 0x77, 0xcc));OH_Drawing_PenSetWidth(cPen_, 5.0);OH_Drawing_PenSetJoin(cPen_, LINE_ROUND_JOIN);// 将Pen画笔设置到canvas中OH_Drawing_CanvasAttachPen(cCanvas_, cPen_);// 在画布上画PriceOH_Drawing_CanvasDrawPath(cCanvas_, pricePath_);OH_Drawing_PenSetColor(cPen_, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x9D, 0x03));OH_Drawing_CanvasAttachPen(cCanvas_, cPen_);OH_Drawing_CanvasDrawPath(cCanvas_, avgPath_);OH_Drawing_PathLineTo(pricePath_, pointX, height);OH_Drawing_PathLineTo(pricePath_, padding, height);OH_Drawing_PathClose(pricePath_);OH_Drawing_CanvasDrawShadow(cCanvas_, pricePath_, {5, 5, 5}, {15, 15, 15}, 30,OH_Drawing_ColorSetArgb(0x00, 0xFF, 0xff, 0xff),OH_Drawing_ColorSetArgb(0x33, 0x22, 0x77, 0xcc), SHADOW_FLAGS_TRANSPARENT_OCCLUDER);// 选择从左到右/左对齐等排版属性OH_Drawing_TypographyStyle *typoStyle = OH_Drawing_CreateTypographyStyle();OH_Drawing_SetTypographyTextDirection(typoStyle, TEXT_DIRECTION_LTR);OH_Drawing_SetTypographyTextAlign(typoStyle, TEXT_ALIGN_LEFT);// 设置文字颜色,例如黑色OH_Drawing_TextStyle *txtStyle = OH_Drawing_CreateTextStyle();OH_Drawing_SetTextStyleColor(txtStyle, OH_Drawing_ColorSetArgb(0xFF, 0xFF, 0x9D, 0x03));// 设置文字大小、字重等属性double fontSize = width_ / 15;OH_Drawing_SetTextStyleFontSize(txtStyle, fontSize);OH_Drawing_SetTextStyleFontWeight(txtStyle, FONT_WEIGHT_400);OH_Drawing_SetTextStyleBaseLine(txtStyle, TEXT_BASELINE_ALPHABETIC);OH_Drawing_SetTextStyleFontHeight(txtStyle, 1);// 如果需要多次测量,建议fontCollection作为全局变量使用,可以显著减少内存占用OH_Drawing_FontCollection *fontCollection = OH_Drawing_CreateSharedFontCollection();// 注册自定义字体const char *fontFamily = "myFamilyName"; // myFamilyName为自定义字体的family nameconst char *fontPath = "/data/storage/el2/base/haps/entry/files/myFontFile.ttf"; // 设置自定义字体所在的沙箱路径OH_Drawing_RegisterFont(fontCollection, fontFamily, fontPath);// 设置系统字体类型const char *systemFontFamilies[] = {"Roboto"};OH_Drawing_SetTextStyleFontFamilies(txtStyle, 1, systemFontFamilies);OH_Drawing_SetTextStyleFontStyle(txtStyle, FONT_STYLE_NORMAL);OH_Drawing_SetTextStyleLocale(txtStyle, "en");// 设置自定义字体类型auto txtStyle2 = OH_Drawing_CreateTextStyle();OH_Drawing_SetTextStyleFontSize(txtStyle2, fontSize);const char *myFontFamilies[] = {"myFamilyName"}; // 如果已经注册自定义字体,填入自定义字体的family// name使用自定义字体OH_Drawing_SetTextStyleFontFamilies(txtStyle2, 1, myFontFamilies);OH_Drawing_TypographyCreate *handler = OH_Drawing_CreateTypographyHandler(typoStyle, fontCollection);OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle);OH_Drawing_TypographyHandlerPushTextStyle(handler, txtStyle2);// 设置文字内容const char *text = doubleToStringWithPrecision(yClosePrice, 2).c_str();OH_Drawing_TypographyHandlerAddText(handler, text);OH_Drawing_TypographyHandlerPopTextStyle(handler);OH_Drawing_Typography *typography = OH_Drawing_CreateTypography(handler);// 设置页面最大宽度double maxWidth = width_;OH_Drawing_TypographyLayout(typography, maxWidth);// 设置文本在画布上绘制的起始位置double position[2] = {100, height / 2.0};// 将文本绘制到画布上OH_Drawing_TypographyPaint(typography, cCanvas_, position[0], position[1]);void *bitmapAddr = OH_Drawing_BitmapGetPixels(cBitmap_);uint32_t *value = static_cast<uint32_t *>(bitmapAddr);uint32_t *pixel = static_cast<uint32_t *>(mappedAddr_);if (pixel == nullptr) {DRAWING_LOGE("pixel is null");return;}if (value == nullptr) {DRAWING_LOGE("value is null");return;}for (uint32_t x = 0; x < width_; x++) {for (uint32_t y = 0; y < height_; y++) {*pixel++ = *value++;}}Region region{nullptr, 0};OH_NativeWindow_NativeWindowFlushBuffer(nativeWindow_, buffer_, fenceFd_, region);int result = munmap(mappedAddr_, bufferHandle_->size);if (result == -1) {DRAWING_LOGE("munmap failed!");}
}

绘制流程:

  • 向OHNativeWindow申请一块buffer, 并获取这块buffer的handle,然后映射内存;
  • 创建画布Canvas, 将bitmap和画布绑定;
  • 使用Canvas相关api绘制内容;
  • 将bitmap转换成像素数据,并通过之前映射的buffer句柄,将bitmap数据写到buffer中;
  • 将内容放回到Buffer队列,在下次Vsync信号就会将buffer中的内容绘制到屏幕上;
  • 取消映射内存;
7.ArkTS侧使用XComponent
  • 添加so依赖
  "devDependencies": {"@types/libnativerender.so": "file:./src/main/cpp/types/libnativerender"}
  • 定义native接口
export default interface XComponentContext {draw(minuteData: UPMarketMinuteData[], length: number): void;
};
  • 使用XComponent并获取XComponentContext, 通过它可以调用native层函数
      XComponent({id: 'xcomponentId',type: 'surface',libraryname: 'nativerender'}).onLoad((xComponentContext) => {if (xComponentContext) {this.xComponentContext = xComponentContext as XComponentContext;}}).width('100%').height(600).backgroundColor(Color.Gray)
  • 调用native函数绘制分时图
    this.monitor.subscribeRTMinuteData(this.TAG_REQUEST_MINUTE, param, (rsp) => {if (rsp.isSuccessful() && rsp.result != null && rsp.result.length > 0 && this.xComponentContext) {this.xComponentContext.draw(rsp.result!, rsp.result.length)}})

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/54324.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

鸿蒙手势交互(四:多层手势)

四、多层手势 指父子组件嵌套时&#xff0c;父子组件均绑定了手势或事件。有两种&#xff0c;一种默认多层级手势事件&#xff0c;一种自定义多层级手势事件。 默认多层级手势事件&#xff1a;需要分清两个概念&#xff0c;触摸事件&#xff0c;手势与事件 触摸事件&#xf…

Parallels Desktop 20 for Mac中文版发布了?会哪些新功能

Parallels Desktop 20 for Mac 正式发布&#xff0c;完全支持 macOS Sequoia 和 Windows 11 24H2&#xff0c;并且在企业版中引入了全新的管理门户。 据介绍&#xff0c;新版本针对 Windows、macOS 和 Linux 虚拟机进行了大量更新&#xff0c;最大的亮点是全新推出的 Parallels…

智慧火灾应急救援航拍检测数据集(无人机视角)

智慧火灾应急救援。 无人机&#xff0c;直升机等航拍视角下火灾应急救援检测数据集&#xff0c;数据分别标注了火&#xff0c;人&#xff0c;车辆这三个要素内容&#xff0c;29810张高清航拍影像&#xff0c;共31GB&#xff0c;适合森林防火&#xff0c;应急救援等方向的学术研…

【C++ Primer Plus习题】16.10

大家好,这里是国中之林! ❥前些天发现了一个巨牛的人工智能学习网站&#xff0c;通俗易懂&#xff0c;风趣幽默&#xff0c;忍不住分享一下给大家。点击跳转到网站。有兴趣的可以点点进去看看← 问题: 解答: #include <iostream> #include <string> #include <…

高质量的翻译:应用程序可用性和成功的关键

在日益全球化的应用市场中&#xff0c;开发一款优秀的产品只是成功的一半。另一半&#xff1f;确保你的用户&#xff0c;无论他们在哪里或说什么语言&#xff0c;都能无缝理解和使用它。这就是高质量翻译的用武之地——不是事后的想法&#xff0c;而是应用程序可用性和最终成功…

2-100 基于matlab的水果识别

基于matlab的水果识别。从面积特征、似圆形特征&#xff0c;颜色(rgb值和hsv值)特征对图像中的梨子、苹果、桃子、香蕉和菠萝进行特征提取&#xff0c;边缘检测识别&#xff0c;最后按照筛选出来的特征对水果进行识别。程序已调通&#xff0c;可直接运行。 下载源程序请点链接…

一天认识一个硬件之连接线

我们在日常工作生活中经常会用到许多连接线&#xff0c;比如视频线&#xff0c;USB线&#xff0c;但是他们的区别在哪里&#xff0c;可能太不清楚&#xff0c;今天就来给大家分享一下。 HDMI线 特点&#xff1a;HDMI线是一种全数字化视频和声音发送接口&#xff0c;可以发送未…

PCL 点云圆柱邻域搜索

目录 一、概述 1.1原理 1.2实现步骤 1.3应用场景 二、代码实现 2.1关键函数 2.2完整代码 三、实现效果 PCL点云算法汇总及实战案例汇总的目录地址链接&#xff1a; PCL点云算法与项目实战案例汇总&#xff08;长期更新&#xff09; 一、概述 本文将介绍如何使用PCL库进…

Snapchat API 访问:Objective-C 实现示例

Snapchat 是一个流行的社交媒体平台&#xff0c;它允许用户发送和接收短暂存在的图片和视频。对于开发者来说&#xff0c;访问 Snapchat API 可以为应用程序添加独特的社交功能。本文将介绍如何在 Objective-C 中实现对 Snapchat API 的访问&#xff0c;并提供一个详细的代码示…

spring boot启动报错:so that it conforms to the canonical names requirements

springboot 2.x的版本中对配置文件中的命名规范有了强制性的要求&#xff0c;如下图所示中的dataSource属性属于驼峰格式&#xff0c;但是在springboot 2.x中不允许使用驼峰形式。 根据错误提示可知将其使用 - 来分割即可 错误信息的含义&#xff1a;“Canonical names should…

LLM - 理解 多模态大语言模型(MLLM) 的 指令微调(Instruction-Tuning) 与相关技术 (四)

欢迎关注我的CSDN&#xff1a;https://spike.blog.csdn.net/ 本文地址&#xff1a;https://spike.blog.csdn.net/article/details/142237871 免责声明&#xff1a;本文来源于个人知识与公开资料&#xff0c;仅用于学术交流&#xff0c;欢迎讨论&#xff0c;不支持转载。 完备(F…

最新版本TensorFlow训练模型TinyML部署到ESP32入门实操

最新版本TensorFlow训练模型TinyML入门实操 1.概述 这篇文章介绍微型嵌入式设备的机器学习TinyML&#xff0c;它们的特点就是将训练好的模型部署到单片机上运行。 2.TensorFlow深度学习原理 TensorFlow开源项目是由google研发的一个嵌入式机器学习工具&#xff0c;通过调用…

鸿蒙媒体开发系列07——AVRecorder音频录制

如果你也对鸿蒙开发感兴趣&#xff0c;加入“Harmony自习室”吧&#xff01;扫描下方名片&#xff0c;关注公众号&#xff0c;公众号更新更快&#xff0c;同时也有更多学习资料和技术讨论群。 1、概述 在HarmonyOS系统中&#xff0c;多种API都提供了音频录制开发的支持&#x…

2024永久激活版 Studio One 6 Pro for mac 音乐创作编辑软件 完美兼容

Studio One 6是一款功能强大的音乐制作软件&#xff0c;由PreSonus公司开发。它提供了全面的音频录制、编辑、混音和母带处理工具&#xff0c;适用于音乐制作人、音频工程师和创作人员。 Studio One 6拥有直观的用户界面&#xff0c;使用户能够快速而流畅地进行音乐创作。它采…

ubuntu安装emqx

目录 1.预先下载好emqx压缩包 2.使用tar命令解压 3.进入bin目录 5.放开访问端口18083 6.从通过ip地址访问emqx后台 7.默认用户名密码为admin/public 8.登录后台 9.资源包绑定在此博文可自取 1.预先下载好emqx压缩包 2.使用tar命令解压 sudo tar -xzvf emqx-5.0.8-el8-…

莱卡相机sd内存卡格式化了怎么恢复数据

在数字化时代&#xff0c;相机已成为我们记录生活、捕捉瞬间的重要设备。而SD内存卡&#xff0c;作为相机的存储媒介&#xff0c;承载着我们的珍贵记忆和重要数据。然而&#xff0c;有时由于误操作、系统错误或其他原因&#xff0c;我们可能会不小心格式化SD内存卡&#xff0c;…

一个基于VB的期刊信息管理系统

一个基本的期刊信息管理系统的示例&#xff0c;使用 Visual Basic (VB.NET) 编写。这个示例将展示如何创建一个简单的期刊信息管理系统&#xff0c;其中包括添加、查看、编辑和删除期刊的功能。 系统需求 添加期刊&#xff1a;允许用户输入期刊的信息&#xff08;如标题、作者…

OpenAI GPT o1技术报告阅读(3)-英文阅读及理解

✨继续阅读报告&#xff1a;使用大模型来学习推理(Reason) 原文链接&#xff1a;https://openai.com/index/learning-to-reason-with-llms/ 这次我们继续看一个英文阅读理解的案例。 原问题&#xff1a; The following passage is the draft of an excerpt from a contempora…

条件编译代码记录

#include <iostream>// 基类模板 template<typename T> class Base { public:void func() {std::cout << "Base function" << std::endl;} };// 特化的子类 template<typename T> class Derived : public Base<T> { public:void…

MYSQL数据库——MYSQL管理

MYSQL数据库安装完成后&#xff0c;自带四个数据库&#xff0c;具体作用如下&#xff1a; 常用工具 1.mysql 不是指mysql服务&#xff0c;而是指mysql的客户端工具 例如&#xff1a; 2.mysqladmin 这是一个执行管理操作的客户端程序&#xff0c;可以用它来检查服务器的配置和…