OF_IMAGE_GRAYSCALE to openCV

I have a simple question, I want to use an OF_IMAGE_GRAYSCALE image and send it to open CV. I can do this with first going to a ofxCvColorImage, but as the image is already grayscale I would like to skip this step and go from my grayscale image to ofxCvGrayscaleImage.

Maybe the background is helpful, I am using ofxBlackmagic, I get very fast result for tracking if I feed the ofxCvGrayscaleImage with the grayPixels.

grayImage.setFromPixels(vidGrabber.getGrayPixels().getPixels(), camWidth,camHeight);

I am modifying ofxBlackmagic so I have a simple preprocessor declaration if I don’t have the hardware plugged in so I can keep working with my built in webcam. I want to make a function that gets the same gray pixels from the webcam so I have equivalent functions.

Here is the function from the addon

ofPixels& ofxBlackMagic::getGrayPixels() {
if(grayPixOld) {
	grayPix.allocate(width, height, OF_IMAGE_GRAYSCALE);
	unsigned int n = width * height;
	cby0cry1_to_y(&(getYuvRaw()[0]), grayPix.getPixels(), n);
	grayPixOld = false;
}
return grayPix;

}

and here is the function I thought would work (grabber here is ofVideoGrabber)

ofPixels& ofxBlackMagic::getGrayPixels() {
ofImage gray;
gray=grabber.getPixelsRef();
gray.setImageType(OF_IMAGE_GRAYSCALE);
return gray;
}

It would be great to have the gray from the second function work directly with

grayImage.setFromPixels(vidGrabber.getGrayPixels().getPixels(), camWidth,camHeight);

Cheers

Fred