Ask Your Question

How to write the output image of an Opencv program in an excel sheet

asked 2015-07-02 02:02:16 -0500

Manimaran gravatar image

Hi All, I'm working on Template matching program using OpenCV . I want to save the Result image in an excel sheet. How to call a excel sheet from a opencv program?

Thanks, Manimaran

edit retag flag offensive close merge delete



There is no straight way to do that in OpenCV ;)

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-02 02:14:49 -0500 )edit

OpenCV is standard C++. Try out some C++ libs for read/write xls and link it with your application

pklab gravatar imagepklab ( 2015-07-02 02:22:03 -0500 )edit

3 answers

Sort by ยป oldest newest most voted

answered 2015-07-02 03:47:07 -0500

LorenaGdL gravatar image

updated 2015-07-02 03:47:58 -0500

Though as already said this is not a real OpenCV question/answer, rather more a C++ one, I leave it here my easy function to save matrices as .csv files (comma separated values), which can be opened as Excel sheets. This is what I use inside my OpenCV code, so it should work for you too

#include <fstream>

void saveMatToCsv(Mat &matrix, string filename){
    ofstream outputFile(filename);
    outputFile << format(matrix, "CSV") << endl;
edit flag offensive delete link more


This saves the pixel values in an excel sheet. I got the impression that he actually wants the image inside it. @Manimaran could you elaborate?

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-02 03:52:39 -0500 )edit

@StevenPuttemans: hmmm, I really thought he needed the pixel values. Makes no sense to me to save an image in an excel sheet to be honest. Let's see what he says :)

LorenaGdL gravatar imageLorenaGdL ( 2015-07-02 03:58:08 -0500 )edit

@StevenPuttemans, @Lorena GdL: Thanks to both of you for your time. I dont want the pixel values, I need images to be saved on the excel. Currently I'm working on the automation(with the help of Template Matching- reading two images and comparing it and need to say whether they are equal or not)of automotive related test cases and the test cases output are the images. I want to save those images in an excel. Moreover my next task is I want to read images (both template image(column A in excel) and source image(column B)) from excel sheet and save the output in column c in excel sheet.Do you have any idea on this. If you have please help me.

Manimaran gravatar imageManimaran ( 2015-07-03 02:13:46 -0500 )edit

@Manimaran: that's beyond OpenCV's boundaries. As LBerger said, just saving images inside an Excel sheet is not trivial as Excel is prepare to handle data (text and numbers), @StevenPuttemans: I hate you, you were right at the end ;)

LorenaGdL gravatar imageLorenaGdL ( 2015-07-03 02:29:15 -0500 )edit

@Lorena GdL you owe me a beer!

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-03 03:19:01 -0500 )edit

answered 2015-07-23 21:21:46 -0500

updated 2015-07-23 21:42:42 -0500

here a c++ code. maybe it helps

another way IMHO using excel macros can help. i can guide you using macros if you need.

edit flag offensive delete link more

answered 2015-07-02 04:30:40 -0500

LBerger gravatar image

updated 2015-07-02 04:31:28 -0500

It's possible to save an image in spreadsheet. For Excel using microsoft API i don't know how to But I know it for libreoffice using UNO in a document. For a spreadsheet it is similar. You can use UNO to write an xls or xlsx spreadsheet. that's not trivial

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2015-07-02 02:02:16 -0500

Seen: 2,619 times

Last updated: Jul 23 '15