1234567891011121314151617181920212223242526272829303132 |
- #include "FeedLevelDetector.h"
- #include <iostream>
- int main(int argc, char** argv) {
- FeedLevelDetector detector;
- // 解析命令行参数
- if (argc == 2) {
- // 单张图片模式
- detector.detectFeedLevel(argv[1]);
- FeedLevelDetector detector;
- float distance = detector.detectFeedLevel(argv[1]);
- std::cout << "Feed level distance from top: " << distance << " pixels" << std::endl;
- cv::waitKey(0);
- } else if (argc == 3 && std::string(argv[1]) == "--camera") {
- // 摄像头模式,设置采集频率
- int interval = std::stoi(argv[2]);
- detector.setCaptureInterval(interval);
- detector.startDetectionFromCamera();
- } else {
- std::cerr << "Usage:" << std::endl;
- std::cerr << " 1. Image mode: " << argv[0] << " <image_path>" << std::endl;
- std::cerr << " 2. Camera mode: " << argv[0] << " --camera <interval_sec>" << std::endl;
- std::cerr << " (interval_sec: 10, 30, or 60)" << std::endl;
- return -1;
- }
- return 0;
- }
|