Skip to content

Commit 6e41868

Browse files
authored
Merge pull request #8 from llDev-Rootll/Phase-2
Phase 2
2 parents f4ea286 + 86ced1a commit 6e41868

File tree

184 files changed

+10948
-627
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+10948
-627
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ script:
3737
- test/cpp-test
3838

3939
after_success:
40-
- coveralls --root .. -E ".*external.*" -E ".*CMakeFiles.*" -E ".*test/.*.cpp.*"
40+
- coveralls --root .. -E ".*external.*" -E ".*CMakeFiles.*" -E ".*test/.*.cpp.*" -E ".*app/main.cpp" -E ".*opencv*"
4141

4242
notifications:
4343
email: false

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ option(COVERAGE "Generate Coverage Data" OFF)
1818
if (COVERAGE)
1919
include(CodeCoverage)
2020
set(LCOV_REMOVE_EXTRA "'vendor/*'")
21-
setup_target_for_coverage(code_coverage test/cpp-test coverage)
22-
set(COVERAGE_SRCS app/main.cpp test/include/test_Robot.h test/include/test_HumanDetector.h test/src/test_Robot.cpp test/src/test_HumanDetector.cpp)
21+
setup_target_for_coverage(code_coverage test/human_detector_tracker_tests coverage)
22+
set(COVERAGE_SRCS src/Robot.cpp src/HumanDetector.cpp include/Humandetector.h include/Rohot.h)
2323

