Skip to content

Commit

Permalink
move test cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
DuJiajun1994 committed Apr 6, 2017
1 parent c7e7b2a commit df0a748
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 29 deletions.
2 changes: 1 addition & 1 deletion CMakeLists_fast_rcnn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ link_directories(${CUDA_PATH}/lib64)
aux_source_directory(src/opencv2 OPENCV_TRACKING_SOURCE_FILES)

add_executable(test_fast_rcnn_detector
src/test_fast_rcnn_detector.cpp
test/test_fast_rcnn_detector.cpp
src/real_time_monitor.cpp
src/displayer.cpp
src/fusion/detector_only_fusion.cpp
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists_faster_rcnn.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ link_directories(${CUDA_PATH}/lib64)
aux_source_directory(src/opencv2 OPENCV_TRACKING_SOURCE_FILES)

add_executable(test_faster_rcnn_detector
src/test_faster_rcnn_detector.cpp
test/test_faster_rcnn_detector.cpp
src/real_time_monitor.cpp
src/displayer.cpp
src/fusion/detector_only_fusion.cpp
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists_motion_detector.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ link_directories(/usr/local/lib)
aux_source_directory(src/opencv2 OPENCV_TRACKING_SOURCE_FILES)

add_executable(test_motion_detector
src/test_motion_detector.cpp
test/test_motion_detector.cpp
src/motion_detector/background_substraction_motion_detector.cpp)

add_executable(evaluation_region_proposal
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists_yolo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ link_directories(${DARKNET_PATH})
aux_source_directory(src/opencv2 OPENCV_TRACKING_SOURCE_FILES)

set(SOURCE_FILES
src/test_yolo_detector.cpp
test/test_yolo_detector.cpp
src/real_time_monitor.cpp
src/displayer.cpp
src/fusion/detector_only_fusion.cpp
Expand Down
19 changes: 0 additions & 19 deletions src/test_yolo_detector.cpp

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,25 @@
#include "real_time_monitor.hpp"

int main(){
// VOC 1+20 classes
voc_itc = {
Target::UNKNOWN,
// Target::UNKNOWN, Target::BICYCLE, Target::UNKNOWN, Target::UNKNOWN,
Target::UNKNOWN, Target::UNKNOWN, Target::UNKNOWN, Target::UNKNOWN, //bicycle is easy to confuse with person
Target::UNKNOWN, Target::BUS, Target::CAR, Target::UNKNOWN,
Target::UNKNOWN, Target::UNKNOWN, Target::UNKNOWN, Target::UNKNOWN,
Target::UNKNOWN, Target::MOTORBIKE, Target::PERSON, Target::UNKNOWN,
Target::UNKNOWN, Target::UNKNOWN, Target::TRAIN, Target::UNKNOWN
};

string address="/home/dujiajun/CUHKSquare.mpg";
string fast_prototxt = "/home/dujiajun/fast-rcnn/models/VGG16/test.prototxt";
string fast_trained_model = "/home/dujiajun/fast-rcnn/data/fast_rcnn_models/vgg16_fast_rcnn_iter_40000.caffemodel";
// string faster_prototxt = "/home/dujiajun/py-faster-rcnn/models/pascal_voc/VGG16/faster_rcnn_end2end/test.prototxt";
// string faster_trained_model = "/home/dujiajun/py-faster-rcnn/data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel";
// FasterRcnnDetector fasterRcnnDetector(faster_prototxt, faster_trained_model);
// FastRcnnDetector detector(fasterRcnnDetector, fast_prototxt, fast_trained_model);
FastRcnnDetector detector(fast_prototxt, fast_trained_model);
FastRcnnDetector detector(fast_prototxt, fast_trained_model, voc_itc);
DetectorOnlyFusion fusion(detector);
Displayer displayer;
RealTimeMonitor monitor(address, fusion, displayer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@
#include "real_time_monitor.hpp"

int main(){
voc_itc = {
Target::UNKNOWN,
Target::UNKNOWN, Target::BICYCLE, Target::UNKNOWN, Target::UNKNOWN,
Target::UNKNOWN, Target::BUS, Target::CAR, Target::UNKNOWN,
Target::UNKNOWN, Target::UNKNOWN, Target::UNKNOWN, Target::UNKNOWN,
Target::UNKNOWN, Target::MOTORBIKE, Target::PERSON, Target::UNKNOWN,
Target::UNKNOWN, Target::UNKNOWN, Target::TRAIN, Target::UNKNOWN
};
string address="/home/dujiajun/CUHKSquare.mpg";
string prototxt = "/home/dujiajun/py-faster-rcnn/models/pascal_voc/VGG16/faster_rcnn_end2end/test.prototxt";
string trained_model = "/home/dujiajun/py-faster-rcnn/data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel";
FasterRcnnDetector detector(prototxt, trained_model);
FasterRcnnDetector detector(prototxt, trained_model, voc_itc);
DetectorOnlyFusion fusion(detector);
Displayer displayer;
RealTimeMonitor monitor(address, fusion, displayer);
Expand Down
11 changes: 7 additions & 4 deletions src/test_motion_detector.cpp → test/test_motion_detector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ using namespace cv;

int main()
{
VideoCapture cap("/home/dujiajun/CUHKSquare.mpg");
// string address="rtsp:https://192.168.1.201:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream";
string address = "/home/dujiajun/CUHKSquare.mpg";
VideoCapture cap(address);
Mat image;
BackgroundSubstractionMotionDetector motion_detector;
while(cap.read(image)){
for(int i=0;i<20;i++) cap>>image;
vector<Rect> regions = motion_detector.detect(image);
int proposal_num = 0;
for(Rect &region: regions){
Expand All @@ -23,15 +26,15 @@ int main()
int w = region.width, h = region.height;
int center_x = x1 + w / 2, center_y = y1 + h / 2;
getRectSubPix(image, {w, h}, {center_x, center_y}, partImage);
vector<Rect> proposals = region_proposal::selectiveSearch(partImage, 500, 0.8, 50, 1000, 100000, 2.5 );
vector<Rect> proposals = region_proposal::selectiveSearch(partImage, 500, 0.8, 50, 100, 100000, 2.5 );
proposal_num += proposals.size();
for(Rect &proposal: proposals){
int x = x1 + proposal.x, y = y1 + proposal.y;
rectangle(image, {x, y, proposal.width, proposal.height}, Scalar(255, 0, 0), 3, 1);
rectangle(image, {x, y, proposal.width, proposal.height}, Scalar(255, 0, 0), 1, 1);
}
}
cout<<"proposal num: "<<proposal_num<<endl;
imshow("motion detector", image);
waitKey(5);
waitKey(10);
}
}
27 changes: 27 additions & 0 deletions test/test_yolo_detector.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// Created by dujiajun on 3/4/17.
//

#include "detector/yolo_detector.hpp"
#include "fusion/detector_only_fusion.hpp"
#include "real_time_monitor.hpp"

int main(){
coco_itc = {
Target::PERSON, Target::BICYCLE, Target::CAR, Target::MOTORBIKE,
Target::UNKNOWN, Target::BUS, Target::TRAIN, Target::TRUCK,
Target::UNKNOWN, Target::TRAFFIC_LIGHT, Target::FIRE_HYDRANT, Target::STOP_SIGN
}; // MSCOCO 80 classes
for(int i=12;i<80;i++) coco_itc.push_back(Target::UNKNOWN);

// string address="rtsp:https://192.168.1.201:554/user=admin_password=tlJwpbo6_channel=1_stream=0.sdp?real_stream";
string address = "/home/dujiajun/CUHKSquare.mpg";
YoloDetector detector(coco_itc);
DetectorOnlyFusion fusion(detector);
Displayer displayer;
RealTimeMonitor monitor(address, fusion, displayer);
monitor.run();
while(monitor.isRunning()){
this_thread::sleep_for(chrono::milliseconds(100));
}
}

0 comments on commit df0a748

Please sign in to comment.