From 0a919729a5ca388692ebdad0a2555fbeb15133aa Mon Sep 17 00:00:00 2001 From: lebarsfa Date: Fri, 12 Aug 2016 01:27:42 +0200 Subject: [PATCH] Added hcenter, vcenter, hshift, vshift parameters in servers configuration files --- CHANGELOG.txt | 4 ++ Makefile | 13 +++- ReadMe.txt | 6 +- RemoteWebcamCli/RemoteWebcamCli.txt | 4 +- RemoteWebcamMultiSrv/Globals.cpp | 4 ++ RemoteWebcamMultiSrv/Globals.h | 4 ++ RemoteWebcamMultiSrv/Main.cpp | 66 ++++++++++-------- RemoteWebcamMultiSrv/RemoteWebcamMultiSrv.txt | 11 +++ RemoteWebcamSrv/Globals.c | 4 ++ RemoteWebcamSrv/Globals.h | 4 ++ RemoteWebcamSrv/Main.c | 68 ++++++++++--------- RemoteWebcamSrv/RemoteWebcamSrv.txt | 8 +++ RemoteWebcam_Zip.bat | 4 ++ 13 files changed, 132 insertions(+), 68 deletions(-) create mode 100644 RemoteWebcam_Zip.bat diff --git a/CHANGELOG.txt b/CHANGELOG.txt index bc6c13f..7112878 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,3 +1,7 @@ +20 +Improved compatibility with OpenCV 3.1.0. +Added hcenter, vcenter, hshift, vshift parameters in servers configuration files. + 19 Improved Linux support. diff --git a/Makefile b/Makefile index 0f4b504..aba975d 100644 --- a/Makefile +++ b/Makefile @@ -3,19 +3,28 @@ # sudo apt-get install build-essential # in a terminal. # You need to install OpenCV 2.4.9. +# For more information on the configuration used, see www.ensta-bretagne.fr/lebars/Share/Ubuntu.txt . +# Use dos2unix *.txt to ensure line endings are correct for Linux in the configuration files. +# In case of codecs problems, try with USE_ALTERNATE_RECORDING... PROGS = RemoteWebcamMultiSrv RemoteWebcamSrv RemoteWebcamCli CC = gcc CXX = g++ + #CFLAGS += -Wall -Winline -Wextra -g CFLAGS += -Wall -O3 CFLAGS += -I. -I../OSUtils -I../Extensions/Img -#CFLAGS += -D _DEBUG -D _DEBUG_DISPLAY -D _DEBUG_MESSAGES -CFLAGS += -D DISABLE_GUI_REMOTEWEBCAMSRV -D DISABLE_GUI_REMOTEWEBCAMMULTISRV -D USE_ALTERNATE_RECORDING +#CFLAGS += -D _DEBUG -D _DEBUG_DISPLAY +#CFLAGS += -D _DEBUG_MESSAGES +#CFLAGS += -D DISABLE_GUI_REMOTEWEBCAMSRV -D DISABLE_GUI_REMOTEWEBCAMMULTISRV -D USE_ALTERNATE_RECORDING CFLAGS += -D OPENCV249 +#CFLAGS += -D OPENCV310 + CXXFLAGS += $(CFLAGS) -fpermissive + LDFLAGS += -lopencv_core -lopencv_highgui -lopencv_imgproc +#LDFLAGS += -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_videoio LDFLAGS += -lpthread -lrt -lm default: $(PROGS) diff --git a/ReadMe.txt b/ReadMe.txt index 155e9fc..1c32f5b 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -8,13 +8,13 @@ Check also proxy settings of Internet Explorer, and any other installed browser. It should work with the following software : *** USER and DEVEL *** -_ Windows XP Professional SP3 32 bit/Windows 8 Professional 64 bit +_ Windows XP Professional SP3 32 bit/Windows 8.1 Professional 64 bit _ Kinect v2 SDK (not available for Visual Studio 2008 and Windows XP) *** DEVEL *** _ Visual Studio 2008 SP1/Visual Studio 2012 _ OpenCV 2.4.9 (download http://www.ensta-bretagne.fr/lebars/Share/OpenCV2.4.9.zip and extract in C:) -It is also supposed to be compatible with Linux 2.6 with equivalent prerequisites, although not fully tested. +It is also supposed to be compatible with Linux with equivalent prerequisites, although not fully tested, see Makefile. Restart the computer after installation. @@ -22,4 +22,6 @@ The following are required sources dependencies : _ ..\OSUtils : Windows/Linux abstraction layer (threads, network, serial port, time management...) as well as other useful functions. _ ..\Extensions : some image functions. +Please do not try to build the program in a directory that contains commas! Mind the line endings in the configuration files depending on the OS (use e.g. the command dos2unix *.txt to convert line endings for Linux)! + See also https://github.com/ENSTABretagneRobotics/Android and http://www.ensta-bretagne.fr/lebars/utilities/ diff --git a/RemoteWebcamCli/RemoteWebcamCli.txt b/RemoteWebcamCli/RemoteWebcamCli.txt index ebbb199..1b29e67 100644 --- a/RemoteWebcamCli/RemoteWebcamCli.txt +++ b/RemoteWebcamCli/RemoteWebcamCli.txt @@ -1,8 +1,6 @@ % cli1address 127.0.0.1 -%192.168.182.128 -%192.168.1.10 -%192.168.1.15 +%192.168.1.107 % cli1port 4014 % videoimgwidth diff --git a/RemoteWebcamMultiSrv/Globals.cpp b/RemoteWebcamMultiSrv/Globals.cpp index cebd730..9ed2d06 100644 --- a/RemoteWebcamMultiSrv/Globals.cpp +++ b/RemoteWebcamMultiSrv/Globals.cpp @@ -38,9 +38,13 @@ int videoimgheight = 0; int captureperiod = 0; int timeout = 0; BOOL bForceSoftwareResize = FALSE; +double hcenter = 0; +double vcenter = 0; double hscale = 1; double vscale = 1; double angle = 0; +double hshift = 0; +double vshift = 0; int bFlip = FALSE; BOOL bUDP = FALSE; int pixcolorchgthreshold = 0; diff --git a/RemoteWebcamMultiSrv/Globals.h b/RemoteWebcamMultiSrv/Globals.h index 89078ec..30b0b93 100644 --- a/RemoteWebcamMultiSrv/Globals.h +++ b/RemoteWebcamMultiSrv/Globals.h @@ -56,9 +56,13 @@ EXTERN_C int videoimgheight; EXTERN_C int captureperiod; EXTERN_C int timeout; EXTERN_C BOOL bForceSoftwareResize; +EXTERN_C double hcenter; +EXTERN_C double vcenter; EXTERN_C double hscale; EXTERN_C double vscale; EXTERN_C double angle; +EXTERN_C double hshift; +EXTERN_C double vshift; EXTERN_C int bFlip; EXTERN_C BOOL bUDP; EXTERN_C int pixcolorchgthreshold; diff --git a/RemoteWebcamMultiSrv/Main.cpp b/RemoteWebcamMultiSrv/Main.cpp index d5a97c8..8bb7750 100644 --- a/RemoteWebcamMultiSrv/Main.cpp +++ b/RemoteWebcamMultiSrv/Main.cpp @@ -16,9 +16,13 @@ int LoadConfig() captureperiod = 40; timeout = 5; bForceSoftwareResize = 1; + hcenter = 0;//+videoimgwidth/2 + vcenter = 0;//+videoimgheight/2 hscale = 1; vscale = 1; angle = 0*M_PI/180.0; + hshift = 0;//+videoimgwidth/2 + vshift = 0;//+videoimgheight/2 bFlip = 0; bUDP = 0; pixcolorchgthreshold = 12; @@ -52,6 +56,10 @@ int LoadConfig() if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%d", &bForceSoftwareResize) != 1) printf("Invalid configuration file.\n"); if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &hcenter) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &vcenter) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%lf", &hscale) != 1) printf("Invalid configuration file.\n"); if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%lf", &vscale) != 1) printf("Invalid configuration file.\n"); @@ -59,6 +67,10 @@ int LoadConfig() if (sscanf(line, "%lf", &d0) != 1) printf("Invalid configuration file.\n"); angle = d0*M_PI/180.0; if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &hshift) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &vshift) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%d", &bFlip) != 1) printf("Invalid configuration file.\n"); if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%d", &bUDP) != 1) printf("Invalid configuration file.\n"); @@ -409,6 +421,7 @@ THREAD_PROC_RETURN_VALUE handlecam(void* pParam) { double m[6]; // For rotation... CvMat M = cvMat(2, 3, CV_64F, m); // For rotation... + double hcenter0 = 0, vcenter0 = 0, hshift0 = 0, vshift0 = 0; int nbBytes = 0; char szText[256]; unsigned int val = 0; @@ -467,33 +480,29 @@ THREAD_PROC_RETURN_VALUE handlecam(void* pParam) else resizedframe = frame; EnterCriticalSection(&imageCS); - if ((hscale == 1)&&(vscale == 1)&&(angle == 0)) + if ((hcenter == 0)&&(vcenter == 0)&& + (hscale == 1)&&(vscale == 1)&&(angle == 0)&& + (hshift == 0)&&(vshift == 0)) { if (bFlip) cvFlip(resizedframe, image, 1); else cvCopy(resizedframe, image, 0); } else { // Create a map_matrix, where the left 2x2 matrix is the transform and the right 2x1 is the dimensions. - //double hscale = 0.5, vscale = 1.33*0.5; + + hcenter0 = resizedframe->width*0.5+hcenter; + vcenter0 = resizedframe->height*0.5+vcenter; + hshift0 = resizedframe->width*0.5+hshift; + vshift0 = resizedframe->height*0.5+vshift; + m[0] = cos(angle)/hscale; m[1] = sin(angle)/hscale; m[3] = -sin(angle)/vscale; m[4] = cos(angle)/vscale; - m[2] = (1-cos(angle)/hscale)*resizedframe->width*0.5-(sin(angle)/hscale)*resizedframe->height*0.5; - m[5] = (sin(angle)/vscale)*resizedframe->width*0.5+(1-cos(angle)/vscale)*resizedframe->height*0.5; + m[2] = (1-cos(angle)/hscale)*hshift0-(sin(angle)/hscale)*vshift0+hcenter0-hshift0; + m[5] = (sin(angle)/vscale)*hshift0+(1-cos(angle)/vscale)*vshift0+vcenter0-vshift0; cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP, cvScalarAll(0)); - //double hscale = 1.33*0.5, vscale = 0.5; - //m[0] = hscale*cos(-angle); - //m[1] = hscale*sin(-angle); - //m[3] = vscale*-sin(-angle); - //m[4] = vscale*cos(-angle); - //m[2] = (1-hscale*cos(-angle))*resizedframe->width*0.5-hscale*sin(-angle)*resizedframe->height*0.5; - //m[5] = vscale*sin(-angle)*resizedframe->width*0.5+(1-vscale*cos(-angle))*resizedframe->height*0.5; - ////cvGetQuadrangleSubPix(resizedframe, image, &M); - ////cv2DRotationMatrix(cvPoint2D32f(resizedframe->width*0.5,resizedframe->height*0.5), -angle*180.0/M_PI, scale, &M); - //cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0)); - if (bFlip) cvFlip(image, NULL, 1); } LeaveCriticalSection(&imageCS); @@ -683,6 +692,7 @@ int main(int argc, char* argv[]) #endif // __ANDROID__ double m[6]; // For rotation... CvMat M = cvMat(2, 3, CV_64F, m); // For rotation... + double hcenter0 = 0, vcenter0 = 0, hshift0 = 0, vshift0 = 0; THREAD_IDENTIFIER handlecamThreadId; char videorecordfilename[256]; int i = 0; @@ -771,33 +781,29 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - if ((angle == 0)&&(hscale == 1)&&(vscale == 1)) + if ((hcenter == 0)&&(vcenter == 0)&& + (hscale == 1)&&(vscale == 1)&&(angle == 0)&& + (hshift == 0)&&(vshift == 0)) { if (bFlip) cvFlip(resizedframe, image, 1); else cvCopy(resizedframe, image, 0); } else { // Create a map_matrix, where the left 2x2 matrix is the transform and the right 2x1 is the dimensions. - //double hscale = 0.5, vscale = 1.33*0.5; + + hcenter0 = resizedframe->width*0.5+hcenter; + vcenter0 = resizedframe->height*0.5+vcenter; + hshift0 = resizedframe->width*0.5+hshift; + vshift0 = resizedframe->height*0.5+vshift; + m[0] = cos(angle)/hscale; m[1] = sin(angle)/hscale; m[3] = -sin(angle)/vscale; m[4] = cos(angle)/vscale; - m[2] = (1-cos(angle)/hscale)*resizedframe->width*0.5-(sin(angle)/hscale)*resizedframe->height*0.5; - m[5] = (sin(angle)/vscale)*resizedframe->width*0.5+(1-cos(angle)/vscale)*resizedframe->height*0.5; + m[2] = (1-cos(angle)/hscale)*hshift0-(sin(angle)/hscale)*vshift0+hcenter0-hshift0; + m[5] = (sin(angle)/vscale)*hshift0+(1-cos(angle)/vscale)*vshift0+vcenter0-vshift0; cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP, cvScalarAll(0)); - //double hscale = 1.33*0.5, vscale = 0.5; - //m[0] = hscale*cos(-angle); - //m[1] = hscale*sin(-angle); - //m[3] = vscale*-sin(-angle); - //m[4] = vscale*cos(-angle); - //m[2] = (1-hscale*cos(-angle))*resizedframe->width*0.5-hscale*sin(-angle)*resizedframe->height*0.5; - //m[5] = vscale*sin(-angle)*resizedframe->width*0.5+(1-vscale*cos(-angle))*resizedframe->height*0.5; - ////cvGetQuadrangleSubPix(resizedframe, image, &M); - ////cv2DRotationMatrix(cvPoint2D32f(resizedframe->width*0.5,resizedframe->height*0.5), -angle*180.0/M_PI, scale, &M); - //cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0)); - if (bFlip) cvFlip(image, NULL, 1); } diff --git a/RemoteWebcamMultiSrv/RemoteWebcamMultiSrv.txt b/RemoteWebcamMultiSrv/RemoteWebcamMultiSrv.txt index d7e3b41..8beb608 100644 --- a/RemoteWebcamMultiSrv/RemoteWebcamMultiSrv.txt +++ b/RemoteWebcamMultiSrv/RemoteWebcamMultiSrv.txt @@ -1,5 +1,8 @@ % camid (0..9) or a video filename 0 +%Kinect2Color +%Kinect2Depth +%Kinect2Infrared % srvport 4014 % videoimgwidth @@ -14,12 +17,20 @@ 5 % bForceSoftwareResize 1 +% hcenter +0 +% vcenter +0 % hscale 1 % vscale 1 % rotation angle (in deg) 0 +% hshift +0 +% vshift +0 % bFlip 0 % bUDP diff --git a/RemoteWebcamSrv/Globals.c b/RemoteWebcamSrv/Globals.c index 347d10b..47d1743 100644 --- a/RemoteWebcamSrv/Globals.c +++ b/RemoteWebcamSrv/Globals.c @@ -29,9 +29,13 @@ int videoimgheight = 0; int captureperiod = 0; int timeout = 0; BOOL bForceSoftwareResize = FALSE; +double hcenter = 0; +double vcenter = 0; double hscale = 1; double vscale = 1; double angle = 0; +double hshift = 0; +double vshift = 0; int bFlip = FALSE; BOOL bUDP = FALSE; int pixcolorchgthreshold = 0; diff --git a/RemoteWebcamSrv/Globals.h b/RemoteWebcamSrv/Globals.h index 48551cc..cd83969 100644 --- a/RemoteWebcamSrv/Globals.h +++ b/RemoteWebcamSrv/Globals.h @@ -36,9 +36,13 @@ EXTERN_C int videoimgheight; EXTERN_C int captureperiod; EXTERN_C int timeout; EXTERN_C BOOL bForceSoftwareResize; +EXTERN_C double hcenter; +EXTERN_C double vcenter; EXTERN_C double hscale; EXTERN_C double vscale; EXTERN_C double angle; +EXTERN_C double hshift; +EXTERN_C double vshift; EXTERN_C int bFlip; EXTERN_C BOOL bUDP; EXTERN_C int pixcolorchgthreshold; diff --git a/RemoteWebcamSrv/Main.c b/RemoteWebcamSrv/Main.c index 652b6f9..fe846a2 100644 --- a/RemoteWebcamSrv/Main.c +++ b/RemoteWebcamSrv/Main.c @@ -16,9 +16,13 @@ int LoadConfig() captureperiod = 40; timeout = 5; bForceSoftwareResize = 1; + hcenter = 0;//+videoimgwidth/2 + vcenter = 0;//+videoimgheight/2 hscale = 1; vscale = 1; angle = 0*M_PI/180.0; + hshift = 0;//+videoimgwidth/2 + vshift = 0;//+videoimgheight/2 bFlip = 0; bUDP = 0; pixcolorchgthreshold = 12; @@ -51,6 +55,10 @@ int LoadConfig() if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%d", &bForceSoftwareResize) != 1) printf("Invalid configuration file.\n"); if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &hcenter) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &vcenter) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%lf", &hscale) != 1) printf("Invalid configuration file.\n"); if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%lf", &vscale) != 1) printf("Invalid configuration file.\n"); @@ -58,6 +66,10 @@ int LoadConfig() if (sscanf(line, "%lf", &d0) != 1) printf("Invalid configuration file.\n"); angle = d0*M_PI/180.0; if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &hshift) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); + if (sscanf(line, "%lf", &vshift) != 1) printf("Invalid configuration file.\n"); + if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%d", &bFlip) != 1) printf("Invalid configuration file.\n"); if (fgets3(file, line, sizeof(line)) == NULL) printf("Invalid configuration file.\n"); if (sscanf(line, "%d", &bUDP) != 1) printf("Invalid configuration file.\n"); @@ -272,6 +284,7 @@ int handlecli(SOCKET sockcli, void* pParam) { double m[6]; // For rotation... CvMat M = cvMat(2, 3, CV_64F, m); // For rotation... + double hcenter0 = 0, vcenter0 = 0, hshift0 = 0, vshift0 = 0; int nbBytes = 0; char szText[256]; unsigned int val = 0; @@ -364,33 +377,29 @@ int handlecli(SOCKET sockcli, void* pParam) if (bForceSoftwareResize) cvResize(frame, resizedframe, CV_INTER_LINEAR); else resizedframe = frame; - if ((hscale == 1)&&(vscale == 1)&&(angle == 0)) + if ((hcenter == 0)&&(vcenter == 0)&& + (hscale == 1)&&(vscale == 1)&&(angle == 0)&& + (hshift == 0)&&(vshift == 0)) { if (bFlip) cvFlip(resizedframe, image, 1); else cvCopy(resizedframe, image, 0); } else { // Create a map_matrix, where the left 2x2 matrix is the transform and the right 2x1 is the dimensions. - //double hscale = 0.5, vscale = 1.33*0.5; + + hcenter0 = resizedframe->width*0.5+hcenter; + vcenter0 = resizedframe->height*0.5+vcenter; + hshift0 = resizedframe->width*0.5+hshift; + vshift0 = resizedframe->height*0.5+vshift; + m[0] = cos(angle)/hscale; m[1] = sin(angle)/hscale; m[3] = -sin(angle)/vscale; m[4] = cos(angle)/vscale; - m[2] = (1-cos(angle)/hscale)*resizedframe->width*0.5-(sin(angle)/hscale)*resizedframe->height*0.5; - m[5] = (sin(angle)/vscale)*resizedframe->width*0.5+(1-cos(angle)/vscale)*resizedframe->height*0.5; + m[2] = (1-cos(angle)/hscale)*hshift0-(sin(angle)/hscale)*vshift0+hcenter0-hshift0; + m[5] = (sin(angle)/vscale)*hshift0+(1-cos(angle)/vscale)*vshift0+vcenter0-vshift0; cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP, cvScalarAll(0)); - //double hscale = 1.33*0.5, vscale = 0.5; - //m[0] = hscale*cos(-angle); - //m[1] = hscale*sin(-angle); - //m[3] = vscale*-sin(-angle); - //m[4] = vscale*cos(-angle); - //m[2] = (1-hscale*cos(-angle))*resizedframe->width*0.5-hscale*sin(-angle)*resizedframe->height*0.5; - //m[5] = vscale*sin(-angle)*resizedframe->width*0.5+(1-vscale*cos(-angle))*resizedframe->height*0.5; - ////cvGetQuadrangleSubPix(resizedframe, image, &M); - ////cv2DRotationMatrix(cvPoint2D32f(resizedframe->width*0.5,resizedframe->height*0.5), -angle*180.0/M_PI, scale, &M); - //cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0)); - if (bFlip) cvFlip(image, NULL, 1); } @@ -570,6 +579,7 @@ int main(int argc, char* argv[]) #endif // __ANDROID__ double m[6]; // For rotation... CvMat M = cvMat(2, 3, CV_64F, m); // For rotation... + double hcenter0 = 0, vcenter0 = 0, hshift0 = 0, vshift0 = 0; int i = 0; #ifndef __ANDROID__ @@ -633,7 +643,7 @@ int main(int argc, char* argv[]) cvReleaseCapture(&webcam); return EXIT_FAILURE; } - + if (bForceSoftwareResize) { resizedframe = cvCreateImage(cvSize(videoimgwidth,videoimgheight), frame->depth, frame->nChannels); @@ -656,33 +666,29 @@ int main(int argc, char* argv[]) return EXIT_FAILURE; } - if ((angle == 0)&&(hscale == 1)&&(vscale == 1)) + if ((hcenter == 0)&&(vcenter == 0)&& + (hscale == 1)&&(vscale == 1)&&(angle == 0)&& + (hshift == 0)&&(vshift == 0)) { if (bFlip) cvFlip(resizedframe, image, 1); else cvCopy(resizedframe, image, 0); } else { // Create a map_matrix, where the left 2x2 matrix is the transform and the right 2x1 is the dimensions. - //double hscale = 0.5, vscale = 1.33*0.5; + + hcenter0 = resizedframe->width*0.5+hcenter; + vcenter0 = resizedframe->height*0.5+vcenter; + hshift0 = resizedframe->width*0.5+hshift; + vshift0 = resizedframe->height*0.5+vshift; + m[0] = cos(angle)/hscale; m[1] = sin(angle)/hscale; m[3] = -sin(angle)/vscale; m[4] = cos(angle)/vscale; - m[2] = (1-cos(angle)/hscale)*resizedframe->width*0.5-(sin(angle)/hscale)*resizedframe->height*0.5; - m[5] = (sin(angle)/vscale)*resizedframe->width*0.5+(1-cos(angle)/vscale)*resizedframe->height*0.5; + m[2] = (1-cos(angle)/hscale)*hshift0-(sin(angle)/hscale)*vshift0+hcenter0-hshift0; + m[5] = (sin(angle)/vscale)*hshift0+(1-cos(angle)/vscale)*vshift0+vcenter0-vshift0; cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS+CV_WARP_INVERSE_MAP, cvScalarAll(0)); - //double hscale = 1.33*0.5, vscale = 0.5; - //m[0] = hscale*cos(-angle); - //m[1] = hscale*sin(-angle); - //m[3] = vscale*-sin(-angle); - //m[4] = vscale*cos(-angle); - //m[2] = (1-hscale*cos(-angle))*resizedframe->width*0.5-hscale*sin(-angle)*resizedframe->height*0.5; - //m[5] = vscale*sin(-angle)*resizedframe->width*0.5+(1-vscale*cos(-angle))*resizedframe->height*0.5; - ////cvGetQuadrangleSubPix(resizedframe, image, &M); - ////cv2DRotationMatrix(cvPoint2D32f(resizedframe->width*0.5,resizedframe->height*0.5), -angle*180.0/M_PI, scale, &M); - //cvWarpAffine(resizedframe, image, &M, CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS, cvScalarAll(0)); - if (bFlip) cvFlip(image, NULL, 1); } diff --git a/RemoteWebcamSrv/RemoteWebcamSrv.txt b/RemoteWebcamSrv/RemoteWebcamSrv.txt index 743dc1b..1e99ec4 100644 --- a/RemoteWebcamSrv/RemoteWebcamSrv.txt +++ b/RemoteWebcamSrv/RemoteWebcamSrv.txt @@ -14,12 +14,20 @@ 5 % bForceSoftwareResize 1 +% hcenter +0 +% vcenter +0 % hscale 1 % vscale 1 % rotation angle (in deg) 0 +% hshift +0 +% vshift +0 % bFlip 0 % bUDP diff --git a/RemoteWebcam_Zip.bat b/RemoteWebcam_Zip.bat new file mode 100644 index 0000000..ba15200 --- /dev/null +++ b/RemoteWebcam_Zip.bat @@ -0,0 +1,4 @@ +cd /d "%~dp0" +7z a -y "..\RemoteWebcam_Zip.zip" "..\RemoteWebcam" "..\OSUtils" "..\Extensions" -xr!"Debug*" -xr!"Release*" -xr!"*.ncb" -xr!"*.sdf" -xr!"*.wmv" -xr!"*.mp4" -xr!"*.flv" -xr!"..\OSUtils\Debug" -xr!"..\OSUtils\Release" -xr!"..\OSUtils\OSUtils.ncb" -xr!"..\OSUtils\OSUtils.sdf" -xr!"*.git*" +pause +exit