Added new features
This commit is contained in:
+46
-53
@@ -17,30 +17,41 @@ int main(int argc, char** argv)
|
||||
Training tr;
|
||||
|
||||
cout << "Welcome to Jarvis" << endl;
|
||||
cout << "Would you like to calibrate the camera (c), take pictures (p), train the network (t) or run the neural network (r)?" << endl;
|
||||
|
||||
char c;
|
||||
cin >> c;
|
||||
bool running = true;
|
||||
|
||||
switch (c) {
|
||||
case 'c':
|
||||
cam.Calibrate();
|
||||
break;
|
||||
case 'p':
|
||||
tr.CreateTrainingSet();
|
||||
break;
|
||||
case 't':
|
||||
tr.LoadTrainingSet();
|
||||
break;
|
||||
case 'r':
|
||||
run();
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
while (running)
|
||||
{
|
||||
cout << endl << "What would you like to do?" << endl;
|
||||
cout << "Calibrate the camera (c), take pictures (p), train the network (t), run the neural network (r) or exit (e)?" << endl;
|
||||
|
||||
char c;
|
||||
cin >> c;
|
||||
|
||||
cout << endl;
|
||||
|
||||
switch (c) {
|
||||
case 'c':
|
||||
cam.Calibrate();
|
||||
break;
|
||||
case 'p':
|
||||
tr.CreateTrainingSet();
|
||||
break;
|
||||
case 't':
|
||||
tr.LoadTrainingSet();
|
||||
break;
|
||||
case 'r':
|
||||
run();
|
||||
break;
|
||||
case 'e':
|
||||
running = false;
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
cout << "The program has finished, press enter to exit" << endl;
|
||||
cin.ignore();
|
||||
cout << "The program has finished" << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -51,7 +62,13 @@ int run()
|
||||
NeuralNetwork bpn;
|
||||
bpn.Read();
|
||||
|
||||
while (true)
|
||||
cout << "The neural network is ready to be used" << endl;
|
||||
cout << "Please place an item below the camera and press the spacebar" << endl << endl;
|
||||
|
||||
|
||||
bool running = true;
|
||||
|
||||
while (running)
|
||||
{
|
||||
//Take picture and pre-process
|
||||
Mat image, gray_image, binaryImage;
|
||||
@@ -92,41 +109,17 @@ int run()
|
||||
vector<vector<Point>> contours;
|
||||
contours.push_back(contour);
|
||||
drawContours(image, contours, -1, CV_RGB(0, 255, 0), 4);
|
||||
putText(image, cls, cvPoint(15, 30),
|
||||
FONT_HERSHEY_COMPLEX, 1.0, cvScalar(0, 0, 0), 1, CV_AA);
|
||||
putText(image, cls, cvPoint(15, 30), FONT_HERSHEY_COMPLEX, 1.0, cvScalar(0, 0, 0), 1, CV_AA);
|
||||
|
||||
imshow("Neural detection", image);
|
||||
|
||||
waitKey(0);
|
||||
auto c = waitKey(0);
|
||||
|
||||
if (c == 27)
|
||||
{
|
||||
running = false;
|
||||
}
|
||||
|
||||
destroyAllWindows();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
// Creeer een witte image
|
||||
IplImage* iplimage = cvCreateImage(cvSize(binaryImage.cols, binaryImage.rows), IPL_DEPTH_8U, 3);
|
||||
Mat contourImage = cvarrToMat(iplimage);
|
||||
contourImage = Scalar(255, 255, 255);
|
||||
|
||||
// teken de contouren op de witte image
|
||||
vector<vector<Point>> contours;
|
||||
contours.push_back(contour);
|
||||
|
||||
Point2f vertices2f[4];
|
||||
ext.Rectangle().points(vertices2f);
|
||||
|
||||
// Convert them so we can use them in a fillConvexPoly
|
||||
Point vertices[4];
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
vertices[i] = vertices2f[i];
|
||||
}
|
||||
|
||||
// Now we can fill the rotated rectangle with our specified color
|
||||
fillConvexPoly(contourImage, vertices, 4, Scalar(0, 255, 0));
|
||||
drawContours(contourImage, contours, -1, CV_RGB(255, 0, 0));
|
||||
|
||||
imshow("Features", contourImage);
|
||||
waitKey(0);
|
||||
*/
|
||||
}
|
||||
Reference in New Issue
Block a user