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 |
_______________________________________________ Oiio-dev mailing list Oiio-dev@lists.openimageio.org http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org