Home > Software engineering >  You MFC great spirit and OPENCV great god help me have a look
You MFC great spirit and OPENCV great god help me have a look

Time:10-09

I wrote a MFC + opencv software, run the test without any problem in development phase, in order to can also run on someone else's computer, I used the use MFC in a static library and multi-threaded debugging (/Mtd) , modify configuration after each run error are found below is my code
 
Mat Painting: : criminsi (Mat image, int qukuaiR) {
/* environment variables */
.
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */

/* */image selected area matrix
Mat fillRegion (row, col, CV_8U), sourceRegion;
FillRegion=findSelecteArea (image, shieldVelue);

//get the
SourceRegion=getFan (fillRegion);
Uchar * ptrFillRegion=fillRegion. Ptr (a);
/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
.
}

Each run to findSelecteArea it is below error function content
 
Mat Painting: : findSelecteArea (Mat inputImage, int shieldVelue) {
Int row=inputImage. Rows;
Int col=inputImage. Cols;
Int imgGs col=row *;
Mat outputImage=Mat: : zeros (row, col, CV_8U);

Vector InImgVct;
The split (inputImage, inImgVct);

Uchar * ptrB=inImgVct. Ats (0). Ptr (a);
Uchar * ptrG=inImgVct. At (1) ptr (a);
Uchar * ptrR=inImgVct. At (2) ptr (a);
Uchar * data=https://bbs.csdn.net/topics/outputImage.ptr ();

for (int i=0; I{
If (ptrR [I]==shieldVelue & amp; & PtrG [I]==shieldVelue & amp; & PtrB [I]==shieldVelue)
{
Data [I]=1;
}
}
Return outputImage;
}

An error content for
HEAP [PhotoInpainting. Exe] : Invalid address specified to RtlValidateHeap (02 d30000, 00 d4ede8)
The Windows have been PhotoInpainting. Exe trigger a breakpoint,

The reason may be that the heap is damaged, it shows that PhotoInpainting. Exe or its load in any DLL have bugs,

Reason may also be a user in PhotoInpainting. Exe has focus press F12,

Output window may provide more diagnostic information,

CodePudding user response:

Has a problem on using the vector? Refers to the cross-border subscript?

CodePudding user response:

No, every time can run to return outputImage; Then continue to run an error,

CodePudding user response:

A wide range of possible, anything can image is too big, not necessarily must be a code problem,

CodePudding user response:

reference 1st floor VisualEleven response:
has a problem on the use of vector? Refers to the cross-border subscript?

And I use the
in a Shared DLL generated MFC and multi-threaded debugging DLLS (/MDd)
No problem, what problem

CodePudding user response:

Multi-threaded debugging
Face on the VC program debugging is simple, if you want to debug program, first F10, began to run the program, second, we need to wait after thread creation to set breakpoints, otherwise the program we see only the main function of a thread,
A) click [Debug], choose (threads), then we can start a multi-threaded debugging;
B) if the need for a single thread hangs, click on the corresponding thread, select [suspend];
C) if you need to a certain thread scheduling again, click on the corresponding thread, select/resume;
D) if the need to look at a specific thread stack, then choose the thread, then [Set Focus], closed threads dialog box, can be seen in the stack window;
E) if a thread to be suspended to live, then all threads up in the right now, if you step operation, all the threads will be involved in running;
F) if you need to debug a single thread, so need to suspend the other thread,

CodePudding user response:

Estimation is the memory of crossing the line, you put the if (ptrR [I]==shieldVelue & amp; & PtrG [I]==shieldVelue & amp; & PtrB [I]==shieldVelue) commented out see if it is an error

CodePudding user response:

Sometimes not to "call a function name + each parameter value, after entering the function of each parameter values, intermediate variable values, exit the function return value of preparation, return to the function to call after the function value of the parameter name + + return value" this information to write logs to a file is where no matter how to also can not find the problem, including capture all kinds of abnormal, writing log to the screen and single step or set a breakpoint or core file is generated,... These methods are not! Write logs to a file reference below:
//loop to a function sends a length of 200 bytes (this is the fixed) buffer, 
//a function need to incoming buffer, the circulation of 240 bytes (fixed) new buffer for processing,
//when dealing with each new printing takes two bytes of the buffer
# ifdef _MSC_VER
# pragma warning (4996) disable:
# endif
# include & lt; stdio.h>
# include & lt; Stdlib. H>
# include & lt; String. H>
# ifdef _MSC_VER
# include & lt; Windows. H>
# include & lt; Process. H>
# include & lt; IO. H>
# define MYVOID void
# define vsnprintf _vsnprintf
# the else
# include & lt; Unistd. H>
# include & lt; Sys/time. H>
# include & lt; Pthread. H>
# define CRITICAL_SECTION pthread_mutex_t
# define MYVOID void *
# endif
//the Log {
# define MAXLOGSIZE 20000000
# define MAXLINSIZE 16000
# include & lt; Time. H>
# include & lt; Sys/timeb. H>
# include & lt; Stdarg. H>
Char logfilename1 []="MyLog1. Log";
Char logfilename2 []="MyLog2. Log";
The static char logstr [MAXLINSIZE + 1];
Char datestr [16].
Char timestr [16].
Char MSS [4].
CRITICAL_SECTION cs_log;
The FILE * flog;
# ifdef _MSC_VER
The Lock (CRITICAL_SECTION void * l) {
The EnterCriticalSection (l);
}
Void Unlock (CRITICAL_SECTION * l) {
LeaveCriticalSection (l);
}
Void sleep_ms (int) ms {
Sleep (ms).
}
# the else
The Lock (CRITICAL_SECTION void * l) {
Pthread_mutex_lock (l);
}
Void Unlock (CRITICAL_SECTION * l) {
Pthread_mutex_unlock (l);
}
Void sleep_ms (int) ms {
Usleep (ms * 1000);
}
# endif
Void LogV (const char * pszFmt, va_list argp) {
* struct tm now;
Struct timeb TB;

If (NULL==pszFmt | | 0==pszFmt [0]) return;
Vsnprintf (logstr, MAXLINSIZE pszFmt, argp);
Ftime (& amp; TB);
Now=localtime (& amp; TB. Time);
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related