【基于openharmony的多路摄像头功能:USB设备插拔检测】

深入学习Linux摄像头(二)v4l2驱动框架 深入学习Linux摄像头系列 深入学习Linux摄像头(一)v4l2应用编程 深入学习Linux摄像头(二)v4l2驱动框架 深入学习Linux摄像头(三)虚拟摄像头驱动分析 深入学习Linux摄像头(五)三星平台fimc驱动详解一 深入学习Linux摄像头(六)三星平台fimc驱动详解二 深入学习Linux摄像头(二)v4l2驱动框架 文章目录深入学习Linux摄像头(二)v4l2驱动框架一、V... 阅读详情
AI摘要

文章围绕基于OpenHarmony 3.2的多camera功能展开,主要介绍多路摄像头功能中支持USB摄像头插拔检测这一步骤。涉及HDF层与framework层,阐述了初始化、USB设备检测、MatchDev等环节,包括设备能力查询、设备节点匹配等内容,还提及后续待优化和进一步获取设备信息的方向。

前言

最近项目接触的模块比较繁多而杂,因此开始写文章记录下用以总结。

目前在做的是基于openharmony3.2的多camera功能主要涉及HDF(HAL)层与framework层。

本文章涉及多路摄像头功能的第一步:支持USB摄像头插拔检测。

内容

目前openharmony在HDF层支持的camera模式有V4L2和MPP,除了海思芯片大多用的linux通用的V4L2模式,因此在devicemanager中启动的是V4L2DeviceManager。

初始化

在V4L2DeviceManager::Init会创建一个EnumeratorManager并调用其Init。

RetCode EnumeratorManager::Init()
{
    uvcVideo_ = std::make_shared<HosV4L2UVC>();
    if (uvcVideo_ == nullptr) {
        CAMERA_LOGE("%s Create HosV4L2UVC fail", __FUNCTION__);
        return RC_ERROR;
    }
    uvcVideo_->V4L2UvcDetectInit([&](const std::string& hardwareName,
        std::vector<DeviceControl>& deviceControl,
        std::vector<DeviceFormat>& deviceFormat, bool uvcState) {
        UvcCallBack(hardwareName, deviceControl, deviceFormat, uvcState);
    });
    return RC_OK;
}

可以看到上面代码初始化了一个HosV4L2UVC对象并调用其V4L2UvcDetectInit

