2019赛季RM中部分区赛,自瞄和能量机关,完整稳定版。

This commit is contained in:
xinyang
2019-05-31 19:29:22 +08:00
parent 76bc5988c0
commit c0c12b24f0
28 changed files with 816 additions and 728 deletions

View File

@@ -7,24 +7,32 @@
#include <additions/additions.h>
#include <log.h>
#include <opencv2/videoio/videoio_c.h>
#include <iostream>
#define RECEIVE_LOG_LEVEL LOG_NOTHING
#define RECEIVE_LOG_LEVEL LOG_MSG
using namespace std;
void uartReceive(Serial* pSerial) {
char buffer[100];
char buffer[20];
int cnt = 0;
LOGM("data receive start!");
LOGM(STR_CTR(WORD_LIGHT_WHITE,"data receive start!"));
while (true) {
char byte;
char byte = 0;
memset(buffer, 0, sizeof(buffer));
while (pSerial->ReadData((uint8_t*)&byte, 1) && byte!='\n') {
buffer[cnt++] = byte;
if (cnt >= 100) {
LOG(RECEIVE_LOG_LEVEL, "data receive over flow!");
if (cnt >= sizeof(buffer)) {
// LOGE("data receive over flow!");
cnt = 0;
}
}
if (cnt==0 && byte=='\n'){
LOGM("%d", cnt);
}
if (cnt == sizeof(mcuData)) {
memcpy(&mcuData, buffer, sizeof(mcuData));
LOGM("Get, state:%c, mark:%d!", mcuData.state, (int)mcuData.mark);
}
cnt = 0;
}
@@ -38,13 +46,24 @@ void initVideoWriter(cv::VideoWriter& video, const std::string &filename_prefix)
in >> cnt;
in.close();
}
std::string armor_file_name = filename_prefix + std::to_string(cnt) + ".avi";
std::string file_name = filename_prefix + std::to_string(cnt) + ".avi";
cnt++;
std::ofstream out(filename_prefix + "cnt.txt");
if (out.is_open()) {
out << cnt << std::endl;
out.close();
}
video.open(armor_file_name, CV_FOURCC('P', 'I', 'M', '1'), 90, cv::Size(640, 480), true);
video.open(file_name, CV_FOURCC('P', 'I', 'M', '1'), 90, cv::Size(640, 480), true);
}
void lastVideo(std::string &video_name, const std::string &filename_prefix){
std::ifstream in(filename_prefix + "cnt.txt");
int cnt = 0;
if (in.is_open())
{
in >> cnt;
in.close();
}
if(cnt > 1) std::string video_name = filename_prefix + std::to_string(cnt) + ".avi";
}