$ brew info openimageio
==> openimageio: stable 2.4.11.1 (bottled), HEAD
Library for reading, processing and writing images
https://openimageio.org/
Not installed
From: 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 ✔, [email protected] ✔, 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 <[email protected]> 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
> [email protected]
>  
> <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  <[email protected]> 
> <mailto:[email protected]>
> Date  05/28/2023 01:18
> To    <[email protected]> <mailto:[email protected]>
> Subject       Oiio-dev Digest, Vol 176, Issue 18
> Send Oiio-dev mailing list submissions to
> [email protected] <mailto:[email protected]>
> 
> 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
> [email protected] 
> <mailto:[email protected]>
> 
> You can reach the person managing the list at
> [email protected] 
> <mailto:[email protected]>
> 
> 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 <[email protected] <mailto:[email protected]>>
> To: "[email protected] <mailto:[email protected]>" 
> <[email protected] <mailto:[email protected]>>
> Subject: [Oiio-dev] Connect with opencv
> Message-ID: <[email protected] 
> <mailto:[email protected]>>
> 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
> [email protected] <mailto:[email protected]>
> |
> 
> -------------- 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 <[email protected] <mailto:[email protected]>>
> To: OpenImageIO dev list <[email protected] 
> <mailto:[email protected]>>
> Subject: Re: [Oiio-dev] Connect with opencv
> Message-ID: <[email protected] 
> <mailto:[email protected]>>
> 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 <[email protected] 
> <mailto:[email protected]>> 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
> [email protected] <mailto:[email protected]>
> <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
> [email protected] <mailto:[email protected]> 
> <mailto:[email protected] 
> <mailto:[email protected]>>
> 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
> [email protected] <mailto:[email protected]>
> 
> 
> 
> 
> 
> -------------- 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
> [email protected] <mailto:[email protected]>
> 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
> [email protected] <mailto:[email protected]>
> http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org 
> <http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org>
--
Larry Gritz
[email protected]





_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to