Hi Randall,
Ø
So I was expecting that there was some way to just grab the jpeg out of NDPluginCodec as an array of bytes without any conversion going on.
Ø
I presume the jpeg image exists somewhere within the plugin as a block of bytes. NDFileJpeg(?) appears to be able to write the bytes of a jpeg out to a file which is pretty much what we want though we want it from a network connection
read rather than directed to a file.
Ø
How does a “compressed array” differ from just an array which happens to have a set of bytes that have been compressed?
That depends on the compression scheme. I believe JPEG compressed images themselves contain information about the data type, image dimensions and the color scheme (mono, RGB). But other compression schemes (Blosc, LZ4, BSLZ4) are just
a stream of bytes, and additional metadata is required to know how to interpret the data (data type, image dimensions, mono/RGB), etc.
When using Channel Access that additional metadata is in the form of additional EPICS PVs. When using pvAccess that metadata is contained in the NTNDArray object which is transmitted atomically over the wire.
Ø
I presume knowing that the array data is compressed, how it’s compressed, etc is important if I want to pass it to another module that wants to work on it as an image.
Ø
But here we don’t want to pass it on except to a client that knows what it is and how to deal with it. We just want the bytes.
With Channel Access the waveform record will contain just the JPEG bytes, as will the “value” member of the NTNDArray structure.
I will work on making NDPluginStdArrays able to work with compressed arrays.
Mark
-----Original Message-----
From: Randall Cayford <[email protected]>
Sent: Friday, January 24, 2020 12:40 PM
To: Mark Rivers <[email protected]>
Cc: Wang Xiaoqiang <[email protected]>; [email protected]
Subject: Re: Getting images from area detector plugins
Thanks for the discussion! We will look into moving to PVA. However, I now have a bunch of questions (I’m a new EPICS user)!
Our clients (several) have been using ca_get_array to get an array and we can convert it on our end to whatever we want. Our non-EPICs cameras, which we are moving away from in favor of something more standard, have an internal server
which produces JPEGs. These are just read as a byte stream over a socket and that’s what we are trying to duplicate. We either display them, both QT and IOS can deal with JPEGs directly, or we convert them to a 2D image for image analysis.
So I was expecting that there was some way to just grab the jpeg out of NDPluginCodec as an array of bytes without any conversion going on. I presume the jpeg image exists somewhere within the plugin as a block of bytes. NDFileJpeg(?)
appears to be able to write the bytes of a jpeg out to a file which is pretty much what we want though we want it from a network connection read rather than directed to a file.
How does a “compressed array” differ from just an array which happens to have a set of bytes that have been compressed? I presume knowing that the array data is compressed, how it’s compressed, etc is important if I want to pass it
to another module that wants to work on it as an image. But here we don’t want to pass it on except to a client that knows what it is and how to deal with it. We just want the bytes.
Randall
> On Jan 24, 2020, at 4:23 AM, Mark Rivers via Tech-talk <[email protected]> wrote:
>
> Hi Xiaoqiang,
>
>
> Thanks for the comment.
>
>
>> Actually it is not a limit of channel access to support passing compressed NDArrays.
>
>
> Yes, I realized after my post yesterday that compressed arrays could possibly be passed over Channel Access as well, and once we hear more about Randall's client I was going to suggest this might be an alternative.
>
>
> However, currently NDPluginStdArrays cannot be used for compressed NDArrays because it does not pass the flag compressionAware=true when its constructor calls the NDPluginDriver constructor. This means that NDPluginStdArrays will
return an error if it receives a compressed array and will not send it over Channel Access. This would be easy to change.
>
>
>> The client will look at the $(P)$(R)Codec_RBV record to handle it accordingly.
>
> It will also need to look at the $(P)$(R)CompressedSize_RBV to determine how many bytes to read.
>
> I think it will probably also only work if the data type of the NDArray matches the data type of the waveform record. If not then NDPluginStdArrays will convert the data to the type of the waveform record, which will corrupt the compressed
data.
>
> Mark
>
>
>
> ________________________________
> From: Wang Xiaoqiang <[email protected]>
> Sent: Friday, January 24, 2020 1:33 AM
> To: Mark Rivers
> Cc: [email protected]
> Subject: Re: Getting images from area detector plugins
>
>
> Hi Mark,
>
> Sorry to intercept this thread.
>
> Actually it is not a limit of channel access to support passing compressed NDArrays.
>
> The NDPluginStdArrays could just copy the compressed bytes to output.
> The client will look at the $(P)$(R)Codec_RBV record to handle it accordingly.
>
> I have experimented this idea before the introduction of NDCodec
> plugin. I image this has only got easier.
>
> Best
> Xiaoqiang
>
>
> On 1/24/20 12:44 AM, Mark Rivers via Tech-talk wrote:
>> Hi Randall,
>>
>> You can't pass the JPEG image over EPICS Channel Access, but you can pass it over pvAccess. The NTNDArray that your pvAccess client receives will be the JPEG compressed image.
>>
>> What type of client are you running, and how will you display it?
>>
>> There are examples of receiving JPEG compressed NTNDArrays in the
>> ImageJ EPICS_NTNDA_Viewer.java in ADViewers
>>
>>
https://github.com/areaDetector/ADViewers/tree/master/ImageJ/EPICS_ar
>> eaDetector
>>
>> and in a new Python viewer that Marty Kraimer is writing:
>>
>>
https://github.com/mrkraimer/PY_NTNDA_Viewer
>>
>> These viewers first decompress the JPEG images before displaying them.
>>
>> Mark
>>
>>
>> -----Original Message-----
>> From: Tech-talk <[email protected]> On Behalf Of Randall
>> Cayford via Tech-talk
>> Sent: Thursday, January 23, 2020 5:29 PM
>> To: [email protected]
>> Subject: Getting images from area detector plugins
>>
>> We're trying to connect to a gige camera with areadetector (using ADaravis). We would like to access the camera images via a pv that returns a jpeg of the image rather than an uncompressed byte stream.
>>
>> We've got the camera connected, we've got an NDPluginCodec setup that takes the images and apparently is producing compressed jpeg images. We can enable acquisition and watch the MEDM screen show frames arriving and degree of compression,
etc.
>>
>> Our problem is: how do we access those images? There doesn't seem to be any PV that returns the jpeg. Perhaps we're supposed to pass the output of the codec to something else but we can't seem to find anything that tells us how
to do that.
>>
>> Help would be appreciated.
>>
>> Randall Cayford
>> ALS at Lawerence Berkeley Lab
>>