LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Sequence

hi everybody,
i'm trying to get a sequence of images with the vision functions.
with imaqEasyAcquire() everthing works fine and i get one camera image.
but with:
imaqSetupSequence (sid, images, nbOfImages, skipCount, IMAQ_NO_RECT);
imaqStartAcquisition (sid);
i get only black picture when i try to save one image of the sequence to a .png
my second idea was to check the status of acquisition before saving my image - that produced an endless loop...

best regards,
malte



#define _NIWIN
#include "niimaq.h"
#include "stdafx.h"
#include <windows.h>
#include "nimachinevision.h"
#include <iostream>
#include "nivision.h"

using namespace std;

static Image* myImage=NULL;
static INTERFACE_ID iid;
static SESSION_ID sid;
static Image** images = NULL;
static int imageArraySize = 0;
static Image *resultImage = NULL;

int main(int argc, char* argv[])
{

   const char*        fileName="test.png";
   unsigned long    nbOfImages;
   unsigned long    skipCount;
   int                       i;
   PixelValue         divisor;

   
   nbOfImages=10;
   skipCount=0;

   imgInterfaceOpen ("img0", &iid);
   imgSessionOpen (iid, &sid);
   myImage = imaqCreateImage (IMAQ_IMAGE_I16, 0);
   resultImage = imaqCreateImage (IMAQ_IMAGE_I16, 0);

   
   images = (Image **) malloc(nbOfImages * sizeof(Image *));
   for(i=0; i<nbOfImages; i++) {images[i] = imaqCreateImage (IMAQ_IMAGE_I16, 0);}
   imageArraySize = nbOfImages;

   imaqSetupSequence (sid, images, nbOfImages, skipCount, IMAQ_NO_RECT);
   imaqStartAcquisition (sid);
   
   //imgSessionStatus (sid, &acqInProgress, &bufNum); /* here is the mentioned check of acquisition status */
  // while(acqInProgress){cout<<acqInProgress<<endl;}   
   

   imaqWritePNGFile(myImage, fileName, 750, NULL);
 
   if(images)
            {
                for(i=0; i<imageArraySize; i++)
                    imaqDispose (images[i]);
                
                free(images);
            }
   // Close the interface and the session
   if(resultImage) imaqDispose (resultImage);
   if(myImage) imaqDispose (myImage);

   
   imgClose (sid, TRUE);
   imgClose (iid, TRUE);
   
   return 0;

}
0 Kudos
Message 1 of 4
(3,415 Views)
Hello,

I am not familiar with the imaq API, but right away I see two problems that would explain your black image and your infinite loop.

First, you are passing myImage in the call to imaqWritePNGFile, but it seems your aquired images are actually in the images array. Try passing images[0] instead and see if you get a reasonable .png.

Secondly, you need to push your call to
imgSessionStatus into your loop. Right now, you call it once, and loop forever because you never update acqInProgress.  Try this:

do
{

    imgSessionStatus (sid, &acqInProgress, &bufNum);

    cout<<acqInProgress<<endl;

}
while(acqInProgress);

Hope this fixes your problem.

Mert A.
National Instruments
0 Kudos
Message 2 of 4
(3,399 Views)
hi, thank you for your answer...i fixed the mistake with the parameter of imaqWritePNGFile2()

do
 {
     imgSessionStatus (sid, &acqInProgress, &bufNum);
 }
while(acqInProgress);
imaqWritePNGFile2(images[1], fileName, 750, NULL, FALSE);

now i'm passing an image from the original array, but i still get the same black png-file...

best regards,
malte
0 Kudos
Message 3 of 4
(3,386 Views)
ok, i found the problem...
i opened the resulting .png with gimp and ms paint instead of using this damn ms photo editor --> now everthing is fine Smiley Very Happy
again, thank you for your reply,
malte
0 Kudos
Message 4 of 4
(3,381 Views)