Merge remote-tracking branch 'origin/master'
# Conflicts: # tools/bind-monitor.sh
This commit is contained in:
@@ -16,7 +16,7 @@ typedef enum{
|
||||
|
||||
class ArmorFinder{
|
||||
public:
|
||||
ArmorFinder(EnemyColor color, Uart &u, string paras_folder);
|
||||
ArmorFinder(EnemyColor color, Uart &u, string paras_folder, const bool &use);
|
||||
~ArmorFinder() = default;
|
||||
|
||||
private:
|
||||
@@ -36,6 +36,7 @@ private:
|
||||
|
||||
int contour_area;
|
||||
Uart &uart;
|
||||
const bool &use_classifier;
|
||||
|
||||
bool stateSearchingTarget(cv::Mat &src);
|
||||
bool stateTrackingTarget(cv::Mat &src);
|
||||
|
||||
@@ -8,12 +8,13 @@
|
||||
#include <opencv2/highgui.hpp>
|
||||
#include <armor_finder/armor_finder.h>
|
||||
|
||||
ArmorFinder::ArmorFinder(EnemyColor color, Uart &u, string paras_folder) :
|
||||
ArmorFinder::ArmorFinder(EnemyColor color, Uart &u, string paras_folder, const bool &use) :
|
||||
uart(u),
|
||||
enemy_color(color),
|
||||
state(STANDBY_STATE),
|
||||
classifier(std::move(paras_folder)),
|
||||
contour_area(0)
|
||||
contour_area(0),
|
||||
use_classifier(use)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,7 +33,7 @@ void ArmorFinder::run(cv::Mat &src) {
|
||||
case SEARCHING_STATE:
|
||||
if(stateSearchingTarget(src_use)){
|
||||
if((armor_box & cv::Rect2d(0, 0, 640, 480)) == armor_box) {
|
||||
if(!classifier){
|
||||
if(!classifier && use_classifier){
|
||||
cv::Mat roi = src_use.clone()(armor_box), roi_gray;
|
||||
cv::cvtColor(roi, roi_gray, CV_RGB2GRAY);
|
||||
cv::threshold(roi_gray, roi_gray, 180, 255, cv::THRESH_BINARY);
|
||||
|
||||
@@ -194,7 +194,7 @@ bool ArmorFinder::stateSearchingTarget(cv::Mat &src) {
|
||||
showArmorBoxVector("boxes", split, armor_boxes);
|
||||
cv::waitKey(1);
|
||||
}
|
||||
if(classifier){
|
||||
if(classifier && use_classifier){
|
||||
for(auto box : armor_boxes){
|
||||
cv::Mat roi = src(box).clone();
|
||||
cv::resize(roi, roi, cv::Size(48, 36));
|
||||
|
||||
14
main.cpp
14
main.cpp
@@ -30,6 +30,7 @@ int state = ARMOR_STATE;
|
||||
float curr_yaw = 0, curr_pitch = 0;
|
||||
float mark_yaw = 0, mark_pitch = 0;
|
||||
int mark = 0;
|
||||
bool use_classifier = false;
|
||||
|
||||
void uartReceive(Uart *uart);
|
||||
|
||||
@@ -72,7 +73,7 @@ int main(int argc, char *argv[]) {
|
||||
video_energy->read(armor_src);
|
||||
}
|
||||
|
||||
ArmorFinder armorFinder(ENEMY_BLUE, uart, PROJECT_DIR"/tools/para/");
|
||||
ArmorFinder armorFinder(ENEMY_BLUE, uart, PROJECT_DIR"/tools/para/", use_classifier);
|
||||
|
||||
Energy energy(uart);
|
||||
energy.setAllyColor(ally_color);
|
||||
@@ -119,6 +120,7 @@ int main(int argc, char *argv[]) {
|
||||
void uartReceive(Uart *uart) {
|
||||
char buffer[100];
|
||||
int cnt = 0;
|
||||
LOGM("data receive start!");
|
||||
while (true) {
|
||||
char data;
|
||||
while ((data = uart->receive()) != '\n') {
|
||||
@@ -128,7 +130,8 @@ void uartReceive(Uart *uart) {
|
||||
cnt = 0;
|
||||
}
|
||||
}
|
||||
if (cnt == 10) {
|
||||
// LOGM("%d", cnt);
|
||||
if (cnt == 11) {
|
||||
if (buffer[8] == 'e') {
|
||||
state = ENERGY_STATE;
|
||||
LOG(RECEIVE_LOG_LEVEL, "Energy state");
|
||||
@@ -136,6 +139,13 @@ void uartReceive(Uart *uart) {
|
||||
state = ARMOR_STATE;
|
||||
LOG(RECEIVE_LOG_LEVEL, "Armor state");
|
||||
}
|
||||
if (buffer[10] == 0){
|
||||
use_classifier = false;
|
||||
LOG(RECEIVE_LOG_LEVEL, "Classifier off!");
|
||||
} else if(buffer[10] == 1){
|
||||
use_classifier = true;
|
||||
LOG(RECEIVE_LOG_LEVEL, "Classifier on!");
|
||||
}
|
||||
memcpy(&curr_yaw, buffer, 4);
|
||||
memcpy(&curr_pitch, buffer + 4, 4);
|
||||
LOG(RECEIVE_LOG_LEVEL, "Get yaw:%f pitch:%f", curr_yaw, curr_pitch);
|
||||
|
||||
Reference in New Issue
Block a user