0
  • 聊天消息
  • 系统消息
  • 评论与回复
登录后你可以
  • 下载海量资料
  • 学习在线课程
  • 观看技术视频
  • 写文章/发帖/加入社区
会员中心
创作中心

完善资料让更多小伙伴认识你,还能领取20积分哦,立即完善>

3天内不再提示

如何制作监控摄像机

454398 来源:wv 2019-09-03 11:30 次阅读
加入交流群
微信小助手二维码

扫码添加小助手

加入工程师交流群

第1步:我们需要什么

物理计算

Arduino Uno(或另一个工作的微控制器

伺服(我使用parralax标准伺服)

Red led

220k电阻

5x电线

Javascript

P5.js

P5 DOM库

P5串行库

P5串行控制(处理串行通信的小程序)

ML5.js

对象

MDF 4mm

底漆喷涂

白色喷漆

浅灰色喷涂油漆

黑色喷漆

黑色太阳镜镜片(或其他)

第2步:进行姿势估计工作

如何制作监控摄像机

首先我们要编写识别人类的草图并在它的鼻子上放一个点。目标是从这一点获取水平X数据并将其发送到Arduino。

让我们开始吧!

在这个项目中,我们需要一些文件或库来使一切正常工作:

p5.js (您可以下载完整的软件包,因为这包括DOM库)

p5 DOM

p5串口(我使用了包中包含的示例中的p5.serialport.js文件) )

ML5.js(您可以将其作为链接包含在内,或者您可以通过这种方式下载整个本地库,这样您就不需要连接互联网以使一切正常工作)

我们拥有所有这些,我们可以将所有内容链接到一个简单的HTML文件中:

接下来是我们的sketch.js文件,其中所有的魔法都发生了!

var serial;

var portName = ‘COM6’; // fill in your serial port name here, you can check the right port in Arduino or P5 serial control

var options = {

baudrate: 19200 //baudrate has to be the same in arduino

};

// this is the message that will be sent to the Arduino:

var oneMessage;

let video;

let poseNet;

let poses = [];

var noseX = []

var ifPerson = true;

//var flipHorizontal = false;

function setup() {

createCanvas(640, 480);

video = createCapture(VIDEO);

video.size(width, height);

frameRate(10);

//--------------------------------------

serial = new p5.SerialPort();

// Get a list the ports available

// You should have a callback defined to see the results. See gotList, below:

serial.list();

// Assuming our Arduino is connected, open the connection to it

serial.open(portName, options);

// When you get a list of serial ports that are available

serial.on(‘list’, gotList);

// When you some data from the serial port

serial.on(‘data’, gotData);

//-----------------------------------------

// Create a new poseNet method with a single detection

poseNet = ml5.poseNet(video, {

flipHorizontal: true,

detectionType: ‘single’

}, modelReady);

// This sets up an event that fills the global variable “poses”

// with an array every time new poses are detected

poseNet.on(‘pose’, function (results) {

poses = results;

if (results.length == 0) {

ifPerson = false;

}

//console.log(‘results: ’ + results);

});

// Hide the video element, and just show the canvas

video.hide();

}

