#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include "MvCameraControl.h"
#define CAMERA_NUM 2
bool g_bExit = false;
void PressEnterToExit(void)
{
int c;
while ( (c = getchar()) != '\n' && c != EOF );
fprintf( stderr, "\nPress enter to exit.\n");
while( getchar() != '\n');
g_bExit = true;
sleep(1);
}
{
if (NULL == pstMVDevInfo)
{
printf("The Pointer of pstMVDevInfo is NULL!\n");
return false;
}
{
printf("CurrentIp: %d.%d.%d.%d\n" , nIp1, nIp2, nIp3, nIp4);
}
{
}
else
{
printf("Not support.\n");
}
return true;
}
static void* WorkThread(void* pUser)
{
char camSerialNumber[256] = {0};
if (MV_OK == nRet)
{
}
else
{
printf("Get DeviceUserID Failed! nRet = [%x]\n", nRet);
}
if (MV_OK != nRet)
{
printf("Get PayloadSize fail! nRet [0x%x]\n", nRet);
return NULL;
}
unsigned char *
pData = (
unsigned char *)malloc(
sizeof(
unsigned char) *
stParam.nCurValue);
if (NULL == pData)
{
return NULL;
}
unsigned int nDataSize =
stParam.nCurValue;
while(1)
{
if(g_bExit)
{
break;
}
if (nRet == MV_OK)
{
printf("Cam Serial Number[%s]:GetOneFrame, Width[%d], Height[%d], nFrameNum[%d]\n",
}
else
{
printf("cam[%s]:Get One Frame failed![%x]\n", camSerialNumber, nRet);
}
}
return 0;
}
int main()
{
void* handle[CAMERA_NUM] = {NULL};
if (MV_OK != nRet)
{
printf("MV_CC_EnumDevices fail! nRet [%x]\n", nRet);
return -1;
}
unsigned int nIndex = 0;
{
{
printf("[device %d]:\n", i);
if (NULL == pDeviceInfo)
{
break;
}
PrintDeviceInfo(pDeviceInfo);
}
}
else
{
printf("Find No Devices!\n");
return -1;
}
{
return -1;
}
printf("Start %d camera Grabbing Image test\n", CAMERA_NUM);
for(int i = 0; i < CAMERA_NUM; i++)
{
printf("Please Input Camera Index: ");
scanf("%d", &nIndex);
if (MV_OK != nRet)
{
printf("MV_CC_CreateHandle fail! nRet [%x]\n", nRet);
return -1;
}
if (MV_OK != nRet)
{
printf("MV_CC_OpenDevice fail! nRet [%x]\n", nRet);
return -1;
}
if (
stDeviceList.pDeviceInfo[nIndex]->nTLayerType == MV_GIGE_DEVICE)
{
if (nPacketSize > 0)
{
if(nRet != MV_OK)
{
printf("Warning: Set Packet Size fail nRet [0x%x]!\n", nRet);
}
}
else
{
printf("Warning: Get Packet Size fail nRet [0x%x]!\n", nPacketSize);
}
}
}
for(int i = 0; i < CAMERA_NUM; i++)
{
if (MV_OK != nRet)
{
printf("Cam[%d]: MV_CC_SetTriggerMode fail! nRet [%x]\n", i, nRet);
}
if (MV_OK != nRet)
{
printf("Cam[%d]: MV_CC_StartGrabbing fail! nRet [%x]\n",i, nRet);
return -1;
}
pthread_t nThreadID;
nRet = pthread_create(&nThreadID, NULL ,WorkThread , handle[i]);
if (nRet != 0)
{
printf("Cam[%d]: thread create failed.ret = %d\n",i, nRet);
return -1;
}
}
PressEnterToExit();
for(int i = 0; i < CAMERA_NUM; i++)
{
if (MV_OK != nRet)
{
printf("MV_CC_StopGrabbing fail! nRet [%x]\n", nRet);
return -1;
}
if (MV_OK != nRet)
{
printf("MV_CC_CloseDevice fail! nRet [%x]\n", nRet);
return -1;
}
if (MV_OK != nRet)
{
printf("MV_CC_DestroyHandle fail! nRet [%x]\n", nRet);
return -1;
}
}
printf("exit\n");
return 0;
}