ossimlabs / ossim

Core OSSIM (Open Source Software Image Map) package including C++ code for OSSIM library, command-line applications, tests, and build system
MIT License
296 stars 142 forks source link

Example usage of ossimMemoryImageSource #224

Closed ghansham closed 5 years ago

ghansham commented 5 years ago

Hi

I have a general raster data along with its metadata (width, height, number of bands, nullpix value and data type) as a C buffer and I want to use this data in the image chain without dumping onto the disk and going via ossimGeneralRasterTileSource route. Seems like ossimMemoryImageSource can help in this case. Kindly guide. Can illustrate an example of how to populate ossimMemoryImageSource from the afore-mentioned C buffer.

Ghansham and Tushar

omarossim commented 5 years ago

Hello:

If you want to see a quick example, I used it in our 3-D viewer in the ossim-planet repo: ossimplanet-chip.cpp file. Here is a cut an paste of just that part of the code:

     ossimRefPtr<ossimImageData> imageData = new ossimImageData(0,OSSIM_UINT8, 4, image->s(), image->t());
     imageData->initialize();

     imageData->loadTile(image->data(), ossimIrect(0,0,image->s()-1, image->t()-1), OSSIM_BIP);
     imageData->validate();
     ossimRefPtr<ossimMemoryImageSource> memSource = new ossimMemoryImageSource();
     memSource->setImage(imageData.get());
     ossimRefPtr<ossimJpegWriter> jpegWriter = new ossimJpegWriter();
     jpegWriter->connectMyInputTo(0, memSource.get());
     jpegWriter->setFilename(ossimFilename("/tmp/output.jpg"));
     jpegWriter->execute();

Take care

Garrett

On May 28, 2019, at 6:32 AM, ghansham notifications@github.com wrote:

Hi

I have a general raster data along with its metadata (width, height, number of bands, nullpix value and data type) as a C buffer and I want to use this data in the image chain without dumping onto the disk and going via ossimGeneralRasterTileSource route. Seems like ossimMemoryImageSource can help in this case. Kindly guide. Can illustrate an example of how to populate ossimMemoryImageSource from the afore-mentioned C buffer.

Ghansham and Tushar

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/ossimlabs/ossim/issues/224?email_source=notifications&email_token=ABVG7STUYF5WG2ENKZLMDM3PXUC25A5CNFSM4HQCAHCKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4GWGD53Q, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVG7ST46A42LW5NZQQ2BWLPXUC25ANCNFSM4HQCAHCA.

ghansham commented 5 years ago

Thanks a lot. I am sure it will work for me. Meanwhile I have got some success in using concept of multi threaded programming for improving the reprojection of input image data to a given output projection. I am getting a speed up of 10 times when using 16 threads. I hope that may be useful to community. It is a proof of concept. Right now output is in memory. So wanted to use memoryImageSource.

Regards Ghansham

omarossim commented 5 years ago

Hello Ghansham:

Sounds very cool! Let me know

Take care

Garrett

On May 29, 2019, at 10:48 AM, ghansham <notifications@github.com mailto:notifications@github.com> wrote:

Thanks a lot. I am sure it will work for me. Meanwhile I have got some success in using concept of multi threaded programming for improving the reprojection of input image data to a given output projection. I am getting a speed up of 10 times when using 16 threads. I hope that may be useful to community. It is a proof of concept. Right now output is in memory. So wanted to use memoryImageSource.

Regards Ghansham

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ossimlabs/ossim/issues/224?email_source=notifications&email_token=ABVG7SV27CAWJ7RAFY7A223PX2JTJA5CNFSM4HQCAHCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWPSNOQ#issuecomment-496969402, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVG7SSETXCEYRRQFF2C55DPX2JTJANCNFSM4HQCAHCA.

omarossim commented 5 years ago

Hello Ghansham:

Sounds very cool!

Thank you and take care

Garrett

On May 29, 2019, at 10:48 AM, ghansham <notifications@github.com mailto:notifications@github.com> wrote:

Thanks a lot. I am sure it will work for me. Meanwhile I have got some success in using concept of multi threaded programming for improving the reprojection of input image data to a given output projection. I am getting a speed up of 10 times when using 16 threads. I hope that may be useful to community. It is a proof of concept. Right now output is in memory. So wanted to use memoryImageSource.

Regards Ghansham

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ossimlabs/ossim/issues/224?email_source=notifications&email_token=ABVG7SV27CAWJ7RAFY7A223PX2JTJA5CNFSM4HQCAHCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWPSNOQ#issuecomment-496969402, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVG7SSETXCEYRRQFF2C55DPX2JTJANCNFSM4HQCAHCA.

ghansham commented 5 years ago

I am not conversant with github. But can share the code making a tar ball out of it. Let me know how to share. May be by email.

ghansham commented 5 years ago

Hi there..

The ossimImageData class returns all getSize*() functions ossim_uint32. For files> 4GB, it limits the buffers allocation. Do we have a better class to handle it.

regards Ghansham

ghansham commented 5 years ago

Right now file size I am trying is 5.7GB.

regards Ghansham

ghansham commented 5 years ago

Solution could be to make the getSize*() functions return type as ossim_uint64. But I dont know how much repercussions it will have on the overall library. I mean how many changes it will call for. Or we can make a imageData specialized class for large files.

omarossim commented 5 years ago

Hello:

Try the dev branch now . I made several calls all have ossim_uint64 and ossim_int64 where appropriate

Take care

Garrett

On May 30, 2019, at 3:53 AM, ghansham <notifications@github.com mailto:notifications@github.com> wrote:

Solution could be to make the getSize*() functions return type as ossim_uint64. But I dont know how much repercussions it will have on the overall library. I mean how many changes it will call for. Or we can make a imageData specialized class for large files.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ossimlabs/ossim/issues/224?email_source=notifications&email_token=ABVG7SRC2JCAP7SFZPQR4U3PX6BW5A5CNFSM4HQCAHCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWRUU4I#issuecomment-497240689, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVG7STQE4L7LV2KGZG4NODPX6BW5ANCNFSM4HQCAHCA.

ghansham commented 5 years ago

Thanks a lot Sir. Can you share your email id. I wanted to share the improved code. My id is ghanshamsangar@gmail.com

ghansham commented 5 years ago

Just out of curosity. Will the child classes of ossimImageData be effected by 64 bit offset changes?

ghansham commented 5 years ago

Thanks Sir. This is working..

omarossim commented 5 years ago

Hello:

Good deal! Glad it is working

On Jun 6, 2019, at 4:28 AM, ghansham notifications@github.com wrote:

Thanks Sir. This is working..

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ossimlabs/ossim/issues/224?email_source=notifications&email_token=ABVG7SVJVOXP233B224JDK3PZDDB7A5CNFSM4HQCAHCKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXCDZVQ#issuecomment-499399894, or mute the thread https://github.com/notifications/unsubscribe-auth/ABVG7SX3X3F2ERAKSZEFNBTPZDDB7ANCNFSM4HQCAHCA.