04-29-2016 05:04 AM
Following a previous question I made here, I found out that I'm able to install and use IMAQ.
So I can try to do what I need, that is to save a grayscale 12bit image with IMAQ.
I read somewhere here that the nearer I can go is to save it as 16bit - I hope it wont create problems in the final image...
anyway, this is how far I was able to go - trying to understand how IMAQ works:
(sorry for the confusion - the lower left part deals with it without imaq, the relevant part is to the right)
running this, I get an "error -1074396154 occurred at IMAQ WritePNGFile - possible reason(s): IMAQ Vision: the image is not large enough for the operation"
- yet just for that reason I inserted an IMAQ SetImageSize!
any hint?
thanks for any help...
alessandro
Solved! Go to Solution.
04-29-2016 07:59 AM
I don't have imaq/vas/vdm installed anymore, so I'm going from memory here but
1) you're going to run into a lot of trouble with memory. you are creating a new image each loop iteration and never deleting it. At the very least put a destroy image after the imaq functions. The way I've always done things is to create the image once and then just re-use it before destroying it once at the end.
2) I think your issue may be the fact that you need to explicity set the image type to grayscale 16 on the imaq create functions, but I'm not positive
This article references
http://digital.ni.com/public.nsf/allkb/B51CCE62D00112B68625735C0000DDCF
these
http://www.ni.com/example/28120/en/
examples which might help you out more
04-29-2016 08:18 AM
Please do not attach pictures of your VIs, but attach the (entire) VI, itself. What you want to do is very simple, but I can't see the "camera" functions in your code, so can't see if you are doing it right or not.
Some IMAQ concepts:
Bob Schor
04-29-2016 08:33 AM
thank you for your answer Bob...
I'm sorry the image bothers you - since the VI I'm working on is large, I thought it a good idea to attach the whole VI, and to include the screenshot of the problematic part. If I dont do it this way, how can I expect people to find the problem I'm having?
The image data arrives to "IMAQ ArrayToImage" from the ReshapeArray box, which produces the 2D array of pixels (and those I probed, the image is there all right).
I certainly intend to move the CreateIMAQ outside the loop as OEM_Dev suggested (thank you!), but I dont think that's the problem, since the error pops up immediately, it's not out of memory related...
Instead the prblem could be as you suggested that I didnt identify the Image Type. And damn, I knew it was probably that, because I saw it done this way in some VI, but I cannot find a way to specify it!
04-29-2016 08:55 AM
... nope, it didnt work:
(the modified VI is again attached)
- I set the create IMAQ image outside the loop
- I intentionally created it bigger: it should be 1392x1040 - but I read about borders needed by IMAQ - so I put it at 1400x1400
- I set the type to 7 (grayscale unsigned )
... same error as before!
04-29-2016 09:20 AM
Look at the help for array to image
"Image Pixels (U16) is a 2D array of unsigned 16-bit integers containing the pixel values that comprise the image. The first index corresponds to the vertical axis and the second index corresponds to the horizontal axis. The VI resizesImage to be the same size as Image Pixels. Use this input only when Image is an unsigned 16-bit image."
I've never needed to resize to save personally. Looking at it further, I'm wonder if you are getting errors you aren't seeing further up. Try connecting all the imaq functions with error wires and see what happens.
05-02-2016 04:19 AM
sorry for my mistake - my last attempt did indeed succeed, but Labview for some reason kept giving me the old error...
I needed to arrive this morning and do a fresh restart of everything to notice that the error is gone, and the images are saved!
So I'd say that what saved the day was correctly set the image type (7 for grayscale U16) - not even the resize was necessary!
The images are good grayscale 16 bit instead of 12, but it doesnt matter.
thank you all...
alessandro