Skip to content

fix: to_OpenCV fails for ImageCache-backed images #4013

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions src/libOpenImageIO/imagebufalgo_opencv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,12 +343,10 @@ ImageBufAlgo::to_OpenCV(cv::Mat& dst, const ImageBuf& src, ROI roi,

size_t pixelsize = dstSpecFormat.size() * chans;
size_t linestep = pixelsize * roi.width();
bool converted = parallel_convert_image(
chans, roi.width(), roi.height(), 1,
src.pixeladdr(roi.xbegin, roi.ybegin, roi.zbegin, roi.chbegin),
spec.format, spec.pixel_bytes(), spec.scanline_bytes(), 0, dst.ptr(),
dstSpecFormat, pixelsize, linestep, 0, -1, -1, nthreads);

// Make an IB that wraps the OpenCV buffer, then IBA:: copy to it
ImageBuf cvib(ImageSpec(roi.width(), roi.height(), chans, dstSpecFormat),
dst.ptr(), pixelsize, linestep, AutoStride);
bool converted = ImageBufAlgo::copy(cvib, src);
if (!converted) {
OIIO::pvt::errorfmt(
"to_OpenCV() was unable to convert source {} to cv::Mat of {}",
Expand Down