我正在使用MPI和Opencv库文件将c程序写入我的raspberry pi。 当我的c程序尝试使用像cvCreateImage和cvGet2D这样的opencv函数时,它总是会出现这个错误:
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 11
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
这是我的c程序:
#include <mpi.h>
#include </home/pi/opencv-2.4.8/include/opencv/cv.h>
#include </home/pi/opencv-2.4.8/include/opencv/highgui.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define MAXN 2048 /* max 2d fft size */
#define EPSILON 0.00001 /* for comparing fp numbers */
#define PI 3.14159265358979 /* 4*atan(1.0) */
#define IMAGE_SIZE 1024
#define NUM_CELLS 4
#define IMAGE_SLICE (IMAGE_SIZE / NUM_CELLS) //(512/4)=128
#define SOURCE_PROCESSOR 0
#define DEST_PROCESSOR SOURCE_PROCESSOR
typedef struct {int r,i;} mycomplex;
int numtasks; /* Number of processors */
int taskid; /* ID number for each processor */
int checkpoint;
int dt[10], sum;
int main(int argc,char *argv[])
{
int rc, cell, i, j, k, n, nx, logn, errors, sign, flops;
float mflops;
checkpoint=0;
/*****************************************************************************/
/* Initialize MPI environment and get task's ID and number of tasks
* in the partition. */
rc = MPI_Init(&argc,&argv);
rc|= MPI_Comm_size(MPI_COMM_WORLD,&numtasks);
rc|= MPI_Comm_rank(MPI_COMM_WORLD,&taskid);
if(taskid==0)
{
//getimage();
IplImage *image;
IplImage *grayimage;
image=cvLoadImage("one.jpg",-1);
grayimage=cvCreateImage(cvSize(image->width,image->height),IPL_DEPTH_8U,1);
cvCvtColor(image,grayimage,CV_RGB2GRAY);
for(i=0;i<image->height;i++)
{
for(j=0;j<image->width;j++)
{
CvScalar scal=cvGet2D(image,i,j);
printf("(%d) ",(int)scal.val[0]);
}
printf("\n");
}
cvWaitKey(0);
cvReleaseImage(&image);
}
MPI_Barrier(MPI_COMM_WORLD);
/* Must have 4 tasks for this program */
if (numtasks != NUM_CELLS)
{
printf("Error: this program requires %d MPI tasks\n", NUM_CELLS);
exit(1);
}
if (rc != MPI_SUCCESS)
printf ("error initializing MPI and obtaining task ID information\n");
else
printf ("MPI task ID = %d\n", taskid);
n = IMAGE_SIZE; //512
/* compute logn and ensure that n is a power of two */
nx = n;
logn = 0;
while(( nx >>= 1) > 0)
logn++; //logn=9 when nx=1
nx = 1;
for (i=0; i<logn; i++) //loop 9 times
nx = nx*2; //nx=nx*(2^9)=512
if (nx != n) //nx=512 = n=512 proved
{
(void)fprintf(stderr, "%d: fft size must be a power of 2\n", IMAGE_SIZE);
exit(0);
}
.....
我使用的make文件似乎很好:
mpi_2dfft: mpi_2dfft.o /home/pi/mpich2/lib/libmpich.a
/home/pi/mpich2/bin/mpicc -o mpi_2dfft mpi_2dfft.o -I/usr/local/include/opencv -I/usr/local/include -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_calib3d -lopencv_objdetect -lopencv_contrib -lopencv_contrib -lopencv_legacy -lopencv_flann -lwiringPi -lwiringPiDev -lpthread -lm
我可以知道为什么opencv函数不能在mpi中使用? mpi与其他库有冲突吗?