Skip to content

Commit

Permalink
use test_utils for vision examples argparsing (#1293)
Browse files Browse the repository at this point in the history
  • Loading branch information
fifield authored Apr 18, 2024
1 parent 7e20fe5 commit 21da018
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 78 deletions.
22 changes: 1 addition & 21 deletions programming_examples/vision/color_detect/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,7 @@ int main(int argc, const char *argv[]) {
"optional video input file name");
po::variables_map vm;

try {
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);

if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
} catch (const std::exception &ex) {
std::cerr << ex.what() << "\n\n";
std::cerr << "Usage:\n" << desc << "\n";
return 1;
}

try {
test_utils::check_arg_file_exists(vm, "xclbin");
test_utils::check_arg_file_exists(vm, "instr");
} catch (const std::exception &ex) {
std::cerr << ex.what() << "\n\n";
return 1;
}
test_utils::parse_options(argc, argv, desc, vm);

std::cout << "Running colorDetect for resolution: " << testImageWidth << "x"
<< testImageHeight << std::endl;
Expand Down
17 changes: 1 addition & 16 deletions programming_examples/vision/color_threshold/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,7 @@ int main(int argc, const char *argv[]) {
"path of file containing userspace instructions to be sent to the LX6");
po::variables_map vm;

try {
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);

if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
} catch (const std::exception &ex) {
std::cerr << ex.what() << "\n\n";
std::cerr << "Usage:\n" << desc << "\n";
return 1;
}

test_utils::check_arg_file_exists(vm, "xclbin");
test_utils::check_arg_file_exists(vm, "instr");
test_utils::parse_options(argc, argv, desc, vm);

/*
****************************************************************************
Expand Down
22 changes: 1 addition & 21 deletions programming_examples/vision/edge_detect/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,7 @@ int main(int argc, const char *argv[]) {
"optional video input file name");
po::variables_map vm;

try {
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);

if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
} catch (const std::exception &ex) {
std::cerr << ex.what() << "\n\n";
std::cerr << "Usage:\n" << desc << "\n";
return 1;
}

try {
test_utils::check_arg_file_exists(vm, "xclbin");
test_utils::check_arg_file_exists(vm, "instr");
} catch (const std::exception &ex) {
std::cerr << ex.what() << "\n\n";
return 1;
}
test_utils::parse_options(argc, argv, desc, vm);

std::cout << "Running edgeDetect for resolution: " << testImageWidth << "x"
<< testImageHeight << std::endl;
Expand Down
21 changes: 1 addition & 20 deletions programming_examples/vision/vision_passthrough/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,7 @@ int main(int argc, const char *argv[]) {
"path of file containing userspace instructions to be sent to the LX6");
po::variables_map vm;

try {
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);

if (vm.count("help")) {
std::cout << desc << "\n";
return 1;
}
} catch (const std::exception &ex) {
std::cerr << ex.what() << "\n\n";
std::cerr << "Usage:\n" << desc << "\n";
return 1;
}

try {
test_utils::check_arg_file_exists(vm, "xclbin");
test_utils::check_arg_file_exists(vm, "instr");
} catch (const std::exception &ex) {
std::cerr << ex.what() << "\n\n";
}
test_utils::parse_options(argc, argv, desc, vm);

// Read the input image or generate random one if no input file argument
// provided
Expand Down

0 comments on commit 21da018

Please sign in to comment.