Capability to get YUV image from VideoCapture object (Feature #1445)
Description
The VideoCapture::Retrieve method populates a Matrix with an image capture by a camera. Currently, this method only supports retrieving the image in BGR, RGB, and GRAY formats. It is proposed to add the YUV format to this list.
The reasoning for this is:
In Android devices, the image captured by the camera is in YUV format. In order to get these other formats, a conversion must be performed performed. This conversion is unavoidable in nearly all cases because YUV isn't a particularly useful format, but there is one case in which it is not desired.
Should the user require both a GRAY and RGBA format image of the same frame, the only option is to capture the RGBA format image and convert it to GRAY. However, the RGBA->GRAY conversion is much slower than the YUV->GRAY conversion. If the user had the option to capture the YUV, then they could do the YUV->RGBA, and YUV->GRAY conversions directly. The performance enhancement would be on the order of 10 milliseconds. This may seem small, but in an application running at 30 FPS, this a significant portion of the time available for each frame.
Associated revisions
Merge pull request #1445 from vpisarev:stereocalib_quick_fix
History
Updated by Andrey Kamaev about 13 years ago
Actually OpenCV supports YUV888 format but Android camera returns frames in YUV420 (or possibly in YUV422) format. So it is not fit into the OpenCV image format and is not returned by the VideoCapture
methods.
By the way VideoCapture
is implemented to allow retrieve each frame several times in different output formats. Moreover converting from YUV420 to grayscale can be done (and is done) at zero cost! As result you can get both Gray and RGBA formats at the cost of getting RGBA only.
You can find examples of getting both Gray and RGBA frames from VideoCapture
in Android samples coming with OpenCV.
- Status changed from Open to Done
- (deleted custom field) set to wontfix
Updated by Andrey Kamaev about 13 years ago
- Status changed from Done to Cancelled
Updated by Andrey Kamaev almost 13 years ago
- Target version set to 2.4.0