50行Python代码实现视频中物体颜色识别和跟踪!

python实现颜色检测、轮廓检测、颜色追踪 Opencv学习准备工作读取图像和视频基础功能裁剪图像绘制图形和文本视角转换图像拼接颜色检测轮廓检测颜色追踪 准备工作 python配置numpy和openCv库 读取图像和视频 图像 cv2.imread(路径) cv2.imshow(窗口名称,输出对象) cv2.waitkey(等待时间) import cv2 img = cv2.imread("./Resources/3-1P316104441.jpg")//当前项目目录下 cv2.imshow("output", img) cv2.wait 阅读详情

目前计算机视觉(CV)与自然语言处理(NLP)及语音识别并列为人工智能三大热点方向,而计算机视觉中的对象检测(objectdetection)应用非常广泛,比如自动驾驶、视频监控、工业质检、医疗诊断等场景。

目标检测的根本任务就是将图片或者视频中感兴趣的目标提取出来,目标的识别可以基于颜色、纹理、形状。其中颜色属性运用十分广泛,也比较容易实现。下面就向大家分享一个我做的小实验———通过OpenCV的Python接口来实现从视频中进行颜色识别和跟踪。

下面就是我们完整的代码实现(已调试运行):

 

import numpy as np
import cv2
font = cv2.FONT_HERSHEY_SIMPLEX
lower_green = np.array([35, 110, 106])  # 绿色范围低阈值
upper_green = np.array([77, 255, 255])  # 绿色范围高阈值
lower_red = np.array([0, 127, 128])  # 红色范围低阈值
upper_red = np.array([10, 255, 255])  # 红色范围高阈值
#需要更多颜色,可以去百度一下HSV阈值!
# cap = cv2.VideoCapture('1.mp4')  # 打开视频文件
cap = cv2.VideoCapture(0)#打开USB摄像头
if (cap.isOpened()):  # 视频打开成功
    flag = 1
else:
    flag = 0
num = 0
if (flag):
    while (True):
        ret, frame 
【opencv-python捕捉特定色彩&色彩追踪】 opencv-python来捕捉hsv的特定颜色,显示出来 阅读详情

相关推荐

50行Python代码实现视频中物体颜色识别和跟踪

如果你也是看准了Python,想自学Python,在这里为大家准备了丰厚的免费。

2201_75604580的博客 1080

python-opencv 机器视觉 质心,形心 坐标 颜色分拣

python-opencv 机器视觉 质心,形心 坐标 颜色分拣 ,程序功能为区分物体颜色,算出物体在图像中的坐标,使用了十字,菱形,方形,X形去噪处理

50行Python代码实现视频中物体颜色识别和跟踪(必须以红色为例)

本文通过50行Python代码实现视频中物体颜色识别和跟踪效果,通过实例截图和实例代码给大家讲解的非常详细,需要的朋友可以参考下

001-基础入门-Web演示源码&资源&工具箱等

小迪安全2023笔记

wushangyu32335的博客 4256

光通信仿真入门:手把手教你用VPI和Matlab搭建第一个联合仿真系统(含避坑指南)

本文详细介绍了如何使用VPI和Matlab搭建光通信联合仿真系统,涵盖软件配置、链路搭建、数据交互等关键环节,并提供常见问题的解决方案。特别适合初学者快速掌握光通信仿真技术,避免常见错误,提升仿真效率。

weixin_28733637的博客 377

逆向分析TikTok的Cronet网络库:定位libsscronet.so并Hook关键SSL函数

本文深入探讨了逆向分析TikTok的Cronet网络库的技术细节,重点介绍了如何定位libsscronet.so并Hook关键SSL函数。通过Java到Native的调用链路追踪、So库定位策略和SSL验证函数的动态Hook技巧,帮助开发者突破定制化网络库的协议加密防护,实现流量解密和协议分析。

weixin_27875131的博客 967

【福建dem】原始高程数据tif格式

DEM(Digital Elevation Model,数字高程模型)是一种地理信息系统中的关键数据集,它提供了地表地形的三维信息,通常用于分析地貌特征、模拟水文过程、规划建设、灾害预警等多个领域。这种数据对于地理分析非常有价值,例如,它可以用于计算坡度、坡向、地形粗糙度等地形特征,或者进行洪水模拟、地质灾害评估、太阳能辐射分析等。“福建dem原始高程数据tif格式”是研究和理解福建省地形地貌的重要资源,结合GIS工具,可以揭示丰富的地理信息,为科研、工程和决策提供有力支持。

鸿业远图科技 943

基于Simulink的雷达跟踪系统仿真(附源码)

此示例包含对雷达系统的基本特征进行建模的子系统。该模型是用于目标位置和速度检测的雷达系统的典型模型。该示例包括雷达脉冲发生器、射频发射器子系统、移动目标的 Simulink 表示、射频接收器和接收模块(Rx 模块)。

珞瑜的博客 3512

ABAP 后台作业里的消息机制:把 MESSAGE 写对,避免作业莫名取消

SAP后台作业消息处理机制解析 本文深入剖析了SAP系统中后台作业的消息处理机制,揭示了前台与后台执行环境的关键差异。核心发现包括: 后台作业对消息的处理规则: 所有消息写入Job log而不显示 根据消息类型决定是否继续执行 W警告在列表处理阶段会被自动转为E错误 关键异常处理: 通过error_message可捕获E/A类型消息 A类型消息会触发隐式数据库回滚 未被捕获的E/A消息将导致作业中断 实用解决方案: 将业务提示改为S或I类型 使用DISPLAY LIKE保持前台体验 通过error_mess

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 2216

IPOP 使用详解 (附IPOP工具包)

IP 地址动态绑定功能;路由信息查询和配置功能;MAC 地址信息查询和修改功能;MAC 、主机信息扫描功能;本机网络报文统计功能;本机端口列表、远程端口扫描功能;端口映射功能;网卡流量统计功能;本机 IP 报文捕获和发送功能;终端控制功能(支持 telnet 、 dos、 ssh、 sftp 、ftp、com 等协议);TCL 脚本支持;多种服务功能( tcp/udp/ping/telnet/ftp/tftp/web/team/syslog/smtp );

悦分享 1万+

openbmc 支持mctp over pcie(三)(支持作为endpoint)

本文介绍了在Intel BHS平台上支持MCTP over PCIe端点开发的调试方法。开发基于CodeConstruct和AspeedTech-BMC的开源项目,将内核驱动改为模块形式以便调试。内容包括DTS配置、驱动模块设置步骤,以及如何将BMC配置为端点设备。调试过程涉及内核模块加载、MCTPD启动、参数设置等关键命令,并展示了路由表、地址和邻居信息的测试结果。该方案仅为实验性工作,需注意停止其他使用/dev/aspeed-mctp0接口的应用。

wit_yuan的专栏 1553

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")

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

上一篇: Python图像识别之图片相似度计算!强的一批!
下一篇: 用Python命令观看 NBA 比分直播,球员数据!押谁赢不用说了吧!
PythonJavaPHP
博客等级 码龄7年 116粉丝 76原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值