0

I'm currently working on machine vision project. The issue is saving all of the images fast enough so that the queue of images doesn't build up in RAM and drain the user's memory. Is there any other method available for fast image saving?

This method helps the CPU issue, but because its not fast enough. The queue of images builds up and overloads the ram so I don't know what else I can do to solve both issues.

Sam Koay
  • 1
  • 1
  • Your question doesn't seem to be related to WPF. What is ImageSaveInfo and HOperatorSet supposed to be? – Clemens May 07 '19 at 07:41
  • `HOperatorSet` etc seems to be associated with a computer vision library called Halcon. I added a tag for that – mortb May 07 '19 at 07:48
  • How are the images generated / loaded? Maybe the answer is not to generate / load them as fast as is currently done? – mortb May 07 '19 at 07:49
  • But you dont keep the actual image in the queue just the filepath, wo why do you get out of memory´? – Magnus May 07 '19 at 07:51
  • 2
    Also, you could probably farm out the saving by using a [ConcurrentQueue](https://learn.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentqueue-1?view=netcore-2.2), and spawn off multiple async tasks to dequeue and save the images. This should help utilise all your CPU and hopefully max out the hard-drive throughput. – NPras May 07 '19 at 07:52
  • @NPras yes it seems that an async / task design would be nicer. The method in the question obviously sits in a thread and "hammers" the queue to look for new images. – mortb May 07 '19 at 07:56
  • 1
    More like a `BlockingCollection`. – Magnus May 07 '19 at 07:57
  • I am voting to close, the OP has asked and run, and not clarifying any questions – TheGeneral May 07 '19 at 08:29

1 Answers1

1

The fastest way for writing images in Halcon is using their proprietary format .hobj. It is much faster than any other lossless compression:

enter image description here

You can see the benchmark shown above in example write_image_benchmark.hdev

The only disadvantage is that you cannot open this format without the Halcon license.

Vladimir Perković
  • 1,351
  • 3
  • 12
  • 30
  • Is there any other way to speed up the saving process instead of using Halcon library? – Sam Koay May 08 '19 at 01:51
  • I'm not sure I understand, you are already using the Halcon library according to this line: HOperatorSet.WriteImage – Vladimir Perković May 08 '19 at 14:14
  • yeah, the problem here is that it seems to be impractical as it required Halcon license to open the images. – Sam Koay May 09 '19 at 02:22
  • i am looking a way to speed up saving all of the images fast enough so that the queue of images doesn't build up in RAM and drain the user's memory. – Sam Koay May 09 '19 at 02:23
  • How often do you need to save the images and how many? Is it a machine where you have e.g. few seconds of intense image processing and then few seconds of pause? Can you describe the process a bit more? – Vladimir Perković May 09 '19 at 07:30