c++ - 无法在 docker 容器中打开目录运行代码
问题描述
我是 docker 新手,我正在编写一个代码来使用带有 docker 的 opencv 检测车道线。但是,当我尝试在挂载到本地目录的容器中运行代码时,终端给了我以下错误:
root@26a27d6346fe:~/eec193_lab1/lane_line_detection/build# ./perspective_transform_tester /Users/evangeng/eec_193/eec193_lab1/docker_container/udacity_parameters.yaml /Users/evangeng/eec_193/eec193_lab1/docker_container/lane_line_detection/images/test_images/\*.jpg
terminate called after throwing an instance of 'cv::Exception'
what(): OpenCV(3.4.4-dev) /root/opencv/modules/core/src/glob.cpp:267: error: (-204:Requested object was not found) could not open directory: /Users/evangeng/eec_193/eec193_lab1/docker_container/lane_line_detection/images/test_images in function 'glob_rec'
Aborted
我确信我的路径是正确的,图像格式也是正确的。如果这是一个明显的问题,我深表歉意。
任何意见将不胜感激!
// draws the four source or destination points on an image
void draw_viewing_window(cv::Mat& dst, std::vector<cv::Point2f>& points, cv::Scalar color, int thickness);
int main(int argc, char* argv[]) {
if (argc != 3) {
std::cerr << "Usage: ./perspective_transform_tester <yaml_file> <path/to/images/\\*.png> \n";
return 1;
}
// create save path for final birds-eye view images
std::string save_path = "../images/warped_images";
if (!boost::filesystem::exists(save_path)) {
boost::filesystem::create_directory(save_path);
}
// read in yaml file
cv::FileStorage file(argv[1], cv::FileStorage::READ);
// declare camera matrix and list of distortion coefficients
cv::Mat dist, mtx;
// declare source points and destination points
std::vector<cv::Point2f> src_points, dst_points;
file["distortion coefficients"] >> dist;
file["camera matrix"] >> mtx;
file["source points"] >> src_points;
file["destination points"] >> dst_points;
std::vector<cv::String> image_paths;
cv::glob(argv[2], image_paths);
cv::Mat img, undist_img;
std::vector<cv::Mat> axs(image_paths.size());
for (unsigned int i = 0; i < image_paths.size(); i++) {
img = cv::imread(image_paths[i]);
cv::undistort(img, undist_img, mtx, dist);
draw_viewing_window(undist_img, src_points, cv::Scalar(0,255,0), 5);
}
subplot("source points", axs, 4, 2);
}
编辑:以下是我的dockerfile:
FROM spmallick/opencv-docker:opencv
RUN apt-get update -y
RUN apt-get install libboost-all-dev -y
RUN apt-get install ffmpeg -y
RUN apt-get install python-numpy -y
RUN cd ~
RUN git clone https://github.com/lava/matplotlib-cpp.git
RUN cp matplotlib-cpp/matplotlibcpp.h /usr/include/
RUN rm -rf matplotlib-cpp
当我创建容器时,我使用了:
docker run -it --name=lanelines -v <path_where_I_store_my_codes>:/root/eec193_lab1 eec193_lab1
解决方案
推荐阅读
- javascript - 将列添加到 JQuery 中的新表行
- ns-3 - NS3如何获取节点的以下属性
- java - 如何在java(jsp)中计算时间前
- html - 2列布局HTML/CSS
- python - 我如何在 python 请求中将图像作为参数以及 url 作为第二个参数传递?
- python - 带有 dlib 的面部识别槽烧瓶给出 NameError: name 'face_utils' is not defined
- java - 没有 Spring MVC 和 Spring Boot 的 Spring Data JPA
- ios - 使组合直通发布者不那么全球化
- php - 如何在laravel中将图像放置到1/1画布上
- airflow - 是否有明确的气流许可清单?