VLTIF
CS426FinalProject
|
#include <iostream>
#include <vector>
#include <cv.h>
#include "feature/VehicleDetection.h"
#include <cvaux.h>
#include <highgui.h>
#include "ui/LaneDrawing.h"
#include "feature/FeaturePointUtilities.h"
#include "core/Enumerations.h"
#include "core/Options.h"
#include "core/Parser.h"
#include "ui/Mouse.h"
#include "structures/Vehicle.h"
Go to the source code of this file.
Functions | |
void | init (Options &options) |
int | main (int argc, char **argv) |
Variables | |
int | pX |
int | pY |
size_t | mouse_flag |
void init | ( | Options & | options | ) |
Definition at line 160 of file main.cpp.
References Options::bout, PointTracker::build_background(), Options::cap, Options::DEBUG, Options::dout, Options::equalizeHistogram, Options::frame_count, Options::interest_point_max_life, mouse_flag, Options::pointHistory, PointTracker::set_point_max_life(), Options::show, Options::siftCommonParams, Options::siftDescriptorParams, Options::siftDetectorParams, Options::start_frame, Options::video_filename, Options::video_output_filename, Options::vout, and Options::window_name.
Referenced by main().
{ options.DEBUG = true; options.equalizeHistogram = true; options.frame_count = options.start_frame; mouse_flag = 0; //create window if (options.show == true) { namedWindow(options.window_name.c_str()); namedWindow("black frame"); namedWindow("density frame"); } //open video file options.cap.open(options.video_filename); int ex = static_cast<int> (options.cap.get(CV_CAP_PROP_FOURCC)); Size S = Size( (int) options.cap.get(CV_CAP_PROP_FRAME_WIDTH), (int) options.cap.get(CV_CAP_PROP_FRAME_HEIGHT)); options.vout.open(options.video_output_filename.c_str(), ex, options.cap.get(CV_CAP_PROP_FPS) + 5, S, true); options.bout.open("data/black_output.avi", ex, options.cap.get(CV_CAP_PROP_FPS) + 5, S, true); options.dout.open("data/density_output.avi", ex, options.cap.get(CV_CAP_PROP_FPS) + 5, S, true); options.pointHistory.set_point_max_life(options.interest_point_max_life); //build the background set of interest points options.pointHistory.build_background( options.video_filename, options.siftCommonParams, options.siftDescriptorParams, options.siftDetectorParams); }
int main | ( | int | argc, |
char ** | argv | ||
) |
start lane drawing section
END OF LANE DRAWING
build interest point background dictionary
compute list of candidates vector<Vehicle> candidates = VehicleDetection::computeCandidates(options.density_frame);
compute validated list of vehicles vector<Vehicle> classifiedVehicles = VehicleDetection::classifyCandidates(options.frame, candidates);
Definition at line 41 of file main.cpp.
References Options::black_frame, Options::bout, Options::cap, COLOR_BLUE, COLOR_GREEN, Enumerations::color_interp(), COLOR_RED, DetectorType::compute_frame(), compute_point_density(), Options::DEBUG, Options::density_frame, Options::density_window, Options::detector, Options::dout, Options::equalizeHistogram, Options::frame, Options::frame_count, Options::frame_rate, Options::gray_frame, init(), Options::key, lane_manager(), Options::lanes, mouse_flag, Parser::parse_config_file(), Options::pointHistory, Options::show, Options::start_frame, Options::stop_frame, PointTracker::update_points(), Options::vout, Options::window_name, and Parser::write_configuration().
{ //create options Options options; options.DEBUG = true; if( options.DEBUG == true) cout << "Start of program" << endl; //parse command-line options if( options.DEBUG == true) cout << "Start of parser" << endl; Parser::parse_config_file(argc, argv, options, "data/options.cfg"); if( options.DEBUG == true) cout << "End of parser" << endl; //initialize remaining options init(options); vector<KeyPoint> points; vector<Tuple> showPoints; lane_manager(options); mouse_flag = 2; //load first frame for (size_t i = 0; i < options.start_frame; i++) options.cap >> options.frame; options.black_frame = Mat(Size(options.frame.cols, options.frame.rows), CV_8UC3); options.density_frame = Mat(Size(options.frame.cols, options.frame.rows), CV_8UC3); while (options.frame.data && (options.stop_frame == -1 || (int) options.frame_count < options.stop_frame)) { //compute keypoints cvtColor(options.frame, options.gray_frame, CV_BGR2GRAY); // if( options.equalizeHistogram == true ) equalizeHist( options.gray_frame, options.gray_frame); options.detector->compute_frame(options.gray_frame, points, options.lanes); //add keypoints to frame record showPoints = options.pointHistory.update_points(points); //compute density image compute_point_density(options.density_frame, showPoints, Size(options.frame.cols, options.frame.rows), Size(options.density_window, options.density_window)); //track //some tracking functions //draw keypoints on frame for (size_t i = 0; i < showPoints.size(); i++) if (showPoints[i].span > 8) { circle(options.frame, Point(showPoints[i].centroid.x, showPoints[i].centroid.y), 1, Enumerations::color_interp(COLOR_RED, COLOR_GREEN, showPoints[i].strength), 1); circle(options.black_frame, Point(showPoints[i].centroid.x, showPoints[i].centroid.y), 1, Enumerations::color_interp(COLOR_RED, COLOR_GREEN, showPoints[i].strength), 1); } else { circle(options.frame, Point(showPoints[i].centroid.x, showPoints[i].centroid.y), 1, COLOR_BLUE, 1); circle(options.black_frame, Point(showPoints[i].centroid.x, showPoints[i].centroid.y), 1, COLOR_BLUE, 1); } //draw lanes onto images for (size_t z = 0; z < options.lanes.size(); z++) { options.lanes[z].draw(options.density_frame); options.lanes[z].draw(options.black_frame); options.lanes[z].draw(options.frame); } if (options.show) { imshow(options.window_name.c_str(), options.frame); imshow("black frame", options.black_frame); imshow("density frame", options.density_frame); options.key = waitKey(options.frame_rate); } else { if (options.frame_count % 10 == 0) cout << options.frame_count << endl; options.key = waitKey(1); } options.dout << options.density_frame; options.vout << options.frame; options.bout << options.black_frame; if (options.key == 27) break; options.cap >> options.frame; options.frame_count++; options.black_frame = Scalar(0, 0, 0, 0); options.density_frame = Scalar(0, 0, 0, 0); } Parser::write_configuration( options ); return 0; }
size_t mouse_flag |
Definition at line 34 of file main.cpp.
Referenced by draw_lanes(), init(), main(), and mouseFunc().
int pX |
Definition at line 33 of file main.cpp.
Referenced by draw_lanes(), and mouseFunc().
int pY |
Definition at line 33 of file main.cpp.
Referenced by draw_lanes(), and mouseFunc().