LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error Saving Image in Loop

Hey everyone,

 

So I'm an undergraduate research assistant trying to get a VI to work and spit out an image every time it is looped. The VI I'm working on is supposed to be a part of a sequence that captures a photo of a sample at set intervals. Everything is working fine except for this photo taking part that I have as a subVI.

 

The VI works fine when it is run once, and it saves a file perfectly. However, when it is looped, it seems incapable of spitting out the second file (both when the whole vi is looped and when it is placed in a while loop). I've been tinkering with making it generate new file names for each photo but all amount to nothing, and I just keep getting Error Code 3 when the file save part is disabled, and Error Code 3 and Error 1172 occurred at Invoke Node Error calling method uc480.Image.Save, (System.ArgumentNullException: Key cannot be null.
Parameter name: key) when the file save structure is enabled.

 

I'd appreciate any help I can get.

0 Kudos
Message 1 of 12
(3,108 Views)

Hey badr.jpg,

 

I'd suggest as a starting point that you do the following:

  • Move the initialization code outside of the loop (Set Pixel Format, open references, etc)
  • Move the cleanup code to after the loop (I suspect this is your problem, but we'll see - the Close References should be after the loop)
  • Use Shift Registers to store the references between iterations.
  • Track where your error occurs (connect error wires, use Execution Highlighting or Error probes)
  • Ensure that the references into your nodes are connected when needed (perhaps including the "Image Format" node in the Diagram Disable Structure)

 

I'll dig out my copy of the driver for these cameras if you're not able to solve the problem based on these tips, then I'll be able to read the help information and so on (currently they're all just displaying "The method for this invoke node is not valid for this class"...)


GCentral
Message 2 of 12
(3,099 Views)

Hey,

So I've moved all the cleanup stuff out of the loop. I've tried moving the initialization outside too but that just stopped the loop from initializing each time. There is a subVI thing in the initialization sequence that also throws out an error when looped. I suspect that is the culprit.

 

Thanks for replying so soon.

0 Kudos
Message 3 of 12
(3,086 Views)

I'll just add that when the while loop is removed, and the sequence is run, it works just fine. So I doubt it's a connection issue. Maybe the initialization sequence isn't starting over from scratch like it should and it's reusing values?

0 Kudos
Message 4 of 12
(3,083 Views)

Let me find the driver and get back to you.

I'd expect you want the Save inside the loop though (or else it will only save the last image, not any of the earlier ones, even once it's happy to acquire repeatedly).


GCentral
Message 5 of 12
(3,082 Views)

Alright cool!

 

Also, here's the file with the saving inside the loop. I get Error 1172 occurred at Invoke Node Error calling method uc480.Image.Save, (System.ArgumentNullException: Key cannot be null.
Parameter name: key) when the saving is inside the loop.

0 Kudos
Message 6 of 12
(3,075 Views)

Forgot to upload, oops.

0 Kudos
Message 7 of 12
(3,074 Views)

So let me have a few more guesses and you can point out where I'm going wrong...

  • You've started from something like the "uc480_SimpleLive.vi" example, and wisely chosen to make your own version
  • You picked together the key bits from each of the cases, and it worked nicely without looping
  • When you start looping, it falls apart.

It seems as though (at least from that somewhat peculiarly structured example) that the only bits you're going to want inside the loop are the sections here:

everyIteration.png

Note here that the camera reference is not closed. The "Memory" reference and the "Display" reference are closed.

The "memID" value is the handle of the PictureBox, which is also not closed.

 

I'll need to look through the documentation to get a better idea of why, but that might have to wait for tomorrow! (Perhaps someone else will tell you before then, but I have to sleep!)


GCentral
Message 8 of 12
(3,058 Views)

I can wait! Thats alright. I've also literally just used the uc480_basics VI and added in a little something to save the file it captures, but even the original VI chokes on the same error when looped. I'll upload that here.

 

The only thing I've done to modify this is just remove the loop, which I'm not sure was the wisest idea, but here is the original in case you'd like to take a look at it.

 

Greatly appreciating your help. It's keeping me sane for now.

0 Kudos
Message 9 of 12
(3,053 Views)

Hey,

I hope you're doing well. Did you manage to get anything?

Thanks!

0 Kudos
Message 10 of 12
(2,994 Views)