实验一 串口文件传输
1、串口连接
将两个USB转TTL模块的RX和TX交叉相连,分别插入两台电脑的USB口上
2、传输文件
设置波特率为115200bps
打开串口助手,发送文件,结果如下图所示
总结:
理论传输时间=(文件大小×8)÷波特率
实际传输时间为六分钟,与理论传输时间相差较大
实验二 点阵汉字的字模读取与显示**
实验步骤
(1)创建一个logo.txt文件,将姓名与学号输入其中
(2)在Ubuntu中创建一个文件夹document
将压缩包中的Asci0816.zf、HZKF2424.hz、以及创建的logo.txt和图片photo.jpg放入该文件夹中
(3)进入该文件夹,使用gedit命令创建name.cpp文件
编写代码
具体代码如下
#include<iostream>
#include<opencv/cv.h>
#include"opencv2/opencv.hpp"
#include<opencv/cxcore.h>
#include<opencv/highgui.h>
#include<math.h>
using namespace cv;
using namespace std;
void paint_chinese(Mat& image,int x_offset,int y_offset,unsigned long offset);
void paint_ascii(Mat& image,int x_offset,int y_offset,unsigned long offset);
void put_text_to_image(int x_offset,int y_offset,String image_path,char* logo_path);
int main(){
String image_path="/home/zls/code/1.jpg";
char* logo_path=(char*)"/home/zls/code/logo.txt";
put_text_to_image(450,750,image_path,logo_path);//安排文字从图片像素坐标(450,750)开始显示
return 0;
}
//在图片上绘制文字的起点坐标
void paint_ascii(Mat& image,int x_offset,int y_offset,unsigned long offset){
Point p;
p.x = x_offset;
p.y = y_offset;
//存放ascii字膜
char buff[16];
//打开ascii字库文件
FILE *ASCII;
if