C++实现车不礼让行人的抓怕代码
时间: 2024-03-26 07:40:31 浏览: 20
学历(原值:%s):", employees[i].education);
scanf("%s", employees[i].education);
printf("请输入职务(原值:%s):", employees[i].position);
scanf("%s", employees[i].position);
printf以下是一个基于OpenCV和Dlib库的C++实现车不礼让行人的抓拍代码示例:
("请输入工资(原值:%.2f):", employees[i].salary);
scanf("%lf", &employees[i].salary);
printf("请输入住址(原值:%s):", employees[i].address);
scanf("%s", employees[i].```c++
#include <opencv2/opencv.hpp>
#include <dlib/image_processing.h>
#include <dlib/image_processing/frontal_face_detectoraddress);
printf("请输入电话(原值:%s):", employees[i].phone);
scanf("%s", employees[i]..h>
#include <dlib/opencv.h>
#include <iostream>
using namespace cv;
using namespace dlib;
using namespace std;
int mainphone);
printf("员工信息已修改。\n");
return;
}
}
printf("职工号不存在。\n");
}
// 保存员工信息到文件
void saveToFile() {
if (employeeCount == 0) {
printf()
{
// 加载分类器
frontal_face_detector detector = get_frontal_face_detector();
// 加载摄像头
("没有员工信息。\n");
return;
}
FILE *fp = fopen("employees.txt", "w");
if ( VideoCapture cap(0);
// 判断摄像头是否打开
if (!cap.isOpened())
{
cerr <<fp == NULL) {
printf("无法打开文件。\n");
return;
}
for (int i = 0 "无法打开摄像头!" << endl;
return -1;
}
// 创建窗口
namedWindow; i < employeeCount; i++) {
fprintf(fp, "%s %s %s %s %s %s %.2f %s %s\n", employees[i].id, employees[i].name, employees[i].gender, employees[i].birth, employees[i].education("Camera", WINDOW_NORMAL);
resizeWindow("Camera", 640, 480);
// 捕获每一帧图像
, employees[i].position, employees[i].salary, employees[i].address, employees[i].phone);
}
fclose(fp);
printf while (true)
{
Mat frame;
cap >> frame;
// 将OpenCV图像转换为dlib图像("员工信息已保存到文件。\n");
}
```
该程序使用结构体来表示员工信息,实现了
cv_image<bgr_pixel> img(frame);
// 检测人脸
std::vector<rectangle> dets = detector添加、列出、查找、删除、修改和保存员工信息到文件的功能。在程序启动时会读取文件中已有的员工信息,程序退出时会将员工信息保存到文件中。注意,该程序还有一(img);
// 绘制矩形框
for (auto&& det : dets)
cv::rectangle(frame, cv::Point些不足之处,例如没有输入验证、没有异常处理等,仅供参考。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)