From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
06-10-2007 10:41 PM
06-11-2007 09:37 PM
hi all,
well,i found a way around it..i just used a boolean variable(isOpen) and set it to true when there is acquisition going on,and false when there isnt.maybe its not the most efficient way,but it works. but if anyone has a better suggestion, i would love to try it out..
there is another issue that i have been trying to solve:lets say the camera is already open,so if another process needs to access the image,how do i go about it?my application is a vb class library,and i am trying to call it from different multiple consoles.so the flow would be something like this:
if isOpen ==true
'perform image processing using current image
else
'start acquisition
endif
bt the problem now is,im not sure hw other processes can access the image.currently wat im doing is each time a process calls the application, i start image acquisition,then perform processing,and release the camera once the process is complete.
thank you..
06-12-2007 01:16 PM
Hi rebecs,
That is great that you found a good work around. There is something that may help you with the second question that you asked. There is an IMAQ function called IMG_ATTR_ACQ_IN_PROGRESS. It will return a true if the acquisition is in progress. I think this is the function you are looking for. I hope this helps. If I misunderstood the question, let me know.
Regards,
GG
06-12-2007 09:13 PM
hi GG,
thank u so much for the help.yup,IMG_ATTR_ACQ_IN_PROGRESS is the function im looking for i think i can use it instead of the isOpen variable as well. but wat is baffling me is how do i allow separate processes to access the current image?for instance.if i call this library from different consoles at the same time, only one of it will be able to access the image,the other will get the "camera already in use error". i have to call the library again from this console.so what im currently implementing is:
process one:
open camera
start acquisition
get image from buffer
perform processing
dispose CWIMAQ control
return result to calling process
*i dont close the acquisition or the camera after this, so does that mean acquisition continues even after the result is returned to the calling process?
process two:
if acquisition in progress
return "camera already in use" message
else
start acquisition(again..)
get image from buffer
perform processing
dispose CWIMAQ control
return result to calling process
endif
but wat i want to implement is:
process one:
start acquisition
perform processing
return result
all subsequent processes:
if acquisition in progress
get current image from buffer
perform processing
return result
else
start acquisition again
perform processing
return result
endif
the reason i want continuous acquisition is, all that camera open and restarting acquisition seems a bit inefficient.if i can have an ongoing acquisition,then i can just grab the latest image from the buffer and go on with the processing.maybe there is a obvious way to do it.but with my limited programming experience,its eluding me
i am also considering using separate threads for each process..but i havent got to trying it yet
any suggestions will be much appreciated.
thank you...
06-14-2007 08:02 AM
Hi Rebecs,
You are right that continuously opening and closing the IMAQ session in not very efficient. The best way to do this is to do all initialization before you beginning the loop. Inside your loop you can do a grab with all of your image processing. If you are doing a lot of processing and it is slowing your acquisition down then running different threads as you suggested would be the best way to do this. Once the while loop is completed then you can close your camera session. I hope this helps.
GG06-15-2007 02:33 AM
hi GG,
thanks for ur reply
i think i am almost done here:smileytongue: well,wat i did was modify my application a bit..i start start the acquisition once, and dont close the session or dispose any control til the end. so for all subsequent processing fucntions which requires the image, i inserted this into the function:
CWIMAQ1394.GetImageCW(sid, -2, BufferNumber, CWIMAQ1394.OverwritePolicy.IMG1394_ONOVERWRITE_GET_NEWEST, myImage)
that seems to have done the trick..for now anyway..but sometimes,i still get those unhandled exceptions..and i cant seem to pinpoint wat exactly triggers it,it just pops out once in a while.
if there are any suggestions to improve or enhance this,i would love to hear them. thank you.
06-18-2007 08:58 AM
06-18-2007 08:56 PM
hi GG,
thanks for ur reply..
as it turns out, it was not that code that was causing that exception.when i step thru my code, i realised that whenever my scores variable( score of the matching function) is not set,it throws an exception. backtracking from that, i found that the learn and match functions were not called,coz i disposed the CWIMAQ control too soon..oopps..
so instead of inserting the dispose code right after the color processing,i grouped all the closing codes( dispose control, stop acquisition,close camera) into one function,and called it just before the library returns to the calling program.that seems to have solved it..i havent encountered any exception so far
thanks for all ur help..really appreciate it
rebecca