09-10-2016 04:25 AM
Hi,
I spent hours trying to find a solution for this on the internet for what I think must be really straight forward:
I have a camera which gives me a stream of images, which I show in an image graph.
Now when the user presses a "save" button, I want that the image which was shown at the moment when the user was hitting "save" is saved. However, the user is prompted for a file location and name, so some time passes between hitting "save" and writing the image to the disk.
In that time, new images will be at the pointer position of the image I wanted to save.
It is clear to me why this happens, but how do I get around it?
I tried to make a copy with Imaq copy, but this will just give me a new pointer which is still linked to the old one.
I tried converting to an array, same effect.
I also tried writing a queue with one element which has one image buffer. The queue was not in a loop (which would of course replace the image there) but still, the queue also just seemed to save the pointer position, although I was creating in advance a new empty image, and copied the image I want with Imaq Copy in this image buffer.
So how do I store the actual image (not pointer) in the memory to save it a few seconds later?
I basically want something similar to what the "snapshot" function of the image graph does.
Any ideas?
Many thanks!
Philipp
Solved! Go to Solution.
09-10-2016 04:51 AM
Please post the VI so that it is easier to debug.
Few pointers:
-Try to use Producer/Consumer design pattern
-So you want the pop-up to be shown or not? If not try creating the path constant and build path for each image so that program automatically saves without user interaction to save image.
09-10-2016 05:04 AM - edited 09-10-2016 05:05 AM
Sorry, thought it is very clear from the description, I can't upload an image right now, but will do it later tonight.
Thanks for your tips!
Yes, I do want the pop-up to be shown so that the user can decide for the filename each time.
I tried using a producer, consumer pattern, however, it was still overwriting the image. Of course, I could make a buffer with 1000 images an then the camera wouldn't be fast enough to fill it during the process, but this sounds very inefficient to me.
Because I really only need one image at a time.
09-10-2016 05:34 AM
How fast are you acquiring images?
-You need to have enough buffers until the user finishes writing the file name without overwriting.And it can be sometimes slow sometimes fast which is uncertain.
-I think it is easier to give predefined path for images programatically to avoid these kind of overwriting.
-When you enqueue the image in only reference to the image is passed and still Producer loop has capability to overwrite the image.
-Instead make copy of the image at that instant with new buffer(Inside Producer create case to and then pass to consumer loop via queue.
-So untill you press the snapshot button, the image will not be overwritten and gives sufficient time to save the image and give name in consumer loop.
-Attached quick draft what i am explaining
09-10-2016 06:52 AM - edited 09-10-2016 06:54 AM
Hi,
many many thanks.
I did consider your solution already, however, I thought this is a bit of an overkill.
For some reason I do not know, it now works as I wanted. See the example below (I really just wanted always one image).
The only difference to what I was trying earlier, is that now I did not specify the data type and size of the new image...not sure if this was the reason it did not work.
Thank you uday for your help!
Philipp
PS: How did you make the image you posted visible in your post? Mine is just a link.
09-10-2016 07:12 AM
-Definitely your code will fail at some because of "race condition" with local variables (Please search in forum you will get lot of resources)
-Hence the same reason it can work sometimes and cannot sometimes.
I did consider your solution already, however, I thought this is a bit of an overkill.
-Care to explain why it is overkill?
For some reason I do not know, it now works as I wanted. See the example below (I really just wanted always one image).
-As said earlier if you want to separate the acquisition process and saving independently(Paralelly) you need atleast two buffers to avoid overwriting.
The only difference to what I was trying earlier, is that now I did not specify the data type and size of the new image...not sure if this was the reason it did not work.
Without seeing the original post cannot comment.
PS: How did you make the image you posted visible in your post? Mine is just a link.
When you click on Insert/edit image Click on Insert image it will be added.
P.S.The only way to thank is by giving kudos and marking correct post as solution.