Discussions au sujet des autres produits NI

annuler
Affichage des résultats de 
Rechercher plutôt 
Vouliez-vous dire : 

remplacer image par tableau d'image dans IVA_ProcessImage(image)

Bonjour,

j'aimerai faire une modification sur le code que génère vision assistant en code C sous labwindowscvi le code de base permet selectionner une photo , moi j'aimerai utiliser un tableau qui permet de selectionner plusieur photos et de les passer en argument dans la fonction IVA_ProcessImage(image) veuillez trouver le code de base code modifier et le projet merci pour votre aide :

CODE de base :

int main (int argc, char *argv[])
{
   ..........................
    char** imagePath;       // Image Path
    int cancelled;
    ImageType imageType;    // Image Type
    Image* image;           // Image
        
    /.................

    // Display the Load Image dialog
    imagePath = imaqLoadImagePopup(NULL, "*.*", NULL, "Open Image", FALSE, IMAQ_BUTTON_LOAD, 0, 0, 1, 0, &cancelled, NULL);

    if (!cancelled)
    {
        // Get the type of the image file to create an image of the right type
        imaqGetFileInfo(imagePath[0], NULL, NULL, NULL, NULL, NULL, &imageType);

        // Create an IMAQ Vision image
        image = imaqCreateImage(imageType, 7);
        // Read the image from disk
        imaqReadFile(image, imagePath[0], NULL, NULL);
        // Vision Assistant Algorithm
        success = IVA_ProcessImage(image);
        if (!success)
            err = imaqGetLastError();
     // Display the image
        imaqMoveWindow(DISPLAY_WINDOW, imaqMakePoint(0,0));
        imaqSetWindowPalette(DISPLAY_WINDOW, IMAQ_PALETTE_BINARY, NULL, 0);
        imaqDisplayImage(image, DISPLAY_WINDOW, TRUE);
        // Wait for a key press before exiting
        printf ("Press Enter to exit.\n");
        getchar();
        // Dispose resources
        imaqDispose(image);
    }
    imaqDispose(imagePath);
    return 0;
}

 

Je voudrai le changer j'ai ajouter quelques modifications mais sans succès

CODE modifier  :

//==============================================================================
//     Includes
//==============================================================================

#include <stdio.h>
#include <nivision.h>
#include "ImageProcessing.h"


//==============================================================================
//  Defines
//==============================================================================

#define DISPLAY_WINDOW 0

   int currentImage = 0;
   #define NUM_OCR_IMAGES 9  
   
//==============================================================================
//  Main Function
//==============================================================================

int main (int argc, char *argv[])
{          int i;
    int success = 1;
    int err = 0;
    char** imagePath;       // Image Path
    int cancelled;
    ImageType imageType;    // Image Type
    Image* ocrImagesArray[NUM_OCR_IMAGES];        // Image
        

    // IMAQ Vision creates windows in a separate thread
    imaqSetWindowThreadPolicy(IMAQ_SEPARATE_THREAD);

    //// Display the Load Image dialog
    //imagePath = imaqLoadImagePopup(NULL, "*.*", NULL, "Open Image", FALSE, IMAQ_BUTTON_LOAD, 0, 0, 1, 0, &cancelled, NULL);

    //if (!cancelled)
    //{
        //// Get the type of the image file to create an image of the right type
        //imaqGetFileInfo(imagePath[0], NULL, NULL, NULL, NULL, NULL, &imageType);

    for ( i = 0; i < NUM_OCR_IMAGES; i++ )
        ocrImagesArray[i] = imaqCreateImage (IMAQ_IMAGE_U8, 10);

    /* Load all the OCR images */
    imaqReadFile( ocrImagesArray[0], "OCR\\Image 00.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[1], "OCR\\Image 01.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[2], "OCR\\Image 02.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[3], "OCR\\Image 03.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[4], "OCR\\Image 04.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[5], "OCR\\Image 05.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[6], "OCR\\Image 06.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[7], "OCR\\Image 07.bmp", NULL, NULL);
    imaqReadFile( ocrImagesArray[8], "OCR\\Image 08.bmp", NULL, NULL);
        
        
       // // Create an IMAQ Vision image
       //ocrImagesArray[i] = imaqCreateImage(imageType, 7);

       // // Read the image from disk
       // imaqReadFile(image, imagePath[0], NULL, NULL);

        // Vision Assistant Algorithm
        success = IVA_ProcessImage(ocrImagesArray[i]);
        if (!success)
            err = imaqGetLastError();

        // Display the image
        imaqMoveWindow(DISPLAY_WINDOW, imaqMakePoint(0,0));
        imaqSetWindowPalette(DISPLAY_WINDOW, IMAQ_PALETTE_BINARY, NULL, 0);
        imaqDisplayImage(ocrImagesArray[i], DISPLAY_WINDOW, TRUE);

        // Wait for a key press before exiting
        printf ("Press Enter to exit.\n");
        getchar();

        // Dispose resources
    for ( i = 0; i < NUM_OCR_IMAGES; i++ )
        imaqDispose(ocrImagesArray[i]);

    return 0;
}

 

ERROOR

FATAL RUN-TIME ERROR:   "Main.c", line 77, col 36, thread id 10448:   Dereference of out-of-bounds pointer: 1 bytes (1 elements) past end of array.

 

0 Compliments
Message 1 sur 1
2 124 Visites