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.

Measurement Studio for .NET Languages

cancel
Showing results for 
Search instead for 
Did you mean: 

confirm camera status

hi all,
i am using NI IEEE1394 camera, and developing an application in vb.net.my question is,is there a way i can check the status of the camera( open or otherwise) or the acquisition status(ongoing acquisition or no acquisition)? the reason i want to do this is coz i dont want to open the camera and start image capturing everytime i call the program.instead,i would like to check whether there is acquistion going on,and if there is,just continue with the next step. i tried to do it using the session id,bt since its of UInt32 type,i cant use any comparison methods on it..i am using the Grab2CW function..
 
thank you!!
0 Kudos
Message 1 of 8
(3,807 Views)

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.Smiley Wink 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.. Smiley Happy

0 Kudos
Message 2 of 8
(3,794 Views)

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

0 Kudos
Message 3 of 8
(3,781 Views)

hi GG,

thank u so much for the help.yup,IMG_ATTR_ACQ_IN_PROGRESS is the function im looking for Smiley Very Happy 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 meSmiley Sad

i am also considering using separate threads for each process..but i havent got to trying it yet

any suggestions will be much appreciated.Smiley Happy

thank you...

0 Kudos
Message 4 of 8
(3,775 Views)

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. 

GG
0 Kudos
Message 5 of 8
(3,766 Views)

hi GG,

thanks for ur reply Smiley Happy 

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.Smiley Happy

0 Kudos
Message 6 of 8
(3,753 Views)
Hi Rebecs,

Are you sure it is that line of code that is giving you the unhandled exceptions?  How often are you getting the exceptions.  Can you put in break points to see if what is causing the exceptions?  If we can narrow down what is causing the problem then that will help.

Regards,
GG
0 Kudos
Message 7 of 8
(3,739 Views)

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 Smiley Very Happy

thanks for all ur help..really appreciate it Smiley Happy

 

rebecca

Smiley Tongue

0 Kudos
Message 8 of 8
(3,726 Views)