function modelReady() {

select(‘#status’).html(‘Model Loaded’);

}

function draw() {

image(video, 0, 0, width, height);

// We can call both functions to draw all keypoints

drawKeypoints();

if (ifPerson == false) {

serial.write(‘c’);

console.log(“X”);

ifPerson = true;

} else {

oneMessage = map(oneMessage, 1, 640, 65, 115);

serial.write(oneMessage);

console.log(“browser: ” + oneMessage);

}

}

//---------------------------------

// Got the list of ports

function gotList(thelist) {

console.log(“List of Serial Ports:”);

// theList is an array of their names

for (var i = 0; i 《 thelist.length; i++) {

// Display in the console

console.log(i + “ ” + thelist[i]);

}

}

// Called when there is data available from the serial port

function gotData() {

var currentString = serial.readLine();

console.log(currentString);

}

//-------------------------------------

// A function to draw ellipses over the detected keypoints

function drawKeypoints() {

// Loop through all the poses detected

for (let i = 0; i 《 poses.length; i++) {

// For each pose detected, loop through all the keypoints

for (let j = 0; j 《 poses[i].pose.keypoints.length; j++) {

// A keypoint is an object describing a body part (like rightArm or leftShoulder)

let keypoint = poses[i].pose.keypoints[“0”];

noseX[i] = keypoint.position.x.toFixed(0);

oneMessage = (parseInt(noseX[0],10));

//console.log(typeof(oneMessage));

select(‘#noseX_1’).html(noseX.toString());

//console.log(typeof(oneMessage))

// Only draw an ellipse is the pose probability is bigger than 0.2

if (keypoint.score 》 0.2) {

fill(255, 0, 0);

noStroke();

ellipse(keypoint.position.x, keypoint.position.y, 10, 10);

}

}

}

}

就是这样!如果您打开html文件,您将看到网络摄像头镜头上方有一个红点但镜像(否则您的伺服将远离您)。您还将看到发送到Arduino的X数据

第3步:使用P5.serialcontrol

这是一个快速的。为了建立我的草图和Arduino之间的串行通信,我们需要一个处理所有串行数据的中间人将它发送到另一个。以前人们会使用不太友好的Node.js,p5.serialcontrol修复了这个问题。你可以在这里下载p5.serialcontrol。对于Windows用户,请查看Alpha 5版本。

可悲的是,p5.serialcontrol并不完美,有时会崩溃。所以要小心你发送了多少数据。

步骤4:一切Arduino

接下来是Arduino代码并连接伺服和LED。

#include

Servo myservo;

const int redPin = 12;

int newval1, oldval1;

int servoValue;

int space = 2;

int ledState = LOW;

int pos = 0;

unsigned long currentMillis = 0; // stores the value of millis() in each iteration of loop()

unsigned long previousServoMillis = 0; // the time when the servo was last moved

unsigned long previousMillis = 0;

const long interval = 500;

int servoPosition = 90;

int servoSlowInterval = 60; // millisecs between servo moves

int servoFastInterval = 10;

int servoInterval = servoSlowInterval; // initial millisecs between servo moves

int servoDegrees = 2; // amount servo moves at each step

int servoMinDegrees = 45; // will be changed to negative value for movement in the other direction

int servoMaxDegrees = 135;

int increment; // increment to move for each interval

int updateInterval; // interval between updates

unsigned long lastUpdate; // last update of position

int counter = 0;

bool executed = false;

void servoSweep() {

if (currentMillis - previousServoMillis 》= servoInterval) {

previousServoMillis += servoInterval;

servoPosition = servoPosition + servoDegrees; // servoDegrees might be negative

if (servoPosition 《= servoMinDegrees) {

// when the servo gets to its minimum position change the interval to change the speed

if (servoInterval == servoSlowInterval) {

servoInterval = servoSlowInterval; //servoFastInterval

}

else {

servoInterval = servoSlowInterval;

}

}

if ((servoPosition 》= servoMaxDegrees) || (servoPosition 《= servoMinDegrees)) {

// if the servo is at either extreme change the sign of the degrees to make it move the other way

servoDegrees = - servoDegrees; // reverse direction

// and update the position to ensure it is within range

servoPosition = servoPosition + servoDegrees;

}

// make the servo move to the next position

myservo.write(servoPosition);

digitalWrite(redPin, LOW);

// and record the time when the move happened

}

void ledBlink () {

if (currentMillis - previousMillis 》= interval) {

previousMillis = currentMillis;

if (ledState == LOW) {

ledState = HIGH;

} else {

ledState = LOW;

}

digitalWrite(redPin, ledState);

}

}

void setup() {

myservo.attach(9); // servo

Serial.begin(19200); // initialize serial communication

//Serial.setTimeout(10);

pinMode(redPin, OUTPUT);

myservo.write(90);

}

void loop() {

currentMillis = millis();

if (executed == false) {

servoSweep();

delay(50);

}

}

void serialEvent () {

while (Serial.available()) {

newval1 = Serial.read(); //read it

//Serial.println(newval1);

if (newval1 》 0 && newval1 != ‘c’) {

executed = true;

ledBlink();

//if (newval1 《 (oldval1 - space) || newval1 》 (oldval1 + space)) { //dead band setup

myservo.write(newval1);

delay(15);

//oldval1 = newval1;

//}

}

if (newval1 == ‘c’) {

executed = false;

}

}

}

正如您所看到的,我使用了不使用delay()的代码,因此可以随时停止扫描功能,即如果某人被识别。

在此之后,您可以测试整个系统。首先插入你的Arduino与led和伺服(我在我的箭头上进行测试),然后启动p5.serialcontrol然后打开html文件。如果一切正常,箭头将始终指向您。如果您走出网络摄像头捕获的图像,伺服将扫描。

第5步:制作安全摄像头

所有这些软件和代码都让我们开始制作东西!

我模仿了安全摄像头的这个原型,并为激光切割机设计了它。我用木胶组装了这些碎片。相机内部有足够的空间容纳Arduino,它需要一些额外的孔才能将所有电线都放入其中。我还将LED放置在正确的位置,并在前面安装了黑色镜头,以提供额外的安全摄像头效果。我用一些塑料薄膜消除了led灯的光线。

接下来,我准备整个事情并用典型的安全摄像头颜色绘制它。

步骤6:安装备注

关于在某处设置此安装的最后一些评论。安全摄像头本身没有摄像头摄像头,可以看到前面的人。我所做的是将网络摄像头隐藏在支柱中并在其前面放置一个带孔的海报,以隐藏相机,这对于创造正确的效果至关重要。

您还可以做的就是放置相机处于一个更典型的安全摄像头位置,就像挂在天花板或墙壁上一样。但你可以用它做任何你想做的事!

第7步:结束结果

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉
  • 监控摄像机
    +关注

    关注

    0

    文章

    47

    浏览量

    12919
收藏 人收藏
加入交流群
微信小助手二维码

扫码添加小助手

加入工程师交流群

    评论

    相关推荐
    热点推荐

    索尼即将推出R系列系统摄像机

    索尼电子将推出新系列系统摄像机,涵盖五个型号——HDC‑5500R, HDC‑5500RV, HDC‑3500R, HDC‑3500RV和HDC‑3200R,统称为R系列;同时还将推出摄像机控制单元HDCU-3500R与3D LUT选件板HKCU-LUT351。
    的头像 发表于 04-22 14:11 180次阅读

    FCB-EV9520L与CM2002V组合:宽动态监控摄像机的技术融合与应用突破

    协同,为宽动态(WDR)监控提供了系统性解决办法。这一技术融合不仅突破了传统摄像机在明暗对比场景中的性能局限,还通过多维度适配能力重新确立了专业级监控设备的行业标准。
    的头像 发表于 03-17 15:45 1022次阅读

    医疗手术室术野摄像机现场安装教程(一)实操版

    摄像机
    szxuanzhan
    发布于 :2026年03月12日 17:53:03

    索尼AI智能构图PTZ摄像机迎来固件更新

    2026年1月29日,索尼(中国)有限公司表示今年4月起,将面向PTZ摄像机用户推出一系列固件升级,包括AI智能构图旗舰PTZ摄像机BRC-AM7 固件Ver. 3.0版与AI智能构图PTZ摄像机
    的头像 发表于 02-03 09:39 817次阅读

    MS41908M,网络摄像机·监控摄像机用镜头驱动芯片(内置光圈控制)

    MS41908M 是一款用于网络摄像机监控摄像机的镜头驱动芯片,芯片内置光圈控制功能;通过电压驱动方式以及扭矩纹 波修正技术,实现了超低噪声微步驱动。   主要特点 电压驱动方式,256 微步驱动
    的头像 发表于 11-25 14:42 494次阅读
    MS41908M,网络<b class='flag-5'>摄像机</b>·<b class='flag-5'>监控</b><b class='flag-5'>摄像机</b>用镜头驱动芯片(内置光圈控制)

    智能机型崛起,传统安防摄像机,要被 “拍死” 在沙滩上了?

    传统安防摄像机面临智能化挑战,多模态智能摄像机通过多传感器融合实现全场景感知与智能分析,重构安防监控核心能力。
    的头像 发表于 11-03 09:25 776次阅读
    智能机型崛起,传统安防<b class='flag-5'>摄像机</b>,要被 “拍死” 在沙滩上了?

    HTD9901镜头驱动芯片:摄像机与安防监控的核心动力保障

          在摄像机与安全监控摄像头的运行体系中,镜头驱动芯片如同“神经中枢”,直接决定了设备缩放、调焦的精准度与运行稳定性,而HTD9901正是为满足这一核心需求量身打造的专业镜头驱动芯片,其内
    的头像 发表于 10-22 16:52 710次阅读
    HTD9901镜头驱动芯片:<b class='flag-5'>摄像机</b>与安防<b class='flag-5'>监控</b>的核心动力保障

    电动升降桅杆 户外可移动升降杆 监控照明摄像机伸缩支架

    摄像机
    jf_14142521
    发布于 :2025年07月10日 19:05:19

    快速自动聚焦4K摄像机模组——索尼FCB-ER8530

    摄像机
    szxuanzhan
    发布于 :2025年06月09日 16:12:27

    松下推出专业级手持摄像机AG-CX100MC

    松下公司近期发布了专为视频制作、广播电视及流媒体分发领域量身打造的专业级手持摄像机——AG-CX100MC。该摄像机支持4K 60p 10-bit超高清拍摄,旨在为专业用户带来极致的影像体验。
    的头像 发表于 05-29 09:23 1831次阅读

    IPC网络摄像机的静电和浪涌保护方案

    概述IPC网络摄像机(IPCAMERA)是一种结合传统摄像机与网络技术所产生的新一代摄像机,它可以将影像通过网络传至地球另一端,且远端的浏览者不需用任何专业软件,只要标准的网络浏览器即可监视其影像
    的头像 发表于 05-27 18:06 1275次阅读
    IPC网络<b class='flag-5'>摄像机</b>的静电和浪涌保护方案

    双光谱云台监控摄像机,让秸秆焚烧行为尽收眼底

    秋天是喜庆丰收的季节,却也是秸秆焚烧的易发期。为持续改善空气质量,做好农作物秸秆焚烧和综合利用工作,环保有关部门采用在高塔上安装远距离双光谱视频监控摄像机,对村域范围内的农田秸秆焚烧情况进行实时监控
    的头像 发表于 05-14 10:56 816次阅读

    索尼摄像机系统的使用功能

    设备使用功能和配置扩展,增加摄像机的系统应用深度和方便性快速指派RCP和CCU的灵活组合,简化调整视频、Tally等多种信号的跟随变动。
    的头像 发表于 05-07 16:30 2175次阅读
    索尼<b class='flag-5'>摄像机</b>系统的使用功能

    索尼摄像机系统的应用功能

    节目制作系统快速发展,索尼系统摄像机始终立于技术前沿,不断推陈出新,助力实现用户日益多元的需求。系统摄像机有一些和系统相关的非常规功能,属于资深工程师严选推荐,以下让我们一同探寻这些深度(秘密)的系统应用功能。
    的头像 发表于 05-06 09:45 1949次阅读
    索尼<b class='flag-5'>摄像机</b>系统的应用功能