Import/export files to/from a camera.
The sample code shows how to export the User Set or DPC (Defective Pixel Correction) file of a connected camera to the local PC as a binary file, or import a binary file from the local PC to a connected camera.
#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)
{
if(4 == sizeof(long))
{
printf("State = 0x%x,Completed = %lld,Total = %lld\r\n",
}
else
{
printf("State = 0x%x,Completed = %ld,Total = %ld\r\n",
}
{
break;
}
usleep(50000);
}
return 0;
}
static void* FileAccessThread(void* pUser)
{
if (1 == g_nMode)
{
{
printf("File Access Read fail! nRet [0x%x]\n", g_nRet);
}
}
else if (2 == g_nMode)
{
{
printf("File Access Write fail! nRet [0x%x]\n", g_nRet);
}
}
return 0;
}
int main()
{
void* handle = NULL;
do
{
{
printf("Initialize SDK fail! nRet [0x%x]\n", nRet);
break;
}
{
printf("Enum Devices fail! nRet [0x%x]\n", nRet);
break;
}
{
for (
unsigned int i = 0; i < stDeviceList.
nDeviceNum; i++)
{
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;
}
{
printf("Create Handle fail! nRet [0x%x]\n", nRet);
break;
}
{
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)
{
printf("File access thread create failed.ret = %d\n",nRet);
break;
}
usleep(5000);
pthread_t nReadProcessHandle;
nRet = pthread_create(&nReadProcessHandle, NULL ,ProgressThread , handle);
if (nRet != 0)
{
printf("Progress thread create failed.ret = %d\n",nRet);
break;
}
void *statusRead;
void *statusReadProcess;
pthread_join(nReadHandle, &statusRead);
pthread_join(nReadProcessHandle, &statusReadProcess);
{
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)
{
printf("File access thread create failed.ret = %d\n",nRet);
break;
}
usleep(5000);
pthread_t nWriteProgressHandle;
nRet = pthread_create(&nWriteProgressHandle, NULL ,ProgressThread , handle);
if (nRet != 0)
{
printf("Progress thread create failed.ret = %d\n",nRet);
break;
}
void *statusWrite;
void *statusWriteProcess;
pthread_join(nWriteHandle, &statusWrite);
pthread_join(nWriteProgressHandle, &statusWriteProcess);
{
printf("File Access Write Success!\n");
}
{
printf("ClosDevice fail! nRet [0x%x]\n", nRet);
break;
}
{
printf("Destroy Handle fail! nRet [0x%x]\n", nRet);
break;
}
handle = NULL;
} while (0);
if (handle != NULL)
{
handle = NULL;
}
printf("exit.\n");
return 0;
}