Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. 3rd Party Software
  4. LNK2019 y LNK1120 using sapera sdk for camera genie nano y openCV
Forum Updated to NodeBB v4.3 + New Features

LNK2019 y LNK1120 using sapera sdk for camera genie nano y openCV

Scheduled Pinned Locked Moved Unsolved 3rd Party Software
saperaopencvlnk2019lnk1120buffer
2 Posts 2 Posters 578 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ADR_PT
    wrote on last edited by ADR_PT
    #1

    I need to pass from sapbuffer to mat object but when running the code it shows LNK2019 y LNK1120 as showed
    LNK2019LNK1120.JPG

    The code is as follow:
    .pro

    
    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = Hilos4camaras
    TEMPLATE = app
    
    DEFINES += QT_DEPRECATED_WARNINGS
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    CONFIG += c++11
    
    SOURCES += \
            asignarcamaras.cpp \
            camara2.cpp \
            exp2opencv.cpp \
            main.cpp \
            mainwindow.cpp \
            myvideocapture.cpp
    
    HEADERS += \
            asignarcamaras.h \
            camara2.h \
            exp2opencv.h \
            mainwindow.h \
            myvideocapture.h
    
    FORMS += \
            mainwindow.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    
    
     #### sapera sdk ####
    
    INCLUDEPATH += 'C:\Program Files\Teledyne DALSA\Sapera\Classes\Basic'
    INCLUDEPATH += 'C:\Program Files\Teledyne DALSA\Sapera\Include'
    INCLUDEPATH += 'C:\Program Files\Teledyne DALSA\Sapera\Lib'
    
    LIBS += 'C:\Program Files\Teledyne DALSA\Sapera\Lib\Win64\SapClassBasic.lib'
    
    
     #### OPENCV ####
    
    
    win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../opencv/build/x64/vc15/lib/ -lopencv_world453
    else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../opencv/build/x64/vc15/lib/ -lopencv_world453d
    else:unix: LIBS += -L$$PWD/../../../../../../opencv/build/x64/vc15/lib/ -lopencv_world453
    
    INCLUDEPATH += $$PWD/../../../../../../opencv/build/include
    DEPENDPATH += $$PWD/../../../../../../opencv/build/include
    

    exp2opencv.h

    #ifndef EXP2OPENCV_H
    #define EXP2OPENCV_H
    
    #include <SapClassBasic.h>
    #include <opencv2/opencv.hpp>
    #include <QThread>
    
    class exp2opencv : public QThread
    {
        Q_OBJECT
    public:
        exp2opencv(QObject *parent=nullptr);
        void ExportToOpenCV_Direct( SapBuffer *pSapBuf );
    };
    
    #endif // EXP2OPENCV_H
    
    

    mainwindows.h

    #ifndef MAINWINDOW_H
    #define MAINWINDOW_H
    
    #include <QMainWindow>
    
    
    namespace Ui
    {
    class MainWindow;
    }
    
    class MyVideoCapture;
    class camara2;
    class exp2opencv;
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = nullptr);
        ~MainWindow();
    
    private slots:
        void on_pushButtonIniciar_clicked();
    
    
        void on_pushButton_clicked();
    
    private:
        Ui::MainWindow *ui;
        MyVideoCapture *mOpenCV_videoCapture;
        camara2 *videocamara2;
        exp2opencv *exportaraopencvcam1;
    };
    
    #endif // MAINWINDOW_H
    

    myvideocapture.h

    #ifndef MYVIDEOCAPTURE_H
    #define MYVIDEOCAPTURE_H
    
    #include <QThread>
    #include <SapClassBasic.h>
    #include <opencv2/opencv.hpp>
    #include <exp2opencv.h>
    #include <mainwindow.h>
    
    class MyVideoCapture : public QThread
    {
        Q_OBJECT
    public:
        MyVideoCapture(QObject *parent=nullptr);
        bool parar;
        int tiempoparadain=10000;
        static exp2opencv exportaropencv;
        static void XferCallback(SapXferCallbackInfo *pInfo);
    
    protected:
        void run() override;
        char     ccfcamara1[82]="C:\\Program Files\\Teledyne DALSA\\Sapera\\CamFiles\\User\\T_Nano-M1450_IA_1.ccf";
        char     nombrecamara1[13] = "Nano-M1450_1";
        int      numerodecamara1 =0;
    
    };
    
    #endif // MYVIDEOCAPTURE_H
    

    exp2opencv.cpp

    #include "exp2opencv.h"
    using namespace cv;
    #include "conio.h"
    #include "math.h"
    
    exp2opencv::exp2opencv(QObject *parent)
    :QThread {parent}
    {
    
    }
    
    
    void exp2opencv::ExportToOpenCV_Direct( SapBuffer *pSapBuf )
    {
    	if( pSapBuf == NULL )
    	return;
    	SapFormat sapFormat = pSapBuf->GetFormat();
    	int OpenCV_Type = 0;
    	switch( sapFormat )
    {
    	case SapFormatMono8:
    	OpenCV_Type = CV_8UC1;
    	break;
    	case SapFormatMono16:
    	OpenCV_Type = CV_16UC1;
    	break;
    	case SapFormatRGB888:
    	OpenCV_Type = CV_8UC3;
    	break;
    	case SapFormatRGB161616:
    	OpenCV_Type = CV_16UC3;
    	break;
    	default:
    	sapFormat = SapFormatUnknown;
    	break;
    }
    if( sapFormat != SapFormatUnknown )
    {
    	void *pBuf = NULL;
    	pSapBuf->GetAddress( &pBuf );
    	cv::Mat exportImg( pSapBuf->GetHeight(), pSapBuf->GetWidth(), OpenCV_Type, pBuf );
    	imshow( "deSAPtoOpenCV", exportImg );
    	pSapBuf->ReleaseAddress( &pBuf );
    	cv::waitKey(1);
    }
    }
    

    mainwindow.cpp
    **#include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "myvideocapture.h"
    #include "camara2.h"
    #include "exp2opencv.h"
    #include <QDesktopServices>
    #include <QUrl>
    #include <QFileDialog>

    // De Sapera

    #include "SapClassBasic.h"
    #include "SapAcquisition.h"

    MainWindow::MainWindow(QWidget *parent):
    QMainWindow (parent),
    ui(new Ui::MainWindow)
    {
    ui->setupUi(this);
    mOpenCV_videoCapture = new MyVideoCapture(this); // crea un myvideocapture
    videocamara2 = new camara2(this);
    exportaraopencvcam1 = new exp2opencv(this);
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    void MainWindow::on_pushButtonIniciar_clicked()
    {
    mOpenCV_videoCapture->start();
    }

    void MainWindow::on_pushButton_clicked()
    {
    QString abrircamexpert= QFileDialog::getOpenFileName(this,"cargarccf",QStandardPaths::writableLocation(QStandardPaths::DesktopLocation));//,filtroccf);

            QDesktopServices::openUrl(QUrl("file:///"+abrircamexpert,QUrl::TolerantMode));
    

    }
    **
    myvideocapture.cpp

    #include "mainwindow.h"
    using namespace cv;
    #include "conio.h"
    #include "math.h"
    
    // Restore deprecated function warnings with Visual Studio 2005
    #if defined(_MSC_VER) && _MSC_VER >= 1400
    #pragma warning(default: 4995)
    #endif
    
    MyVideoCapture::MyVideoCapture(QObject *parent)
        :QThread {parent}
    {
    
    }
    
    void MyVideoCapture::run()
    {
    
    char*    configFilename = new char[MAX_PATH];
    
    SapAcqDevice AcqDevice;
    SapBufferWithTrash Buffers;
    SapTransfer AcqDeviceToBuf = SapAcqDeviceToBuf(&AcqDevice, &Buffers);
    SapView View;
    SapTransfer* Xfer=NULL;
    
    SapLocation loc(nombrecamara1, numerodecamara1);
    
    if (SapManager::GetResourceCount(nombrecamara1, SapManager::ResourceAcqDevice) > 0)
    {
       if (strcmp(configFilename, "NoFile") == 0)
          AcqDevice = SapAcqDevice(loc,FALSE);
       else
          AcqDevice = SapAcqDevice(loc,ccfcamara1);
       Buffers = SapBufferWithTrash(1, &AcqDevice);
       View = SapView(&Buffers,SapHwndAutomatic); //SapHwndAutomatic  //SapHwndDesktop
       AcqDeviceToBuf = SapAcqDeviceToBuf(&AcqDevice, &Buffers, XferCallback, &View);
       Xfer = &AcqDeviceToBuf;
       if (!AcqDevice.Create())
          {goto FreeHandles;}
    }
    // Create buffer object
    if (!Buffers.Create())
       {goto FreeHandles;}
    // Create transfer object
    if (Xfer && !Xfer->Create())
       {goto FreeHandles;}
    // Create view object
    if (!View.Create())
      { goto FreeHandles;}
    
    //mPixmap=cvMatToQPixmap(mFrame);
    Xfer->Grab();
    Xfer->Wait(tiempoparadain);
    
    FreeHandles:
    if (!View.Destroy())View.Destroy();//View.Destroy();
    if (Xfer && *Xfer && !Xfer->Destroy())Xfer->Destroy();//Xfer->Destroy();
    if (!Buffers.Destroy())Buffers.Destroy();//Buffers.Destroy();
    if (!AcqDevice.Destroy())AcqDevice.Destroy();
    }
    
    
    void MyVideoCapture::XferCallback(SapXferCallbackInfo *pInfo)
    {
    SapView *pView =(SapView *) pInfo->GetContext() ;
    
    pView->Show(); // muestra imagen
    SapBuffer* Buffer_View = (pView->GetBuffer());
    exportaropencv.ExportToOpenCV_Direct(Buffer_View);
    
    }
    

    When I comment the line "exportaropencv.ExportToOpenCV_Direct(Buffer_View);" in myvideocapture.cpp the programm works showing the image in a sapera window but I need to pass it to openCV and I've tried some things like: clean, run qmake, rebuild, and change the code to other program but the result is the same.
    Any one can help me?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Are you sure you are linking all the required libraries ?
      Are they all from compatible compilers ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved