Page 1 of 6 1 2 3 ... LastLast
Results 1 to 15 of 77

Thread: trigger problem

  1. #1
    Join Date
    Apr 2013
    Posts
    43

    trigger problem

    hi,
    already, sorry if my english is hard to understand (i'm french)


    I program in C and I want to use the features of trigger but I fail to understand how it works
    Can you help me?

  2. #2
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,886

    Re: trigger problem

    Hi

    Which C Compiler do you use?
    Which camera model do you use?
    What do you want to achieve?
    Best regards
    Stefan
    IC Imaging Control Support

  3. #3
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    I use MinGW as compiler
    the model of my camera is DMK 23GP031

    I would like the camera to take a picture when the strobe flash
    I do not know if it is very clear

  4. #4
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,886

    Re: trigger problem

    Hi

    As shown in the "ansi.c" sample, the trigger is enabled as follows:
    Code:
    //////////////////////////////////////////////////////////////////////////
    /*!
    */
    void SetTrigger()
    {
    	HGRABBER hGrabber = IC_ShowDeviceSelectionDialog(NULL);    
    
    	if( IC_IsTriggerAvailable(hGrabber) == IC_SUCCESS )
    	{
    
    
    		IC_EnableTrigger(hGrabber,1);
    		IC_StartLive(hGrabber,1);
    
    		printf("Triggered, there should be new images only if a trigger pulse occurred\n");
    
    		printf("Press any key to continue!\n");
    		_getch();
    	}
    	else
    	{
    		printf("The device does not support triggering!\n");
    	}
    
    	IC_ReleaseGrabber(&hGrabber);
    	IC_CloseLibrary();
    
    }
    In order to be notified of a new image arrival, you add a callback, as shown in the "ansi.c" sample too. Then you only need to connect the cable, that lets your strobe flash parallel to the camera, so the camera is triggered together with the strobe flash.
    Best regards
    Stefan
    IC Imaging Control Support

  5. #5
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    thank you for your response

    but its not working
    what is the minimum time of the pulse?
    a pulse of 5V is enough?

    if I replace the line HGRABBER hGrabber= IC_ShowDeviceSelectionDialog(NULL) by hGrabber=IC_CreateGrabber() does this work anyway

  6. #6
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    I ask stupid questions
    I tried HGRABBER hGrabber IC_ShowDeviceSelectionDialog = (NULL)
    I don't need to this line if I manually return the data normally
    so for now I sent a 5V signal for 1 ms and its not working I also try with 2 and 4 ms without success
    I put the program I did, you maybe find why it does not work
    void photo(char *nomcam,char *format,char *type,char *trigger)
    {
    int trig;
    FILE *prephoto;
    HGRABBER hGrabber;
    trig = atoi(trigger);
    if( IC_InitLibrary(0) == IC_SUCCESS )
    {
    hGrabber = IC_CreateGrabber();
    if( hGrabber )
    {
    if( IC_OpenVideoCaptureDevice(hGrabber,nomcam) == IC_SUCCESS )
    {
    if(!(strcmp(format,"Y800")))
    IC_SetFormat (hGrabber, Y800); //initialise le format de la camera
    else if(!(strcmp(format,"RGB24")))
    IC_SetFormat (hGrabber, RGB24); //initialise le format de la camera
    else
    IC_SetFormat (hGrabber, RGB32); //initialise le format de la camera
    if( IC_IsTriggerAvailable(hGrabber) == IC_SUCCESS )
    {
    if(trig==0)
    {
    if(IC_StartLive (hGrabber, 0)==IC_SUCCESS)
    {
    if(!(strcmp(type,"BMP")))
    IC_SaveImage ( hGrabber, image, FILETYPE_BMP,50);
    else
    IC_SaveImage ( hGrabber, image, FILETYPE_JPEG,50);
    }
    }
    else if(trig==1)
    {
    IC_EnableTrigger(hGrabber,1);
    if(IC_ StartLive (hGrabber, 0)==IC_SUCCESS)
    {

    do{
    prephoto = fopen(image,"r");
    }while(prephoto == NULL);
    }
    }
    IC_StopLive (hGrabber); //stop la camera
    IC_EnableTrigger(hGrabber,0);
    }
    }
    // suprime les choses créé pour eviter les fuite de memoire
    IC_CloseVideoCaptureDevice( hGrabber );
    IC_ReleaseGrabber( &hGrabber );
    }
    //IC_CloseLibrary();
    }
    }

  7. #7
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,886

    Re: trigger problem

    Well, the main issue is, that you do not snap an image at all. e.g. call IC_SnapImage(). Therefore, there is nothing to save.

    Have a look ImageProcessing() function in the ansi.c sample

    Code:
    IC_StartLive(hGrabber, 1);
    IC_SnapImage(hGrabber, 2000);                           // Snap a frame into memory
    IC_SaveImage(hGrabber, "Test.jpg",FILETYPE_JPEG,90);    // Save the snapped frame to harddisk
    Try this without trigger first.
    Best regards
    Stefan
    IC Imaging Control Support

  8. #8
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    I have already try it without the trigger and my program planted because of IC_SnapImage so I removed this and after the program without the trigger worked well
    I also find it odd that he can record an image without IC_SnapImage but it works
    and with the program of above if I do not use the trigger it work as I want
    but with trigger its not working
    I do not know if this is because of the trigger or because of the program but it does not work

  9. #9
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    could i have a response please ?

  10. #10
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,886

    Re: trigger problem

    I am very sorry, but there was holiday on May 1st.
    Best regards
    Stefan
    IC Imaging Control Support

  11. #11
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    yes I understand
    you have an idea of ​​the reason for which it does not work?

  12. #12
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,886

    Re: trigger problem

    Hello

    Your source code snippet works fine, if you pass "0" as trigger parameter to your photo function.

    I wonder, what
    Code:
    IC_EnableTrigger(hGrabber,1);
    if(IC_StartLive (hGrabber, 0)==IC_SUCCESS)
    {
        do{
              prephoto = fopen(image,"r");
        }while(prephoto == NULL);
    }
    is supposed to do, because I see no code, that saves an image. I also see no callback for doing this. However, the loop will terminate, in case the file "image" exists.
    Best regards
    Stefan
    IC Imaging Control Support

  13. #13
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    In this snippet, I did not put recording function because I thought I understood that the photo is taken automatically when it has a trigger signal but if I put IC_SaveImage (hGrabber image, FILETYPE_BMP, 50); he does not expect the trigger signal to save the image

    in what I thought, the camera waits for the trigger signal takes and saves the image and leave the loop when the image is saved

  14. #14
    Join Date
    Jan 2003
    Location
    Bremen, Germany
    Posts
    4,886

    Re: trigger problem

    You are right, the camera takes the photo automatically and sends it to the computer, when the trigger pulse occurred. But in your code is nothing, that will handle the incoming image.

    Therefore, I would add a callback function, that is called, when the image arrives automatically and save the image in there. You must call
    Code:
    IC_SetContinuousMode(hGrabber,0);
    so the incoming images are saved into the internal ringbuffer automatically.

    Please have a look at the "SoftwareTrigger()" and "CallbackTest()" sample functions in the "ansi.c" sample. (It does not matter, whether you use software or hardware trigger, in both cases the same happens in the camera.)
    Best regards
    Stefan
    IC Imaging Control Support

  15. #15
    Join Date
    Apr 2013
    Posts
    43

    Re: trigger problem

    I've looked and I was inspired to write her:
    int photo(char *nomcam,char *format,char *type,char *trigger)
    {
    int trig;
    int ImageReceived; // Flag that is set in the callback to 1 if an image is received.
    int Tries;
    //FILE *prephoto;
    HGRABBER hGrabber;
    trig = atoi(trigger);
    if( IC_InitLibrary(0) == IC_SUCCESS )
    {
    hGrabber = IC_CreateGrabber();
    if( hGrabber )
    {
    if( IC_OpenVideoCaptureDevice(hGrabber,"DMK 23GP031") == IC_SUCCESS )
    {
    if(!(strcmp(format,"Y800")))
    IC_SetFormat (hGrabber, Y800); //initialise le format de la camera
    else if(!(strcmp(format,"RGB24")))
    IC_SetFormat (hGrabber, RGB24); //initialise le format de la camera
    else
    IC_SetFormat (hGrabber, RGB32); //initialise le format de la camera
    if( IC_IsTriggerAvailable(hGrabber))
    {
    if(trig==0)
    {
    if(IC_StartLive (hGrabber, 0)==IC_SUCCESS) //lance la camera sans ouvrir de fenetre visualisant le contenu
    {
    if(IC_SnapImage(hGrabber, -1)==IC_SUCCESS)
    {
    if(!(strcmp(type,"BMP")))
    IC_SaveImage ( hGrabber, image, FILETYPE_BMP,50);
    else
    IC_SaveImage ( hGrabber, image, FILETYPE_JPEG,50);
    }
    }
    }
    else if(trig==1)
    {
    IC_EnableTrigger(hGrabber,1);
    IC_SetFrameReadyCallback (hGrabber, *TriggerCallback, (void*)&ImageReceived);
    IC_SetContinuousMode(hGrabber,0);
    if(IC_StartLive (hGrabber, 0)==IC_SUCCESS) //lance la camera sans ouvrir de fenetre visualisant le contenu
    {
    ImageReceived = 0; // Set the flag for image received to 0;
    Tries = 60; // Tries for time out. Depends on the Sleep time and the frame rate.
    while(Tries > 0 && ImageReceived == 0)
    {
    Sleep( 1000 );
    Tries--;
    }
    if( ImageReceived == 1 )
    {
    if(!(strcmp(type,"BMP")))
    IC_SaveImage ( hGrabber, image, FILETYPE_BMP,50);
    else
    IC_SaveImage ( hGrabber, image, FILETYPE_JPEG,50);
    }
    }
    }
    IC_StopLive (hGrabber); //stop la camera
    IC_EnableTrigger(hGrabber,0);
    }
    }
    // suprime les choses créé pour eviter les fuite de memoire
    IC_CloseVideoCaptureDevice( hGrabber );
    IC_ReleaseGrabber( &hGrabber );
    }
    //IC_CloseLibrary();
    }

    }

    but its not working, ImageReceived remains at 0 it can be the signal that I'm sending who is not good
    I send a 5V signal for 2ms
    Last edited by icemake; May 3, 2013 at 10:31:20.

Page 1 of 6 1 2 3 ... LastLast

Similar Threads

  1. Problem with external trigger
    By edparber in forum Hardware and Driver
    Replies: 1
    Last Post: October 15, 2012, 10:19:58
  2. About extern Trigger Problem!!!
    By yangping1220 in forum IC Imaging Control .NET
    Replies: 2
    Last Post: December 7, 2011, 01:33:18
  3. problem synchronizing two cameras with external trigger
    By LH2011 in forum Hardware and Driver
    Replies: 1
    Last Post: July 18, 2011, 16:21:25
  4. trigger not available
    By windman in forum IC Imaging Control .NET
    Replies: 4
    Last Post: May 24, 2010, 09:52:55

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •