# RPI3: Trying to cv::imwrite to external usb

I'm trying to save an image received from a callback to an external USB drive using OpenCV3.1 cv::imwrite.

I have mounted the USB into /media/usb with ownership to "pi", and I can move/copy/delete files using CLI without the need of "su" nor "sudo", so I think I did it right.

The problem is that when I try to save an image using cv::imwrite, it simply does not save. I added a ROS_ASSERT to the cv::imwrite, and the node simply shutsdown. I also looked at the logs, but cannot find anything relevant because the node simply shutsdown.

Here's the code:

bool camera::takeScreenshotService(std_srvs::Trigger::Request &req, std_srvs::Trigger::Response &res)
{
time_t now;
time(&now);
struct tm* current_time = localtime(&now);
char buffer[256];
strftime(buffer, sizeof(buffer), "%Y-%m-%d_%T", current_time);
std::string current_time_s(buffer);
std::string image_name = save_image_path + current_time_s + image_extension;

ROS_ASSERT( cv::imwrite(image_name, image_rec) );

res.success = true;
return true;
}


image_rec is received in the camera callback, and save_image_path and image_extension are global parameters. All these are set correctly, because when I change the path to a "local" path (like /home/pi) it works flawlessly.

Is it possible that I need to change or modify the ownership or persmissions when mounting the USB in order to be able to save files using ROS?

edit retag close merge delete