mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-15 14:15:54 -06:00
[GH-ISSUE #301] How to convert opencv Mat data to image_buffer? #242
Labels
No labels
awaiting user feedback
bug
cmake
cmake
docs
feature request
in progress
long term
medium term
medium term
pull-request
question
question
ready to close
short term
under investigation
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: github-starred/libxlsxwriter#242
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @simon5u on GitHub (Aug 10, 2020).
Original GitHub issue: https://github.com/jmcnamara/libxlsxwriter/issues/301
Originally assigned to: @jmcnamara on GitHub.
Hi all, I am using opencv to read the frame from video. I want to output the frame into excel but I received the following error "[WARNING]: worksheet_insert_image()/_opt: couldn't read image type for: image_buffer.". Following is my code:-
Please help. Thanks.
@jmcnamara commented on GitHub (Aug 10, 2020):
That warning usually means that the data doesn't contain any headers that indicate that the file is a known image format.
Can you add the image to this issue on GitHub. Also can you print out the size of
fsizeto see if it equates to the byte size of the file.Also, it would be good to attach a full working example to avoid any confusion.
@simon5u commented on GitHub (Aug 10, 2020):
Thanks for the reply. I am using ubuntu16, gcc5.4.0, opencv2.4.9, libxlsxwriter and codeblocks. Attached is the code I am trying. Following is the main.cpp. Please help.
===
#include <sys/stat.h>
#include "xlsxwriter.h"
#include "opencv2/opencv.hpp"
int main() {
}
xlsx_example.tar.gz
@jmcnamara commented on GitHub (Aug 10, 2020):
I compiled and ran your example.
The
worksheet_insert_image_buffer()function works on a buffer of image data. However, the cv::MAT appears to be a matrix representation of the pixels in the file.You need to be able to convert this into the raw buffer format for the PNG file or use some simpler read mechanism. The imread() function probably isn't the right way to do what you need to do.
I don't use OpenCV so I can't really help you with this. It is more of a general question than a Libxlsxwriter question. As such it may be better to ask it on StackOverflow.
Also, if you are reading from video you will need to ensure that the frame data is actually in PNG (or a supported format). You can't insert a raw H.264 or other video frame into Excel.
@simon5u commented on GitHub (Aug 11, 2020):
Thanks for the feedback. Here is the solution I found:-
@jmcnamara commented on GitHub (Aug 11, 2020):
Thanks for letting me know. Someone else may find that useful.