#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <pthread.h>
#include "MvCameraControl.h"
unsigned int g_nMode = 0;
{
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* ProgressThread(void* pUser)
{
while(1)
{
printf(
"State = 0x%x,Completed = %ld,Total = %ld\r\n",nRet,stFileAccessProgress.
nCompleted,stFileAccessProgress.
nTotal);
{
break;
}
usleep(50000);
}
return 0;
}
static void* FileAccessThread(void* pUser)
{
if (1 == g_nMode)
{
if (MV_OK != g_nRet)
{
printf("File Access Read fail! nRet [0x%x]\n", g_nRet);
}
}
else if (2 == g_nMode)
{
if (MV_OK != g_nRet)
{
printf("File Access Write fail! nRet [0x%x]\n", g_nRet);
}
}
return 0;
}
int main()
{
void* handle = NULL;
do
{
if (MV_OK != nRet)
{
printf("Enum Devices fail! nRet [0x%x]\n", nRet);
break;
}
{
{
printf("[device %d]:\n", i);
if (NULL == pDeviceInfo)
{
break;
}
PrintDeviceInfo(pDeviceInfo);
}
}
else
{
printf("Find No Devices!\n");
break;
}
printf("Please Intput camera index: ");
unsigned int nIndex = 0;
scanf("%d", &nIndex);
{
printf("Intput error!\n");
break;
}
if (MV_OK != nRet)
{
printf("Create Handle fail! nRet [0x%x]\n", nRet);
break;
}
if (MV_OK != nRet)
{
printf("Open Device fail! nRet [0x%x]\n", nRet);
break;
}
g_nMode = 1;
printf("Read to file.\n");
pthread_t nReadHandle;
nRet = pthread_create(&nReadHandle, NULL ,FileAccessThread , handle);
if (nRet != 0)
{
break;
}
usleep(5000);
pthread_t nReadProcessHandle;
nRet = pthread_create(&nReadProcessHandle, NULL ,ProgressThread , handle);
if (nRet != 0)
{
break;
}
void *statusRead;
void *statusReadProcess;
pthread_join(nReadHandle, &statusRead);
pthread_join(nReadProcessHandle, &statusReadProcess);
if (MV_OK == g_nRet)
{
printf("File Access Read Success!\n");
}
printf("\n");
g_nMode = 2;
printf("Write from file.\n");
pthread_t nWriteHandle;
nRet = pthread_create(&nWriteHandle, NULL ,FileAccessThread , handle);
if (nRet != 0)
{
break;
}
usleep(5000);
pthread_t nWriteProgressHandle;
nRet = pthread_create(&nWriteProgressHandle, NULL ,ProgressThread , handle);
if (nRet != 0)
{
break;
}
void *statusWrite;
void *statusWriteProcess;
pthread_join(nWriteHandle, &statusWrite);
pthread_join(nWriteProgressHandle, &statusWriteProcess);
if (MV_OK == g_nRet)
{
printf("File Access Write Success!\n");
}
if (MV_OK != nRet)
{
printf("ClosDevice fail! nRet [0x%x]\n", nRet);
break;
}
if (MV_OK != nRet)
{
printf("Destroy Handle fail! nRet [0x%x]\n", nRet);
break;
}
} while (0);
if (nRet != MV_OK)
{
if (handle != NULL)
{
handle = NULL;
}
}
printf("exit.\n");
return 0;
}