RetCode HosV4L2UVC::V4L2UvcDetectInit(UvcCallback cb)
{
    // set callback
    uvcCallbackFun_ = cb;

    uDevFd_ = socket(PF_NETLINK, SOCK_RAW, NETLINK_KOBJECT_UEVENT);
    if (uDevFd_ < 0) {
        CAMERA_LOGE("UVC:V4L2Detect socket() error\n");
        return RC_ERROR;
    }
    memset_s(&nls, sizeof(nls), 0, sizeof(nls));
    nls.nl_family = AF_NETLINK;
    nls.nl_pid = getpid();
    nls.nl_groups = 1;
    rc = bind(uDe
OpenHarmony I2C外设适配与排障实战:从协议时序到设备树配置 I2C总线作为嵌入式系统中广泛使用的双线串行通信协议,通过SDA和SCL实现多设备互联,其开漏输出结构和上拉电阻设计决定了总线电容、上升时间等关键参数。在OpenHarmony外设适配中,I2C通信依赖设备树配置和HDI接口调用,涉及地址匹配、时钟频率、pinctrl复用等核心环节。掌握I2C时序逻辑与排障方法,能有效提升传感器、EEPROM等外设的驱动开发效率,解决波形异常、地址扫描失败、数据读取错误等典型问题。本文系统梳理了从协议原理到OpenHarmony实战的完整链路,涵盖设备树配置、HDI接口使用 阅读详情

相关推荐

RK3568 OpenHarmony3.2 Camera介绍(MIPI、USB)

本文主要介绍OpenHarmony下的Camera整体框架,以及USB、MIPI摄像头在RK3568下的驱动调试。

Martian_Jonas的博客 2336

【信息科学与工程学】【产品体系】计算机科学与自动化——第一百八十九篇 操作系统内核(微内核/宏内核)函数与算法02

宏内核(Linux)更多典型内核函数/算法,从编号271开始,覆盖中断管理、热插拔、PCI、ACPI、固件、崩溃转储、kexec、休眠、watchdog、RTC、hwmon、LED、backlight、input子系统、remoteproc等更多领域。编号类型领域内核类型内核中的函数/算法/模块/模组模块的调用关系模块/函数/算法逐步推理思考的数学表达式及参数列表及参数数值设计模块的C/C++/其他代码关联知识271中断管理中断描述符宏内核 / (中断子系统核心)驱动申请中断 → → → 分配irq_

weixin_49199313的博客 131

UVCCamera+Opencv+RK3568+Android12+调试记录

说明:基于https://github.com/saki4510t/UVCCamera开发 注:本压缩包内不包含源代码,可下载https://github.com/saki4510t/OpenCVwithUVC工程进行开发 压缩包内OpencvWitchUVCCamera.apk实现功能如下 1、安卓主板运行外接USB摄像头 2、使用opencv开发安卓图像处理,完成轮廓识别及输出 3、解决Android10以上系统运行崩溃问题(插入USB摄像头崩溃,Android7系统无崩溃问题) 4、包含RK3568主板开发相关资料

材料力学小白必看:纯弯曲正应力计算全解析(附实例演示)

本文详细解析了材料力学中纯弯曲正应力的计算原理与工程应用,通过实例演示帮助初学者掌握关键公式和计算流程。内容涵盖纯弯曲的基本假设、正应力分布规律、截面特性计算,以及现代工具如Excel、ANSYS和Python在应力分析中的应用,特别适合材料力学小白系统学习。

sea99的博客 1246

基于BS21的星闪模块设计电路SLE/BLE

基于BS21的星闪模块设计电路SLE/BLE HI2821

2503_91889531的博客 2782

TMS-EEG数据预处理:eeglab工具包TESA(一)

b. 自动选择:Tools -> Reject data epochs -> Reject by probability,然后进行Plot -> channel,进行删除。TMS-EEG(经颅磁刺激-脑电图)是一种结合了TMS和EEG记录的技术,这种技术允许研究者在非侵入的情况下探测大脑环路,评估大脑的兴奋性和连通性等皮层特性。对移除脉冲伪迹的数据进行插值:Tools ->TESA -> Interpolate removed data;插值后,画图查看:数据会有数值;

weixin_43604817的博客 1504

研发工作量科学量化评估模型:从多维系数到等级落地指南

摘要:本文提出了一套基于多维系数的科学量化评估模型,用于精准评估软件开发工作量。该模型从需求复杂度、技术难度、质量要求和依赖风险四个核心维度进行量化评估,通过系数乘积计算综合工作量。文章详细说明了各维度的系数区间划分标准,并演示了从基础工作量估算到综合系数计算的具体步骤。该模型通过结构化评估过程,将主观经验转化为客观量化指标,帮助团队提高工作量评估的准确性,增强项目交付的可预测性。其价值在于使评估过程透明化、结构化和可追溯,从而减少项目延期风险,优化资源规划。

友莘居士的博客 1697

【Python进阶】VSCode Python开发完全指南:从环境配置到高效调试

本文通过15个实战案例,系统讲解VSCode进行Python开发的环境配置、编码技巧、调试方法及性能优化,帮助初学者快速构建专业开发环境。

赶紧的博客 3887

【Bug已解决】This model‘s maximum context length is X tokens. However, you requested Y tokens 解决方案

summary_prompt = "请将以下对话历史压缩成一段简洁摘要,保留关键决策和结论:\n" + format_messages(old_part)return [{"role": "system", "content": f"此前对话摘要:{summary}"}] + recent_part这种方式能在大幅降低 token 消耗的同时,尽量保留任务推进所需的关键上下文,是目前业内做长会话 Agent 最常见的处理方式之一。方案适用场景推荐指数滑动窗口裁剪短任务,对早期历史依赖不强⭐⭐⭐。

一键难忘的博客 1万+

26版SPSS操作教程(高级教程第二十一章)

#专注方能成事 #本期内容:信度分析 #由于导师最近布置了学习SPSS这款软件的任务,因此想来平台和大家一起交流下学习经验,这期推送内容接上一次高级教程第二十章的学习笔记,希望能得到一些指正和帮助~

你好! 1717

GibbsCAM软件二次开发:GibbsCAM软件API接口详解

API(Application Programming Interface,应用程序编程接口)是一种允许不同软件之间进行通信的接口。在GibbsCAM软件中,API提供了与外部程序交互的能力,使得开发者可以利用GibbsCAM的强大功能进行二次开发,定制化满足特定的制造需求。GibbsCAM的API主要基于.NET框架,使用C#或VB.NET等语言进行编程。在GibbsCAM软件中,通过API接口创建自定义几何形状是实现复杂零件设计和加工策略定制的关键步骤。

kkchenjj的博客 1503

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: 使用IO内存控制硬件点亮LED灯
下一篇: 【无标题】
luxiefly
博客等级 码龄16年 7粉丝 18原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值