通过备案号查网站荆州学校网站建设

张小明 2026/1/16 18:32:08
通过备案号查网站,荆州学校网站建设,建设网站基本步骤,网站自己做还是找公司目录1. 解决措施2. 示例代码3. 将arraybuffer转换成cv::mat4. 使用OH_PixelMap_AccessPixels获取PixelMap的内存地址#xff0c;将这个内存地址中的数据转换为cv::mat的1. 解决措施 将PixelMap转换成cv::mat有两种方法#xff1a; 将PixelMap的arraybuffer转换成cv::mat。使…目录1. 解决措施2. 示例代码3. 将arraybuffer转换成cv::mat4. 使用OH_PixelMap_AccessPixels获取PixelMap的内存地址将这个内存地址中的数据转换为cv::mat的1. 解决措施将PixelMap转换成cv::mat有两种方法将PixelMap的arraybuffer转换成cv::mat。使用OH_PixelMap_AccessPixels获取PixelMap的内存地址将这个内存地址中的数据转换为cv::mat。上述两种方法都需确保PixelMap的格式与OpenCV中Mat的格式一致否则会导致色彩偏差。2. 示例代码importcPixelMapToMatfromlibcpixelmaptomat.so;import{BusinessError}fromkit.BasicServicesKit;import{image}fromkit.ImageKit;Entry Component struct Index{State pixelMap:image.PixelMap|undefinedundefinedasyncarrayBufferToMat(){if(this.pixelMapundefined||this.pixelMap){letcontextthis.getUIContext().getHostContext()ascommon.UIAbilityContext;letresourceManagercontext.resourceManagerletimageArrayawaitresourceManager.getMediaContent($r(app.media.sample10));letpixelBuffernewUint8Array(imageArray).bufferasObjectasArrayBuffer console.info(pixelBuffer length: pixelBuffer.byteLength);letimageResourceimage.createImageSource(pixelBuffer);letopts:image.DecodingOptions{editable:true,desiredPixelFormat:image.PixelMapFormat.RGBA_8888}this.pixelMapawaitimageResource.createPixelMap(opts);}constreadBuffer:ArrayBuffernewArrayBuffer(this.pixelMap.getPixelBytesNumber());// Obtain the array buffer of the pixelmapconsole.info(readBuffer length: readBuffer.byteLength);this.pixelMap.readPixelsToBuffer(readBuffer).then((){console.info(No Error!)}).catch((err:BusinessError){console.error(Error! err.message)})constdirgetContext(this).filesDir;console.info(save path: dir);cPixelMapToMat.arrayBufferToMat(this.pixelMap,readBuffer,dir);}asyncaccessToMat(){if(this.pixelMapundefined||this.pixelMap){letresourceManagergetContext(this).resourceManagerletimageArrayawaitresourceManager.getMediaContent($r(app.media.sample14));letpixelBuffernewUint8Array(imageArray).bufferasObjectasArrayBuffer console.info(pixelBuffer length: pixelBuffer.byteLength);letimageResourceimage.createImageSource(pixelBuffer);letopts:image.DecodingOptions{editable:true,desiredPixelFormat:image.PixelMapFormat.RGBA_8888}this.pixelMapawaitimageResource.createPixelMap(opts);}constdirgetContext(this).filesDir;console.info(save path: dir);cPixelMapToMat.accessToMat(this.pixelMap,dir);}build(){Row(){Column(){Image(this.pixelMap).width(200).height(200)Button(ArrayBufferToMat).onClick((){this.arrayBufferToMat();})Button(AccessToMat).onClick((){this.accessToMat();})}.width(100%)}.height(100%)}}3. 将arraybuffer转换成cv::mat#includenapi/native_api.h#includemultimedia/image_framework/image_mdk.h#includemultimedia/image_framework/image_mdk_common.h#includemultimedia/image_framework/image_pixel_map_mdk.h#includemultimedia/image_framework/image_pixel_map_napi.h#includehilog/log.h#includeopencv2/opencv.hpp#includebits/alltypes.hstaticnapi_valueArrayBufferToMat(napi_env env,napi_callback_info info){size_t argc3;napi_value args[3]{nullptr};napi_get_cb_info(env,info,argc,args,nullptr,nullptr);napi_value error;napi_create_int32(env,-1,error);// Initialize PixelMap object dataNativePixelMap*nativeOH_PixelMap_InitNativePixelMap(env,args[0]);if(nativenullptr){returnerror;}// Obtaining Image InformationstructOhosPixelMapInfospixelMapInfos;if(OH_PixelMap_GetImageInfo(native,pixelMapInfos)!IMAGE_RESULT_SUCCESS){OH_LOG_Print(LOG_APP,LOG_ERROR,0xFF00,Test,Pure : -1);returnerror;}// Obtains the buffernapi_value bufferargs[1];napi_valuetype valueType;napi_typeof(env,buffer,valueType);if(valueTypenapi_object){boolisArrayBufferfalse;napi_is_arraybuffer(env,buffer,isArrayBuffer);if(!isArrayBuffer){napi_throw_error(env,EINVAL,Error);}}void*datanullptr;size_t byteLength0;napi_get_arraybuffer_info(env,buffer,data,byteLength);int32_t*saveBuffer(int32_t*)(data);// Convert to Matcv::MatoriginMat(pixelMapInfos.height,pixelMapInfos.width,CV_8UC4,saveBuffer);if(!originMat.data){OH_LOG_Print(LOG_APP,LOG_ERROR,0xFF00,Read Image,Pure : -1);returnerror;}// openCV defaults to BGRA or BGR. If the pixelmap is not created in one of these formats, a format conversion is requiredcv::Mat saveMat;cv::cvtColor(originMat,saveMat,cv::COLOR_BGRA2RGBA);charpathArray[1024];size_t length;napi_get_value_string_utf8(env,args[2],pathArray,1024,length);std::stringpath(pathArray);path/buffer.jpg;if(!cv::imwrite(path,saveMat)){OH_LOG_Print(LOG_APP,LOG_ERROR,0xFF00,Write Image,Pure : -1);returnerror;}napi_value res;napi_create_int32(env,1,res);returnres;}4. 使用OH_PixelMap_AccessPixels获取PixelMap的内存地址将这个内存地址中的数据转换为cv::mat的staticnapi_valueAccessToMat(napi_env env,napi_callback_info info){size_t argc2;napi_value args[2]{nullptr};napi_get_cb_info(env,info,argc,args,nullptr,nullptr);napi_value error;napi_create_int32(env,-1,error);NativePixelMap*nativeOH_PixelMap_InitNativePixelMap(env,args[0]);if(nativenullptr){returnerror;}structOhosPixelMapInfospixelMapInfos;if(OH_PixelMap_GetImageInfo(native,pixelMapInfos)!IMAGE_RESULT_SUCCESS){OH_LOG_Print(LOG_APP,LOG_ERROR,0xFF00,Test,Pure : -1);returnerror;}void*pixel;// Obtain the memory address of the NativePixelMap object and lock the memoryOH_PixelMap_AccessPixels(native,pixel);// Convert to Mat, pay attention to alignment, so rowSize needs to be passed incv::MatoriginMat(pixelMapInfos.height,pixelMapInfos.width,CV_8UC4,pixel,pixelMapInfos.rowSize);if(!originMat.data){OH_LOG_Print(LOG_APP,LOG_ERROR,0xFF00,Read Image,Pure : -1);returnerror;}// openCV defaults to BGRA or BGR. If the pixelmap is not created in one of these formats, a format conversion is requiredcv::Mat saveMat;cv::cvtColor(originMat,saveMat,cv::COLOR_BGRA2RGBA);charpathArray[1024];size_t length;napi_get_value_string_utf8(env,args[1],pathArray,1024,length);std::stringpath(pathArray);path/access.jpg;if(!cv::imwrite(path,saveMat)){OH_LOG_Print(LOG_APP,LOG_ERROR,0xFF00,Write Image,Pure : -1);returnerror;}napi_value res;napi_create_int32(env,1,res);returnres;}在HarmonyOS开发中针对图库支持硬解码的操作需要指定图像的内存空间大小。OH_PixelMap_AccessPixels() 获取图片的内存地址并锁定该内存。实际图像的大小需要按 lineStride 对齐。因此在构造成 mat 时需指定 lineStride 对齐。lineStride即 rowSize。可以使用 OH_GetImageInfo 获取 imageInfo其中包含 width、height 和 rowSize 等信息。
版权声明:本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!

