-1

I have actually a problem with the Iterator in OpenCV. I am reading from LabView an Image and store this in a Mat imgIn. Afterwards I create a second Mat for image proccesing things Mat imOut. When I clone this and try to send it back to LabView, I get a black image so there have been sent no information.

#include <windows.h>
#include "extcode.h"
#include <iostream>
#include <stdio.h>
#include "opencv2/opencv.hpp"
#include "opencv2/core.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"

using namespace cv;
using namespace std;

// --- Dll entry point ---
BOOL APIENTRY DllMain( HANDLE hModule, 
                   DWORD  ul_reason_for_call, 
                   LPVOID lpReserved
                 )
{
UNREFERENCED_PARAMETER(hModule);
UNREFERENCED_PARAMETER(lpReserved);
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
    break;
}
return TRUE;
 }


  #ifdef __cplusplus
  extern "C" {
  #endif  /* __cplusplus */


  __declspec(dllexport) INT myDoSomething(short* M, short* N, short* image, int SizeX, int SizeY, short* imgOut){

// Alloc Memory
Mat imgIn(SizeX, SizeY, CV_16S, &image[0]);
Mat imOut(SizeX, SizeY, CV_16S, &imgOut[0]);


// Clone Source Image

imOut = imgIn.clone();

// Get size for DFT

*M = getOptimalDFTSize(imgIn.rows);
*N = getOptimalDFTSize(imgIn.cols);

MatIterator_ it;// = imOut.begin<short>();

//for(int x=0;x<=SizeX;x++){

    //imgOut = imOut.at<short>(x,y);
//}

return 0;
}



#ifdef __cplusplus
}
#endif  /* __cplusplus */

In LabView everything is correct. VS error:

Fehler 1 error C2955: "cv::MatIterator_": Für die Verwendung der template-Klasse ist eine template-Argumentliste erforderlich.

Miki
  • 40,887
  • 13
  • 123
  • 202
Xeno1987
  • 9
  • 1
  • 6

1 Answers1

2

MatIterator_ is a template class.

it's exactly, what the error says, you have to specify the type (as well as for begin() and end()):

MatIterator_<short> it = imOut.begin<short>();
for (; it != imOut.end<short>(); ++it)
{
    ...
}
berak
  • 39,159
  • 9
  • 91
  • 89