Forum Italiano sui Prodotti NI

annulla
Visualizzazione dei risultati per 
Cerca invece 
Intendevi dire: 

Problema con VB nel generare un file png

Sono nuovo all'utilizzo di prodotti NI  questo è il mio problema:
Visualizzo un'immagine catturata da uma telecamera e faccio scehliere all'utente una zona da usare come template per una funzione di PatternMatching. Ho usato un esempio di quelli disponibili ed ho adattato la procedura
 
    Dim LearnOptions As New CWIMAQLearnPatternOptions
    Dim Rectangle As New CWIMAQRectangle
   
    'Estrai la regione corrispondente
    CWMachineVision1.GetSelectedRectangleFromViewer CWIMAQViewer1, Rectangle
    'CWIMAQViewer1.Regions.RemoveAll
    CWIMAQVision1.Extract2 CWIMAQViewer1.Image, CWIMAQViewer2.Image, Rectangle
   
    'Setta parameteri
    LearnOptions.LearnMode = cwimaqLearnAll
    
    'Setta template
    CWIMAQVision1.LearnPattern2 CWIMAQViewer2.Image, LearnOptions
 
    ' Salva Immagine Template
    CWIMAQVision2.WritePNGFile CWIMAQViewer2.Image, App.Path & "\Tmp_P.png"
 
 
fino qui tutto OK o quasi  perchè se eseguo la ricerca del pattern con una sequenza di istruzioni tipo:
 
    Dim ProcessedPartImage As New CWIMAQImage
    Dim ParticleReport As New CWIMAQParticleReport
    Dim AreaArray As Variant
    Dim TextOptions As New CWIMAQTextOptions
    Dim UncorrectedImage As New CWIMAQImage
   
    'Parametri di Confronto
    Opzioni_Match.MatchMode = cwimaqMatchRotationInvariant
    Opzioni_Match.MinimumMatchScore = 480
    Opzioni_Match.NumMatchesRequested = 5
    Opzioni_Match.MinimumContrast = 10
    Opzioni_Match.SubPixelAccuracy = True
    Opzioni_Match.AdvancedOptions.SubpixelTolerance = 10
   
    CWMachineVision1.GetSelectedRectangleFromViewer CWIMAQViewer1, Rettangolo_Ricerca, False
   
    'Confronta e cerca immagine tipo 1
    CWIMAQVision1.MatchPattern2 CWIMAQViewer1.Image, CWIMAQViewer2.Image, Opzioni_Match, Report_Dati_Trovati, Rettangolo_Ricerca
 
tutto funziona.
 
Ma se provo ad usare come template di ricerca l'immagine  precedentemente salvata  "Tmp_P.png" 
ho un errore del tipo
 
Run Time error "31913"
Invalid Template Descriptor
   
dove sto sbagliando?
 
Un anticipato grazie a tutti
 
 
 
0 Kudos
Messaggio 1 di 2
3.844Visualizzazioni

Hi,

 

Look at this:

Problem:
I am getting the error -1074395247: "invalid template descriptor" from IMAQ Match Pattern. What could be the cause of this error?

Solution :
This often happens when you use the IMAQ Save Image to save your template. The IMAQ Save Image saves the pixel data but not the template data. You should use IMAQ Save Image and Vision Info. This will save all of the required template data.

 

Or next links:

http://digital.ni.com/public.nsf/websearch/21BF4BF6A4DD2CD186256D2F00394899?OpenDocument

 

http://digital.ni.com/public.nsf/websearch/F05924D50AD6472B86256F320075CDBF?OpenDocument

 

Hope it helps,

Regards,

Jaime Cabrera

NI Applications Engineering Spain
0 Kudos
Messaggio 2 di 2
3.780Visualizzazioni