Converting NV12 to BGR

I am trying to convert NV12 from a camera to BGR24. I have tried using opencv’s conversion functions but when I do that I just get a lovely solid pink image. I know the NV12 is fine as I save it to /tmp, scp it and use ffplay to view the raw data and the image is fine. But using this code and doing the same with BGR gives me solid pink, as does saving as jpeg. I need BGR for opencv’s image processing.

EDIT: I should add this is on a MIPS32EL SOC with opencv4 built by BUILDROOT

        cv::Mat picNV12 = cv::Mat(height * 3/2, width, CV_8UC1, frame->virAddr);
        cv::Mat picBGR;
        cv::cvtColor(picNV12, picBGR, cv::COLOR_YUV2BGR_NV12);

I guess I could save the NV12 as png and read it back but that is a waste of time.

plain cvtColor might not be able to handle planar formats. browse the docs. there’s a sibling function specifically for planar stuff.