danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
647 stars 225 forks source link

How to iterate over channel data? #255

Closed leshravnya closed 4 years ago

leshravnya commented 5 years ago

I was trying to read data from a MF4 file. But I could not find an implementation to read the data as an iterator. I found a similar implementation in MDF3. Is this planned to be implemented for MDF4? In the mean while, is there a workaround that I can use to iterate through the data from the MF4 file ❓

danielhrisca commented 5 years ago

Hello @leshravnya ,

you should not use the MDF3 and MDF4 classes. Instead use MDF, you can then access the https://asammdf.readthedocs.io/en/master/api.html#asammdf.mdf.MDF.iter_channels and https://asammdf.readthedocs.io/en/master/api.html#asammdf.mdf.MDF.iter_get methods

leshravnya commented 5 years ago

Hello @danielhrisca,

Thank you, the above solution works for iterating over data samples. But I have another issue with the way it returns the data. The channel that I am trying to iterate over is a video stream and each sample is an image. But when I use iter_get on this channel each sample is returned as a numpy.arrary. Is there any method which can return the data as bytes ❓ My requirement is to extract the images from each sample into a jpeg file and then stitch it to make an avi.

Should I create another issue for returning data in bytes in case it is not yet implemented?

danielhrisca commented 5 years ago

You may take some inspiration from this commented snippet https://github.com/danielhrisca/asammdf/blob/development/asammdf/mdf.py#L817

The complete video stream is fond in the attachment attribute of the returned Signal object.

mounir324 commented 4 years ago

Hello @leshravnya I have the same problem like you I want to know please what did you do to handle the problem (I am biginner in Python :/). Actually, I want to extract the images from each sample into a jpeg file and then stitch it to make an avi. The channel each sample is returned as a numpy.arrary as in you case! and I have found that the Raw data is coded in RAW12!!! Thank you in advance for your help,