Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
553 changes: 553 additions & 0 deletions data/classification/squeezenet/1.1/caffe/squeezenet1.1.prototxt

Large diffs are not rendered by default.

Binary file not shown.
1,912 changes: 1,912 additions & 0 deletions data/object_detection/common/mobilenet-ssd/caffe/mobilenet-ssd.prototxt

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion data/squeezenet1.1.labels
Original file line number Diff line number Diff line change
Expand Up @@ -997,4 +997,4 @@ earthstar
hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa
bolete
ear, spike, capitulum
toilet tissue, toilet paper, bathroom tissue
toilet tissue, toilet paper, bathroom tissue
11 changes: 11 additions & 0 deletions include/classificator.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,15 @@ class Classificator
public:
vector<string> classesNames;
virtual Mat Classify(Mat image) = 0 {}
};

class DnnClassificator :public Classificator {
string path_to_model, path_to_config, path_to_labels;
int width, height;
Scalar mean;
bool swap;
Net net;
public:
DnnClassificator(string ptm, string ptc, string ptl, int nwidth, int nheight, Scalar nmean = (0, 0, 0, 0), bool srb = 0);
Mat Classify(Mat image);
};
1 change: 1 addition & 0 deletions include/tracking_by_matching.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ using TrackedObjects = std::deque<TrackedObject>;
bool operator==(const TrackedObject& first, const TrackedObject& second);
bool operator!=(const TrackedObject& first, const TrackedObject& second);
/// (object id, detected objects) pairs collection.

using ObjectTracks = std::unordered_map<int, TrackedObjects>;

///
Expand Down
63 changes: 63 additions & 0 deletions samples/practice1_Anton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <iostream>
#include <string>

#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

#include "filter.h"

using namespace cv;
using namespace std;

const char* cmdAbout = "Sample of OpenCV usage. ";

const char* cmdOptions =
"{ i image | <none> | image to process }"
"{ w width | <none> | width for image resize }"
"{ f filter | <none> | G - gray, R - resize }"
"{ h height | <none> | height for image resize }"
"{ q ? help usage | <none> | print help message }";

int main(int argc, char** argv)
{
// Process input arguments
CommandLineParser parser(argc, argv, cmdOptions);
parser.about(cmdAbout);
string filter;
if (parser.has("help"))
{
parser.printMessage();
return 0;
}
if (!parser.check())
{
parser.printErrors();
return 0;
}
if (parser.has("filter")) {
filter = parser.get<string>("filter");
}

// Load image
String imgName(parser.get<String>("image"));
cv::Mat src;
src = imread(imgName, 1);


// Filter image
if (filter.find('g') != string::npos) {
GrayFilter f;
src = f.ProcessImage(src);
}
if (filter.find('r') != string::npos) {
ResizeFilter filt(parser.get<int>("width"), parser.get<int>("height"));
src = filt.ProcessImage(src);
}
// Show image
cv::imshow("image", src);
cv::waitKey();



return 0;
}
78 changes: 78 additions & 0 deletions samples/practice2_Anton.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include <iostream>
#include <fstream>
#include <string>
#include <set>

#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>

#include "classificator.h"

using namespace cv;
using namespace std;

const char* cmdAbout = "Sample of OpenCV usage. ";

const char* cmdOptions =
"{ i image | <none> | image to process }"
"{ w width | | image width for classification }"
"{ h heigth | | image heigth for classification }"
"{ model_path | | path to model }"
"{ config_path | | path to model configuration }"
"{ label_path | | path to class labels }"
"{ mean | | vector of mean model values }"
"{ swap | | swap R and B channels. TRUE|FALSE }"
"{ q ? help usage | | print help message }";

int main(int argc, char** argv)
{
// Process input arguments
CommandLineParser parser(argc, argv, cmdOptions);
parser.about(cmdAbout);

if (parser.has("help"))
{
parser.printMessage();
return 0;
}
if (!parser.check())
{
parser.printErrors();
return 0;
}

// Load image and init parameters
String imgName(parser.get<String>("image"));
cv::Mat src;
src = imread(imgName);
// cv::imshow("image",src);
//waitKey();

//Image classification
string mp = parser.get<string>("model_path");
string cp = parser.get<string>("config_path");
string lp = parser.get<string>("label_path");
int wid = parser.get<int>("width");
int hei = parser.get<int>("heigth");
Scalar me = parser.get<Scalar>("mean");
int sw = parser.get<int>("swap");
Point classIdPoint;
double confidence;
DnnClassificator ds(mp, cp, lp, wid,hei, me, sw);
Mat res = ds.Classify(src);
minMaxLoc(res, 0, &confidence, 0, &classIdPoint);
int classId = classIdPoint.x;

//Show result

/*ifstream ifs("labels.labels");
int s = 0;
while (s <= classId || !ifs.eof())s++;
string buff;
getline(ifs, buff);*/
cout << "Class:" << classId<< endl;
cout << "Confidence:" << confidence << endl;


return 0;
}
Loading