2

After reading Wikipedia page of Raw image format which is the digital negative of any image.

To be viewed or printed, the output from a camera's image sensor has to be processed, that is, converted to a photographic rendering of the scene, and then stored in a standard raster graphics format such as JPEG. This processing, whether done in-camera or later in a raw-file converter, involves a number of operations, typically including

I have some .raw files grabbed from my Logitech c920 using v4l2 example but when I display the image it looks like this: raw frame file a raw image where in other frames I can see my shadow

Does anyone knows how to process such files to see the complete frame ?

Here is a link to the original .raw file

Ahmed Kato
  • 1,697
  • 4
  • 29
  • 53
  • how did you display it ? raw probably means here, that it's not processed and that there are no 'headers' appended to it. still, it has some format. most sensors use something like yuv. so, if you can find out, what the native format for your camer is, then it's an easy cvtColor() in opencv, to get it to nice rgb or such – berak Feb 22 '13 at 19:17
  • I tried to convert it from yuv to rgb but I failed,this image is displayed as raw. – Ahmed Kato Feb 22 '13 at 20:00
  • There are [many different ways](http://www.fourcc.org/yuv.php) to store and represent YUV data. It just looks like you got the wrong decoding. – slhck Feb 22 '13 at 20:58
  • Right now it is a PNG, so it is irrelevant to the problem. Include a link to the raw file. – mmgp Feb 22 '13 at 20:58
  • Here is a link to the .raw file https://docs.google.com/file/d/0B-IBanqetxwNNzJYMVk0bEk1Nms/edit?usp=sharing – Ahmed Kato Feb 22 '13 at 21:12
  • The image is 640x480, 16 bit big endian. if opened in photoshop using raw open and mac format, you can see an image a man with short hair wearing glasses. My guess is it is YUV data, where the high order byte of the 16 bits is the grayscale image and the low order byte contains color data. To dissect it further, i'd take some image captures of something all red, and a second image of something green and a third of something blue, then open the images in hex and see what the low order bits are doing. All black and all white would also be interesting. – Fred F Feb 22 '13 at 22:29
  • 1
    There are two definitions of a raw format image. The first is a dump of pixels with no formatting applied. The second is a camera specific format containing unfiltered data from a sensor chip. The quote you give applies to second definition, but the first definition is the one that actually applies to your sample. The sensor data has already been processed into pixels and it's just a matter of determining their format. – Mark Ransom Feb 23 '13 at 05:43

1 Answers1

6
ffmpeg -f rawvideo -s 640x480 -pix_fmt yuyv422 -i frame-1.raw frame-1.jpg

The options were set based on the v4l2 code linked, and the resulting image is the one you would expect to get.

mmgp
  • 18,901
  • 3
  • 53
  • 80
  • 1
    +1 for properly decoding the format, but it would be more useful to have code to do it. – Mark Ransom Feb 23 '13 at 05:34
  • See this question for a start: http://stackoverflow.com/questions/7954416/converting-yuv-into-bgr-or-rgb-in-opencv – Mark Ransom Feb 23 '13 at 05:53
  • I think it is working fine but the problem is that its resolution is very low which is not the original resolution. – Ahmed Kato Feb 23 '13 at 13:11
  • @AhmedKato this is a 640x480 image, if you want a higher resolution save it in a higher resolution. The code for decoding it is there, `ffmpeg` is open source. – mmgp Feb 23 '13 at 14:33
  • If I grab a 640x480 frame using ffmpeg it will be 92600kb, using your command is only 32kb. – Ahmed Kato Feb 23 '13 at 20:35
  • You didn't explained why use `rawvideo`? –  Jan 27 '19 at 11:37