Hello,
Thanks for your guide and I am building from the source. Nice GitHub issue and this will help more people. Thanks again. Juneleung May 28 2023 | | Juneleung TD juneleungc...@163.com | ---- Replied Message ---- | From | <oiio-dev-requ...@lists.openimageio.org> | | Date | 05/28/2023 03:14 | | To | <oiio-dev@lists.openimageio.org> | | Subject | Oiio-dev Digest, Vol 176, Issue 21 | Send Oiio-dev mailing list submissions to oiio-dev@lists.openimageio.org To subscribe or unsubscribe via the World Wide Web, visit http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org or, via email, send a message with subject or body 'help' to oiio-dev-requ...@lists.openimageio.org You can reach the person managing the list at oiio-dev-ow...@lists.openimageio.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Oiio-dev digest..." Today's Topics: 1. Re: Connect with opencv (Larry Gritz) ---------------------------------------------------------------------- Message: 1 Date: Sat, 27 May 2023 12:14:11 -0700 From: Larry Gritz <l...@larrygritz.com> To: OpenImageIO dev list <oiio-dev@lists.openimageio.org> Subject: Re: [Oiio-dev] Connect with opencv Message-ID: <f827608c-e9fa-45a3-a5fc-8d5b24d49...@larrygritz.com> Content-Type: text/plain; charset="utf-8" It won't help you in the short term, but this conversation inspired me to make these changes: https://github.com/OpenImageIO/oiio/pull/3853 <https://github.com/OpenImageIO/oiio/pull/3853> On May 27, 2023, at 11:55 AM, Larry Gritz <l...@larrygritz.com> wrote: $ brew info openimageio ==> openimageio: stable 2.4.11.1 (bottled), HEAD Library for reading, processing and writing images https://openimageio.org/ <https://openimageio.org/> Not installed From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openimageio.rb <https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openimageio.rb> License: BSD-3-Clause ==> Dependencies Build: cmake ?, pkg-config ? Required: boost ?, boost-python3 ?, ffmpeg ?, fmt ?, freetype ?, giflib ?, imath ?, jpeg-turbo ?, libheif ?, libpng ?, libraw ?, libtiff ?, opencolorio ?, openexr ?, pugixml ?, pybind11 ?, python@3.11 ?, webp ? ==> Options --HEAD Install HEAD version ==> Analytics install: 2 (30 days), 23 (90 days), 7,666 (365 days) install-on-request: 2 (30 days), 23 (90 days), 7,490 (365 days) build-error: 0 (30 days) The fact that opencv is not listed in Homebrew's list of dependencies makes me think that probably Homebrew's build of OpenImageIO does not include OpenCV support. You might need to build OpenImageIO itself in order to ensure that it has OpenCV support built in. On May 27, 2023, at 11:22 AM, juneleungchan <juneleungc...@163.com <mailto:juneleungc...@163.com>> wrote: Hello, Thanks for your reply. I think the file can be loaded successfully cause I can write it to a local file after reading it. Thanks for your advice and I have changed the namespace to OIIO. My OIIO is downloaded with "brew install opencv?. I don't know if the oiio downloaded in this way has the header and lib of opencv. I'm on a Mac. I am writing a program and found that only OIIO can read and write EXR and DPX files perfectly, so I am now reading files from OIIO and then sending them to CVmat. Thanks. My Code updated: ``` #include <OpenImageIO/imagebuf.h> #include <OpenImageIO/imagebufalgo.h> #include <OpenImageIO/Imath.h> #include <OpenImageIO/imagecache.h> #include <OpenImageIO/imageio.h> using namespace OIIO; using namespace cv; // read QString img = "./0001.dpx"; ImageBuf buf(img.toStdString()); bool okR = buf.read (0, 0, true, TypeDesc::FLOAT); // true // write QString out = "./out.png"; bool okW = buf.write(out.toStdString().data()); // true // to CV auto Mat1 = cv::Mat {}; bool succ = ImageBufAlgo::to_OpenCV(Mat1, buf); // result qDebug()<< okR << okW << succ; // true true false ``` Juneleung TD juneleungc...@163.com <https://dashi.163.com/projects/signature-manager/detail/index.html?ftlId=3&name=Juneleung&uid=juneleungchan%40163.com&iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fwzpmmc%2F3ef565873cb038cd2c89818903cf0fcc.jpg&email=Juneleungchan%40163.com&position=TD&items=%5B%22Juneleungchan%40163.com%22%5D> ---- Replied Message ---- From <oiio-dev-requ...@lists.openimageio.org> <mailto:oiio-dev-requ...@lists.openimageio.org> Date 05/28/2023 01:18 To <oiio-dev@lists.openimageio.org> <mailto:oiio-dev@lists.openimageio.org> Subject Oiio-dev Digest, Vol 176, Issue 18 Send Oiio-dev mailing list submissions to oiio-dev@lists.openimageio.org <mailto:oiio-dev@lists.openimageio.org> To subscribe or unsubscribe via the World Wide Web, visit http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org> or, via email, send a message with subject or body 'help' to oiio-dev-requ...@lists.openimageio.org <mailto:oiio-dev-requ...@lists.openimageio.org> You can reach the person managing the list at oiio-dev-ow...@lists.openimageio.org <mailto:oiio-dev-ow...@lists.openimageio.org> When replying, please edit your Subject line so it is more specific than "Re: Contents of Oiio-dev digest..." Today's Topics: 1. Connect with opencv (juneleungchan) 2. Re: Connect with opencv (Larry Gritz) ---------------------------------------------------------------------- Message: 1 Date: Sun, 28 May 2023 01:08:38 +0800 (GMT+08:00) From: juneleungchan <juneleungc...@163.com <mailto:juneleungc...@163.com>> To: "oiio-dev@lists.openimageio.org <mailto:oiio-dev@lists.openimageio.org>" <oiio-dev@lists.openimageio.org <mailto:oiio-dev@lists.openimageio.org>> Subject: [Oiio-dev] Connect with opencv Message-ID: <4c6b78bf.cb38.1885e2f0094.coremail.juneleungc...@163.com <mailto:4c6b78bf.cb38.1885e2f0094.coremail.juneleungc...@163.com>> Content-Type: text/plain; charset="utf-8" Hello, Thanks for your great work of OIIO. I have a question when using OIIO and wanna to ask how to use with details. I'm not sure if I'm writing to this email address is the right channel to ask questions. If not, please point me to it, thanks. My question is about how to convert between OIIO's buf and Opencv. I found related functions (ImageBufAlgo::to_OpenCV and ImageBufAlgo::from_OpenCV) in the manual, but it seems that I always get a false result for these the result of functions . I would like to ask if I am using it correctly, and is there any sample for reference? my code: ``` #include <OpenImageIO/imagebuf.h> #include <OpenImageIO/imagebufalgo.h> #include <OpenImageIO/Imath.h> #include <OpenImageIO/imagecache.h> #include <OpenImageIO/imageio.h> using namespace OpenImageIO_v2_4; using namespace cv; QString img = ?./0003.png"; ImageBuf buf(img.toStdString()); bool ok = buf.read (0, 0, true, TypeDesc::FLOAT); // true auto Mat1 = cv::Mat {}; bool succ = ImageBufAlgo::to_OpenCV(Mat1, buf); qDebug()<< succ ;// false ``` Functions I found: OpenCV interoperability is performed by the from_OpenCV() and to_OpenCV() functions: ImageBuf OIIO::ImageBufAlgo::from_OpenCV(const cv::Mat &mat, TypeDesc convert = TypeUnknown, ROI roi = {}, int nthreads = 0) Convert an OpenCV cv::Mat into an ImageBuf, copying the pixels (optionally converting to the pixel data type specified by convert, if not UNKNOWN, which means to preserve the original data type if possible). Return true if ok, false if it couldn?t figure out how to make the conversion from Mat to ImageBuf. If OpenImageIO was compiled without OpenCV support, this function will return an empty image with error message set. bool OIIO::ImageBufAlgo::to_OpenCV(cv::Mat &dst, const ImageBuf &src, ROI roi = {}, int nthreads = 0) Construct an OpenCV cv::Mat containing the contents of ImageBuf src, and return true. If it is not possible, or if OpenImageIO was compiled without OpenCV support, then return false. Note that OpenCV only supports up to 4 channels, so >4 channel images will be truncated in the conversion. Looking forward to your reply and thanks very much. Juneleung May 28 2023 | | Juneleung TD juneleungc...@163.com <mailto:juneleungc...@163.com> | -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20230528/c59faa4e/attachment-0001.htm <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20230528/c59faa4e/attachment-0001.htm>> ------------------------------ Message: 2 Date: Sat, 27 May 2023 10:18:04 -0700 From: Larry Gritz <l...@larrygritz.com <mailto:l...@larrygritz.com>> To: OpenImageIO dev list <oiio-dev@lists.openimageio.org <mailto:oiio-dev@lists.openimageio.org>> Subject: Re: [Oiio-dev] Connect with opencv Message-ID: <87a326c6-7528-4661-bb85-c8fc42c55...@larrygritz.com <mailto:87a326c6-7528-4661-bb85-c8fc42c55...@larrygritz.com>> Content-Type: text/plain; charset="utf-8" I assume that the result of buf.read() is true, so you're sure the image was read in the first place? It's only a guess, but it's possible that OpenCV support was not enabled at build time for OpenImageIO. It needs to find the OpenCV headers and library when OpenImageIO itself is built, or else the to_OpenCV and from_OpenCV functions always just return false and don't try to do anything. I see now that there isn't an especially good way of knowing this from the built library. I will add something to make it easier to find out (without being the builder yourself) whether your copy of OIIO has OpenCV support enabled. As an unrelated aside, you should change using namespace OpenImageIO_v2_4; to using namespace OIIO; OIIO is always an alias for the fully versioned namespace. But then you don't need to update your source code for different versions of OpenImageIO. On May 27, 2023, at 10:08 AM, juneleungchan <juneleungc...@163.com <mailto:juneleungc...@163.com>> wrote: Hello, Thanks for your great work of OIIO. I have a question when using OIIO and wanna to ask how to use with details. I'm not sure if I'm writing to this email address is the right channel to ask questions. If not, please point me to it, thanks. My question is about how to convert between OIIO's buf and Opencv. I found related functions (ImageBufAlgo::to_OpenCV and ImageBufAlgo::from_OpenCV) in the manual, but it seems that I always get a false result for these the result of functions . I would like to ask if I am using it correctly, and is there any sample for reference? my code: ``` #include <OpenImageIO/imagebuf.h> #include <OpenImageIO/imagebufalgo.h> #include <OpenImageIO/Imath.h> #include <OpenImageIO/imagecache.h> #include <OpenImageIO/imageio.h> using namespace OpenImageIO_v2_4; using namespace cv; QString img = ?./0003.png"; ImageBuf buf(img.toStdString()); bool ok = buf.read (0, 0, true, TypeDesc::FLOAT); // true auto Mat1 = cv::Mat {}; bool succ = ImageBufAlgo::to_OpenCV(Mat1, buf); qDebug()<< succ ;// false ``` Functions I found: OpenCV interoperability is performed by the from_OpenCV() and to_OpenCV() functions: ImageBuf OIIO::ImageBufAlgo::from_OpenCV(const cv::Mat &mat, TypeDesc <https://openimageio.readthedocs.io/en/latest/imageioapi.html#_CPPv4N4OIIO8TypeDescE <https://openimageio.readthedocs.io/en/latest/imageioapi.html#_CPPv4N4OIIO8TypeDescE>> convert = TypeUnknown, ROI <https://openimageio.readthedocs.io/en/latest/imageioapi.html#_CPPv4N4OIIO3ROIE <https://openimageio.readthedocs.io/en/latest/imageioapi.html#_CPPv4N4OIIO3ROIE>> roi = {}, int nthreads = 0) Convert an OpenCV cv::Mat into an ImageBuf, copying the pixels (optionally converting to the pixel data type specified by convert, if not UNKNOWN, which means to preserve the original data type if possible). Return true if ok, false if it couldn?t figure out how to make the conversion from Mat to ImageBuf. If OpenImageIO was compiled without OpenCV support, this function will return an empty image with error message set. bool OIIO::ImageBufAlgo::to_OpenCV(cv::Mat &dst, const ImageBuf &src, ROI <https://openimageio.readthedocs.io/en/latest/imageioapi.html#_CPPv4N4OIIO3ROIE <https://openimageio.readthedocs.io/en/latest/imageioapi.html#_CPPv4N4OIIO3ROIE>> roi = {}, int nthreads = 0) Construct an OpenCV cv::Mat containing the contents of ImageBuf src, and return true. If it is not possible, or if OpenImageIO was compiled without OpenCV support, then return false. Note that OpenCV only supports up to 4 channels, so >4 channel images will be truncated in the conversion. Looking forward to your reply and thanks very much. Juneleung May 28 2023 Juneleung TD juneleungc...@163.com <mailto:juneleungc...@163.com> <https://dashi.163.com/projects/signature-manager/detail/index.html?ftlId=3&name=Juneleung&uid=juneleungchan%40163.com&iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fwzpmmc%2F3ef565873cb038cd2c89818903cf0fcc.jpg&email=Juneleungchan%40163.com&position=TD&items=%5B%22Juneleungchan%40163.com%22%5D <https://dashi.163.com/projects/signature-manager/detail/index.html?ftlId=3&name=Juneleung&uid=juneleungchan%40163.com&iconUrl=https%3A%2F%2Fmail-online.nosdn.127.net%2Fwzpmmc%2F3ef565873cb038cd2c89818903cf0fcc.jpg&email=Juneleungchan%40163.com&position=TD&items=%5B%22Juneleungchan%40163.com%22%5D>> _______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org> <mailto:Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org>> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>> -- Larry Gritz l...@larrygritz.com <mailto:l...@larrygritz.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20230527/3412d11a/attachment.htm <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20230527/3412d11a/attachment.htm>> ------------------------------ Subject: Digest Footer _______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org> ------------------------------ End of Oiio-dev Digest, Vol 176, Issue 18 ***************************************** _______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org <mailto:Oiio-dev@lists.openimageio.org> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org> -- Larry Gritz l...@larrygritz.com <mailto:l...@larrygritz.com> _______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org -- Larry Gritz l...@larrygritz.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.openimageio.org/pipermail/oiio-dev-openimageio.org/attachments/20230527/9d308113/attachment.htm> ------------------------------ Subject: Digest Footer _______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org ------------------------------ End of Oiio-dev Digest, Vol 176, Issue 21 *****************************************
_______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org