网站模版网 下载找不到网页

在数字化转型加速的2025年,数据隐私保护已成为软件测试领域不可回避的核心议题。随着《个人信息保护法》等法规的深入实施,测试从业者面临着双重挑战:既要确保软件质量,又要守护用户数据安全。本文旨在为测试工程师提供一套切实可…

张小明 2026/1/14 18:37:08 网站建设

广州红鼎网站建设有限公司怎么样如何将域名和网站绑定

最近学习了git的一些知识,然后就想着把git和vscode集成起来使用,于是就有了这节内容,大致步骤如下: 1.首先vscode要打开你要进行git管理的文件夹,然后对当前文件夹进行初始化,这里初始化有两种方法。方法一是通过命令的方式,git init ;方法二是通过图形化操作的方式,…

张小明 2026/1/14 18:06:39 网站建设

昆明做网站的个人婚纱摄影网站优化技巧

一:主要的知识点 1、说明 本文只是教程内容的一小段,因博客字数限制,故进行拆分。主教程链接:vtk教程——逐行解析官网所有Python示例-CSDN博客 2、知识点纪要 本段代码主要涉及的有①创建一个vtkStructuredPoints数据并进行渲…

张小明 2026/1/14 19:57:14 网站建设

深圳罗湖做网站公司网站开发 模板 c

高级数据库设计与云编码应用技术 在软件开发领域,数据库设计和云服务应用是两个至关重要的方面。下面将详细介绍CQRS模式的应用以及云服务构建中的关键考虑因素和解决方案。 1. CQRS 模式与 Swagger 文档集成 为了展示 CQRS(命令查询职责分离)模式在应用中的强大功能,我…

张小明 2026/1/16 2:52:51 网站建设

建立一个做笔记的网站wordpress的视频嵌入

Linly-Talker能否接入大模型API实现更强对话? 在虚拟主播深夜直播带货、AI客服全天候应答咨询的今天,人们对“数字人”的期待早已不再是机械念稿的动画形象。用户希望它能听懂模糊提问,记住上下文逻辑,甚至带点个性地回应一句&…

张小明 2026/1/14 21:26:31 网站建设

做外贸需要到外汇管理网站盐城网站建设咨询

每天早上醒来,时间都会被重置。 但职业生涯不会。有些人是在失败中被迫停下, 有些人是在系统正常关闭后,才发现自己已经无船可乘。2024 年 12 月,我属于后者。 那一年,我完成了 16 年的“当水手”, 也在毫无…

张小明 2026/1/14 22:50:21 网站建设