Hi guys, I'm currently trying to build a software to photograph, record and recognize a person's face using MFC for the GUI, however, I seem to be having some problems with the saving and registering. After capturing a person's image (3 pictures per user) and I try to register them using a button labeled "Click to register" (code below), an error pops-up which says "incorrect size of input array (non-positive width or height) in function cvCreateMatHeader" followed by the directory of OpenCV and it says that the error is in "cxarray.cpp (136)"
I've checked it against a cxarray I found online and found no fault. I've attached the code for the button below as well as the function it uses to save the image. I'm running the program from D drive, and my OpenCV is in D as well but the error says the directory is "C". I copied the OpenCV folder to the specified directory in C, but without any change. Thanks in advance. Hope you guys can help.
1 2 3 4 5 6
void CzebraDlg::OnBnClickedStartlearning() //button code
{
// TODO: Add your control notification handler code here
learn();
}
void learn() //function code
{
int i, offset;
// load training data
nTrainFaces = loadFaceImgArray("train.txt");
if( nTrainFaces < 2 )
{
/*fprintf(stderr,
"Need 2 or more training faces\n"
"Input file contains only %d\n", nTrainFaces);*/
return;
}
// do PCA on the training faces
doPCA();
// project the training images onto the PCA subspace
projectedTrainFaceMat = cvCreateMat( nTrainFaces, nEigens, CV_32FC1 );
offset = projectedTrainFaceMat->step / sizeof(float);
for(i=0; i<nTrainFaces; i++)
{
//int offset = i * nEigens;
cvEigenDecomposite(
faceImgArr[i],
nEigens,
eigenVectArr,
0, 0,
pAvgTrainImg,
//projectedTrainFaceMat->data.fl + i*nEigens);
projectedTrainFaceMat->data.fl + i*offset);
}
// store the recognition data as an xml file
storeTrainingData();
}
Hi guys, sorry about the previous post, but I just found the problem after something I tried on impulse. Turns out I need to click the circle selector in the windows form before clicking the button even though it appears as toggled. Is it possible to find a way to make it toggled automatically when I start the program? The code is below.
1 2 3 4 5 6
void CzebraDlg::OnBnClicked01()
{
// TODO: Add your control notification handler code here
sprintf(Person, "01"); //write "A" to Person
NumName=1;
}
I can't really see anything in the "properties" that I can use. Is there a fix? Thanks again in advance. (I'm using MFC for the GUI). If you guys prefer I post a new topic on this I will, but it seems like just a minor problem. Thanks.