Ask Your Question
0

Saving image in folder using imwrite [closed]

asked 2017-02-26 14:32:08 -0500

Lekha gravatar image

updated 2017-02-26 18:26:05 -0500

Tetragramm gravatar image

Hi all, I specified a path of a folder for saving images using imwrite.

cv2.imwrite("/home/aishu/ros_ws/baxter_right_cam.png", NewImg)

1) I am just curious as to how the imwrite() distinguishes between the image name and the path name. Does "/" tell the function that it should look for the folder?

2) I also tried this: cv2.imwrite("/baxter_right_cam.png", NewImg) Where would an image be saved if I pass on the above argument because I am not able to find this image.

Thank you!

edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant by LBerger
close date 2017-02-27 01:10:50.707015

Comments

I think your question is off-topic. Wikipedia can help you

About tags now imwrite OK 2d-image why not but pattern matching No

LBerger gravatar imageLBerger ( 2017-02-26 15:14:57 -0500 )edit

@Lekha - you're usually not allowed to write files to root ('/') level, it's a matter of priviledge.

berak gravatar imageberak ( 2017-02-27 12:47:00 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-02-26 17:11:49 -0500

(1) this funtion getFileName distinguishes between the image name and the path name.May it help you .

void getFileName(const string& filepath, string& name,string& lastname){
    vector<string> spilt_path;
    SplitString(filepath, spilt_path, "\\");
    int spiltsize = spilt_path.size();
    string filename = "";
    if (spiltsize != 0){
        filename = spilt_path[spiltsize-1];
        vector<string> spilt_name;
        SplitString(filename, spilt_name, ".");
        int name_size = spilt_name.size();
        if (name_size != 0)
            name = spilt_name[0];
        lastname = spilt_name[name_size-1];
    }
}

(2) try "./baxter_right_cam.png" install of "/baxter_right_cam.png",and find it out.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-02-26 14:32:08 -0500

Seen: 4,870 times

Last updated: Feb 26 '17