更新通信协议。

This commit is contained in:
xinyang
2019-05-09 20:14:25 +08:00
parent 13ffc6efe6
commit 85e1df61da
6 changed files with 21 additions and 9 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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));