Ich brauche deine Hilfe so schnell wie möglich. Ich überweise einen String aus LabView, die den Pfad zum imageSequence angezeigt und dann mit der folgenden Routine all Rohdaten lesen:Bild einlesen Sequenz von Roh mit OpenCV und LV
Mat loadImage(char* path, int SizeX, int SizeY, int type){
Mat imOut(SizeX, SizeY, type, Scalar(0));
FILE *fp = NULL;
char *imagedata = NULL;
int framesize = SizeX * SizeY;
char buffer[1000];
// Open raw image.
fp = fopen(path, "rb");
// Memory allocation for image data buffer.
imagedata = (char*) malloc (sizeof(char) * framesize);
// Read image data and store in buffer.
fread(imagedata, sizeof(char), framesize, fp);
memcpy(imOut.data, imagedata, framesize);
free(imagedata);
fclose(fp);
return imOut;
}
__declspec(dllexport) INT medianImgSeq(ushort SizeX, ushort SizeY, int stringL, char *src, ushort *dst, ushort *debugValue){
WIN32_FIND_DATAA found;
HANDLE hFind;
// Alloc Memory
char path[1000];
char *result;
char directory[1000];
char directoryConCat[1000];
char temp[1000];
vector<Mat> imgSeq;
vector<ushort> med;
int fileCnt(0);
int indexChar(0);
int medianValue(0);
// Copy path from string
std::strcpy(path, src);
// Get directory from path
result = std::strrchr(path, '\\');
indexChar = (int)(result-path+2);
for(int i = 0;i < indexChar;i++){
directory[i] = path[i];
directoryConCat[i] = path[i];
// Convert to String
if(i == indexChar-1){
directory[i] = '*';
directory[i+1] = '\0';
directoryConCat[i] = '\0';
}
}
strcpy(temp, directoryConCat);
// Load in image sequence
hFind = FindFirstFileA(directory, &found);
if(hFind != INVALID_HANDLE_VALUE){
do{
if((found.cFileName[0] == '.') || (found.cFileName[1] == '.')) continue;
fileCnt++;
imgSeq.push_back(loadImage(std::strcat(directoryConCat, found.cFileName), SizeX, SizeY, CV_16U).clone());
*directoryConCat = NULL;
strcpy(directoryConCat, temp);
}while(FindNextFileA(hFind, &found));
}
return 0;
}
Das Problem ist nun, dass nur die Hälfte des Bildes in gelesen (1536 * 1920) . Haben Sie eine Idee, wo der Fehler sein könnte?
versuchen: 'int framesize = CV_ELEM_SIZE (Typ) * SizeX * SizeY;' – Miki