Converting OpenCV Mat to Julia images

Julia images are different from Open CV images, and that is because Open CV is run by C++ in the backend. Therefore, we need a way to convert an image prepared in Open CV Mat to Julia format.

The OpenCV.jl package does not have any functions to accomplish the task, and therefore I have created one. It is not the fastest function ever, but it can work well when run multiple times:

using Imagesusing OpenCVusing Cxxfunction opencv_to_image(img_opencv)converted_image = zeros(Float16, (3, rows(img_opencv), cols(img_opencv)));    for i = 1:size(converted_image, 2)        for j = 1:size(converted_image, 3)            pixel_value = @cxx at_v3b(img_opencv, i, j)            converted_image[:, i, j] = map(x -> Float16(at(pixel_value, x)), [2, ...

Get Hands-On Computer Vision with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.