This commit is contained in:
xinyang
2019-05-10 20:46:33 +08:00
parent 6225abf161
commit bfde0d80ad
2 changed files with 11 additions and 11 deletions

View File

@@ -117,10 +117,10 @@ static bool findArmorBoxes(LightBlobs &light_blobs, std::vector<cv::Rect2d> &arm
cv::Rect2d rect_left = light_blobs.at(static_cast<unsigned long>(i)).rect.boundingRect(); cv::Rect2d rect_left = light_blobs.at(static_cast<unsigned long>(i)).rect.boundingRect();
cv::Rect2d rect_right = light_blobs.at(static_cast<unsigned long>(j)).rect.boundingRect(); cv::Rect2d rect_right = light_blobs.at(static_cast<unsigned long>(j)).rect.boundingRect();
double min_x, min_y, max_x, max_y; double min_x, min_y, max_x, max_y;
min_x = fmin(rect_left.x, rect_right.x); min_x = fmin(rect_left.x, rect_right.x) - 4;
max_x = fmax(rect_left.x + rect_left.width, rect_right.x + rect_right.width); max_x = fmax(rect_left.x + rect_left.width, rect_right.x + rect_right.width) + 4;
min_y = fmin(rect_left.y, rect_right.y) - 3; min_y = fmin(rect_left.y, rect_right.y) - 4;
max_y = fmax(rect_left.y + rect_left.height, rect_right.y + rect_right.height) + 3; max_y = fmax(rect_left.y + rect_left.height, rect_right.y + rect_right.height) + 4;
if (min_x < 0 || max_x > 640 || min_y < 0 || max_y > 480) { if (min_x < 0 || max_x > 640 || min_y < 0 || max_y > 480) {
continue; continue;
} }

View File

@@ -30,14 +30,14 @@ int state = ARMOR_STATE;
float curr_yaw = 0, curr_pitch = 0; float curr_yaw = 0, curr_pitch = 0;
float mark_yaw = 0, mark_pitch = 0; float mark_yaw = 0, mark_pitch = 0;
int mark = 0; int mark = 0;
bool use_classifier = false; bool use_classifier = true;
void uartReceive(Uart *uart); void uartReceive(Uart *uart);
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
process_options(argc, argv); process_options(argc, argv);
Uart uart; Uart uart;
thread receive(uartReceive, &uart); // thread receive(uartReceive, &uart);
bool flag = true; bool flag = true;
while (flag) { while (flag) {
@@ -53,13 +53,13 @@ int main(int argc, char *argv[]) {
WrapperHead *video_armor; WrapperHead *video_armor;
WrapperHead *video_energy; WrapperHead *video_energy;
if (from_camera) { if (from_camera) {
video_armor = new CameraWrapper(0, "armor"); video_armor = new CameraWrapper(0/*, "armor"*/);
video_energy = new CameraWrapper(1, "energy"); // video_energy = new CameraWrapper(1, "energy");
} else { } else {
video_armor = new VideoWrapper("/home/xinyang/Desktop/DataSets/video/blue_4.mp4"); video_armor = new VideoWrapper("/home/xinyang/Desktop/DataSets/video/blue_4.mp4");
video_energy = new VideoWrapper("/home/xinyang/Desktop/DataSets/video/blue_4.mp4"); video_energy = new VideoWrapper("/home/xinyang/Desktop/DataSets/video/blue_4.mp4");
} }
if (video_armor->init() && video_energy->init()) { if (video_armor->init()/* && video_energy->init()*/) {
cout << "Video source initialization successfully." << endl; cout << "Video source initialization successfully." << endl;
} else { } else {
delete video_armor; delete video_armor;
@@ -70,7 +70,7 @@ int main(int argc, char *argv[]) {
Mat energy_src, armor_src; Mat energy_src, armor_src;
for(int i=0; i<10; i++){ for(int i=0; i<10; i++){
video_armor->read(armor_src); video_armor->read(armor_src);
video_energy->read(armor_src); // video_energy->read(armor_src);
} }
ArmorFinder armorFinder(ENEMY_BLUE, uart, PROJECT_DIR"/tools/para/", use_classifier); ArmorFinder armorFinder(ENEMY_BLUE, uart, PROJECT_DIR"/tools/para/", use_classifier);
@@ -79,7 +79,7 @@ int main(int argc, char *argv[]) {
energy.setAllyColor(ally_color); energy.setAllyColor(ally_color);
energy.setRotation(energy_part_rotation); energy.setRotation(energy_part_rotation);
bool ok = video_armor->read(armor_src) && video_energy->read(armor_src); bool ok = video_armor->read(armor_src)/* && video_energy->read(armor_src)*/;
while (ok) { while (ok) {
CNT_TIME(WORD_LIGHT_CYAN, "Total", { CNT_TIME(WORD_LIGHT_CYAN, "Total", {