2424
SET(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
2525
SET(CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
@@ -35,5 +35,5 @@ set(CMAKE_CXX_STANDARD 14)
3535
add_subdirectory(app)
3636
add_subdirectory(src)
3737
add_subdirectory(test)
38-
add_subdirectory(test/src)
38+
3939
add_subdirectory(vendor/googletest/googletest)

README.md

Lines changed: 62 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11

2+
23
# Human_Detection_Tracking-CPP
3-
[![Build Status](https://app.travis-ci.com/aditiramadwar/Human_Detection_Tracking-CPP.svg?branch=Phase_1)](https://app.travis-ci.com/aditiramadwar/Human_Detection_Tracking-CPP)
4-
[![Coverage Status](https://coveralls.io/repos/github/aditiramadwar/Human_Detection_Tracking-CPP/badge.svg?branch=Phase_1)](https://coveralls.io/github/aditiramadwar/Human_Detection_Tracking-CPP?branch=Phase_1)
4+
[![Build Status](https://app.travis-ci.com/llDev-Rootll/Human_Detection_Tracking-CPP.svg?branch=master)](https://app.travis-ci.com/llDev-Rootll/Human_Detection_Tracking-CPP)
5+
[![Coverage Status](https://coveralls.io/repos/github/llDev-Rootll/Human_Detection_Tracking-CPP/badge.svg?branch=master)](https://coveralls.io/github/llDev-Rootll/Human_Detection_Tracking-CPP?branch=master)
56
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
67

78
A C++ module to detect and track humans which outputs location information directly in a robot's reference frame.
89

910
## Authors
10-
11+
Sprint 1 -
1112
- Arunava Basu (Navigator)
1213
- Aditi Ramadwar (Driver)
1314

15+
Sprint 2 -
16+
- Arunava Basu (Driver)
17+
- Aditi Ramadwar (Navigator)
1418
## Introduction
1519
Human detection or person detection is the computer vision task of the localization and classification of human being(s) in an image. This is a key part in robotic applications for various reasons such as safety, obstacle avoidance, collaborative robotics, etc.
1620

@@ -43,8 +47,7 @@ Continuous integration is tracked by using Travis CI and code coverage is tracke
4347

4448
Run this command in the root directory to install the dependencies :
4549
```
46-
chmod a+x scripts/install_dependencies.sh
47-
./scripts/install_dependencies.sh
50+
sh install_dependencies.sh
4851
```
4952

5053
## System Architecture
@@ -54,29 +57,73 @@ The following shows the activity diagram for our proposed schema :
5457
*Fig 1 : Activity Diagram*
5558

5659
The corresponding class diagram can be found [here](https://github.com/llDev-Rootll/Human_Detection_Tracking-CPP/blob/development/UML/revised/Revised_Class_Diagram.pdf).
57-
## Testing
60+
61+
## Output Data Explained
62+
At the output of the Human Detection module from the `detectHumans` method we get a vector of Rects ('Rect' is a data type in OpenCV).
63+
64+
The structure of Rect is: (x, y, z, redundant); It has four parameters,
65+
the first three parameters indicate the coordinates of a point in terms of robot's reference frame (x, y, z)
66+
67+
These coordinates can be extracted from the Rect and used as per application.
68+
The redundant variable is part of the transformation vector which is not useful for us for showing the location of the human detected.
69+
70+
For each person detected in frame, two Rects are created. We are taking two location points of each human detected. To get an estimated location of the human in the entire frame, we need to extract the x, y, z coordinates from both the Rects created where,
71+
x is the distance of the human from the robot's reference frame,
72+
y is the horizontal component and
73+
z is the vertical component.
74+
75+
Example:
76+
If there are two humans detected in a frame, then we will get a vector of four Rects. Consider the output vector variable we got is 'positions'. Size of positions is 4 since in our example 2 humans are detected, then, first human's location will be extracted from Rects positions[0] and positions[1]
77+
second human's location will be extracted from Rects positions[2] and positions[3]
78+
Example for location extraction of one of the coordinates of the first human:
79+
80+
> x = position[0] (0)
81+
> y = position[0] (1)
82+
> z = position[0] (2)
83+
84+
## Steps to Run the application
85+
Run the following commands in the root folder to build and run the Human Detector and Tracker
86+
87+
sh getModels.sh
88+
sh build_with_coverage.sh
89+
sh run_app.sh
90+
91+
## Running Unit tests
5892
Unit Testing will be used to test each submodule and ensure complete code coverage. For this Google Gtest will be leveraged and identical test classes and methods will be created with minimal modification in order to facilitate testing.
93+
Execute these commands in the root folder to run the test cases:
94+
```
95+
sh run_tests.sh
96+
```
97+
## Running cpplint & cppcheck tests
98+
Run the following command in the root directory to generate cpplint results in **results** folder
5999

60-
Additionally, a small test subset of the COCO test data will be used to validate model accuracy.
100+
sh run_cpplint.sh
101+
102+
Run the following command in the root directory to generate cppcheck results in **results** folder
103+
104+
sh run_cppcheck.sh
61105

62106
## Building without code coverage
63-
Execute these commands in the root folder :
107+
Run the following command in the root folder :
64108
```
65-
chmod a+x scripts/build_without_coverage.sh
66-
./scripts/build_without_coverage.sh
109+
sh build_without_coverage.sh
67110
```
68111
## Building with code coverage
69112

70-
Execute these commands in the root folder :
113+
Run these commands in the root folder :
71114
```
72115
sudo apt-get install lcov
73-
chmod a+x scripts/build_with_coverage.sh
74-
./scripts/build_with_coverage.sh
116+
sh build_with_coverage.sh
75117
```
118+
## Generate Doxygen documentation
119+
Run the following command in the root folder:
120+
121+
sh create_doxy_docs.sh
122+
76123
## Phase 1
77124

78125
- Defined Robot, HumanDetector and test classes according to the UML diagrams.
79126
- Implemented all Robot and HumanDetector methods except for transformToRobotFrame method.
80127
- Definition and implementation of test cases are planned for Phase 2.
81-
Please refer to the backlog table, [here](https://docs.google.com/spreadsheets/d/1tjJKUd9B4bBSYAHnrwuMjWNl_lUBmqeB6lw7iTNKZSg/edit?usp=sharing), for an exhaustive list tasks completed in Phase 1.
82-
128+
Please refer to the backlog table, [here](https://docs.google.com/spreadsheets/d/1tjJKUd9B4bBSYAHnrwuMjWNl_lUBmqeB6lw7iTNKZSg/edit?usp=sharing), for an exhaustive list tasks completed in Phase 1.
129+
## Phase 2
34.7 KB
Binary file not shown.
30.5 KB
Binary file not shown.

app/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
add_executable(shell-app main.cpp)
1+
add_executable(human_detector_tracker main.cpp)
22
include_directories(
33
${CMAKE_SOURCE_DIR}/include ${OpenCV_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIR}
44
)
55

66
find_package(OpenCV REQUIRED)
77
find_package(Eigen3 REQUIRED)
8-
target_link_libraries(shell-app PUBLIC detector_lib ${OpenCV_LIBS} ${EIGEN3_LIBS})
8+
target_link_libraries(human_detector_tracker PUBLIC detector_lib ${OpenCV_LIBS} ${EIGEN3_LIBS})

app/main.cpp

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,59 @@ using std::endl;
1515

1616
int main() {
1717
cout << "Human Detector and Tracker" << endl;
18-
Robot bot(Eigen::Matrix4d::Random());
19-
cout << "Checking detectHuman functionality: "
20-
<< "\n" << bot.detectHumans() << endl;
18+
Robot bot(Eigen::Matrix4d::Identity());
19+
// Load the network
20+
Net net = bot.loadNetwork("../network/yolov3.cfg",
21+
"../network/yolov3.weights");
22+
// Start video capture by activating camera
23+
cv::VideoCapture cap(0);
24+
// Test if camera is actually active or not
25+
if (cap.isOpened() == false) {
26+
std::cout << "Cannot open the video camera" << std::endl;
27+
// Wait for any key press
28+
std::cin.get();
29+
return -1;
30+
}
31+
32+
// Create name for window frame
33+
static const string window_name = "Human Object Detector & Tracker";
34+
cv::namedWindow(window_name, cv::WINDOW_NORMAL);
35+
Mat frame;
36+
vector<Rect> positions;
37+
while (true) {
38+
cap >> frame;
39+
positions = bot.detectHumans(frame, net);
40+
// Print positions of humans detected
41+
if (positions.size() > 0) {
42+
cout << "Number of people detected: " << positions.size()/2
43+
<< endl;
44+
for (size_t i = 0; i < positions.size()/2; i++) {
45+
Rect upper_bound_position = positions[i*2];
46+
double x_u = upper_bound_position.x;
47+
double y_u = upper_bound_position.y;
48+
double z_u = upper_bound_position.width;
49+
50+
Rect lower_bound_position = positions[i*2+1];
51+
double x_l = lower_bound_position.x;
52+
double y_l = lower_bound_position.y;
53+
double z_l = lower_bound_position.width;
54+
55+
std::cout << "For person "<< i+1 << ", Postion is: (" << x_u
56+
<< ", "<< y_u <<", "<< z_u << ") and ("<<
57+
x_l << ", "<< y_l <<", "<< z_l << ")" << std::endl;
58+
}
59+
} else {
60+
std::cout << "No person detected" << std::endl;
61+
}
62+
positions.clear();
63+
// Show the frame captured on screen
64+
cv::imshow(window_name, frame);
65+
// To get continuous live video until ctrl+C is pressed
66+
if (cv::waitKey(1) == 27) {
67+
break;
68+
}
69+
}
70+
cap.release();
71+
cv::destroyAllWindows();
2172
return 0;
2273
}

assets/accuracy_test.png

1.03 MB
Loading

0 commit comments

Comments
 (0)