Skip to content

Commit

Permalink
finished UX
Browse files Browse the repository at this point in the history
  • Loading branch information
rossGardiner committed Mar 15, 2022
1 parent 1c4b3eb commit 8e0db96
Showing 1 changed file with 18 additions and 42 deletions.
60 changes: 18 additions & 42 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,18 @@
using namespace cv;
using namespace std;

#define PBSTR "||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||"
#define PBWIDTH 60
#define THRES 20

void printProgress(double percentage) {
int val = (int) percentage;
int lpad = (int) (percentage * PBWIDTH);
int rpad = PBWIDTH - lpad;
printf("\r%3d%% [%.*s%*s]", val, lpad, PBSTR, rpad, "");
#define THRES 100


std::string getLetterFromDigit(int digit){
std::string results[] = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z", "del", "space", "nothing"};
return results[digit];
}

void printProgress(float percentage, int prediction) {
std::string letter = getLetterFromDigit(prediction);
cout << "\r Prediction: " << letter << ", Progress: " << percentage << "% - keep signing! ";
fflush(stdout);
}

Expand Down Expand Up @@ -49,34 +52,6 @@ int main(int, char**)
c.start_thread();
CNNProcessor cnn = CNNProcessor(&c, "models/asl-mobilenetv2.pb");

std::vector<std::string> results = {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V",
"W", "X", "Y", "Z", "del", "space", "nothing"};
// BlockingQueue<int> bq;
// bq.Push(5);
// bq.Push(6);
// bq.Push(7);
// bq.Push(8);
// cout << bq.Pop() << "\n";
// cout << bq.Pop() << "\n";
// cout << bq.Pop() << "\n";
// cout << bq.Pop() << "\n";
// cout << bq.Pop() << "\n";

//Camera c = Camera();
//c.Populate();
//c.start_thread();

/*
c.set_current_task('h');
c.Populate();
c.set_current_task('y');
c.Populate();
*/
//CNNProcessor p = CNNProcessor(c);
//p.SelfPush();
//p.SelfPush();
//p.SelfPush();
//c.Stream();

Scene val_cnn;
printf(" _____ _ \n"
Expand All @@ -89,20 +64,20 @@ int main(int, char**)
" |___/ |_| \n \nWelcome to Signapse, the tool for helping everyday people learn sign language for free!");
do
{
cout << '\n' << "Press any key to continue...";
cout << '\n' << "Press ENTER to continue...";
} while (cin.get() != '\n');
int task;
char key;
while(key != 'q'){
c.on(false);
task = makeTask();
printf("Current task is: %d \n", task);
cout << "\n Current task is : " << getLetterFromDigit(task) << "\n";
printf("Enter \"y\" to confirm, \"q\" to quit, or any other key to change task... ");
key = cin.get();
if(key == 'y'){
c.on(true);
printf("\n Task confirmed. Progress...");
double progress = 0.0;
float progress = 0.0;
float nr_correct = 0;
while ((!(waitKey(5) >= 0)) && (progress < 100)){
cnn.SelfPush();
Expand All @@ -115,10 +90,11 @@ int main(int, char**)
progress = (nr_correct / THRES) * 100;
}
cv::Mat boxFrame = drawBox(val_cnn.frame, val_cnn.regionOfInterest);
cv::imshow("window2", boxFrame);
cv::imshow("Signapse", boxFrame);

printProgress(progress);
printProgress(progress, result);
}
cout << "\n";


}
Expand Down

0 comments on commit 8e0db96

Please sign in to comment.