Add V4L2_PIX_FMT_Y16_BE pixel format#18498
Conversation
Add V4L2_PIX_FMT_Y16_BE pixel format swaps byte order then treats as V4L2_PIX_FMT_Y16
change local variable "frame" to "temp2"
alalek
left a comment
There was a problem hiding this comment.
Thank you for contribution!
Please make builds green.
modules/videoio/src/cap_v4l.cpp
Outdated
| }; | ||
| temp2.ForEach(<uint16_t>(Operator()); | ||
|
|
||
| temp2.convertTo(temp, CV_8U, 1.0 / 256); |
There was a problem hiding this comment.
temp2.ForEach
Extraction through cv::split() from CV_8UC2 should perform better.
|
@firebladed Do you have chance to finish the PR? Also it'll be great if you add list of know cameras that are enabled by the patch to the PR description. It becomes merge commit message and is very useful for git history. |
|
@asmorkalov sorry, had issue an get it to work and been busy with other things recently, will try to look at again a soon as i can. |
|
@firebladed Do you have chance to finish the patch? There are changes in GStreamer support that introduces conflicts. |
remove whitespace
|
I have a version that appears to work however i need to do some more tests and i don't know why the OpenCV CN Windows 10 x64 build failed |
Ignore, there builders are optional for now. |
|
Ive tested visually using the MLX90640 on ubuntu on a raspberypi and it appears to give the same output as there appears to be some delay between running python script and getting an image which i cant currently account for Id like to test using a stream that doesn't use the camera but so far i haven't found anything that can produce a raw y16be stream, ffmpeg doesn't appear to convert to y16be, that i can send to the videoloopback For anyone wanting to use the MLX90640 ive also discovered that this method of obtaining video is of limited use, as the MLX90640 image correction requires data embedded in the video stream and implicit scaling to 8bit corrupts this data. have to set fourcc and disable rgb conversion before doing image correction and then convert to desired format |
|
jenkins cn please retry a build |
|
Thanks for the patch! OpenCV runs on Big-Endian platforms too (like PPC), so the patch with bytes swap does not work there. please add endianess check. |
sorry for slow reply im not sure exactly what you mean, im also not familiar with PPC unless im missing something V4L2_PIX_FMT_Y16 and V4L2_PIX_FMT_Y16_BE are the same except that the MSB and LSB are swapped for each pixel so to convert between them i just swap the MSB and LSB, processor endianess is irrelevent what should i be checking for endianess? does not work on big endian platforms? are you saying that i need to use this on big endian platforms? |
|
To check current platform you can copy this function to cap_v4l.cpp: opencv/modules/imgcodecs/src/utils.hpp Lines 136 to 139 in c4226f0 On BE platform we don't need to swap bytes of |
|
According to documentation:
Implementation has been updated for using |
|
Maybe we should also add a new test case to the |
|
I've added this case to the test, it passes for me. |
asmorkalov
left a comment
There was a problem hiding this comment.
👍
Tested manually with Ubuntu 18.04 + vivid driver
| std::string res = fourccToString(fourcc); | ||
| std::replace_if(res.begin(), res.end(), [](uint8_t c){ return c < '0' || c > 'z'; }, '_'); | ||
| // TODO: return hex values for invalid characters | ||
| std::transform(res.begin(), res.end(), res.begin(), [](uint8_t c) { return (c >= '0' && c <= 'z') ? c : (c == ' ' ? '_' : 'x'); }); |
There was a problem hiding this comment.
There is build regression with MSVS2019/2017: https://pullrequest.opencv.org/buildbot/builders/4_x-win64-vc16/builds/100191
Add V4L2_PIX_FMT_Y16_BE pixel format opencv#18498 Address opencv#18495 relates to opencv#23944 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV - [ ] The PR is proposed to proper branch - [x] There is reference to original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake - [ ] Test using Melexis MLX90640
Add V4L2_PIX_FMT_Y16_BE pixel format opencv#18498 Address opencv#18495 relates to opencv#23944 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV - [ ] The PR is proposed to proper branch - [x] There is reference to original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake - [ ] Test using Melexis MLX90640
Add V4L2_PIX_FMT_Y16_BE pixel format
#18495
swaps byte order then treats as V4L2_PIX_FMT_Y16
relates to #23944
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.