Procházet zdrojové kódy

Z991239-1812 #comment fix: 解决翻转问题

胡琛80272472 před 4 roky
rodič
revize
ce294a84c8

+ 24 - 20
Module/mod_screenshot/mod_screenshot.cpp

@@ -313,16 +313,18 @@ public:
 			}
 		}
 
-//#ifndef RVC_OS_WIN
-//		//linux需翻转图像
-//		Dbg("size = %d, 3*width*height= %d", size, 3 * width * height);
-//		IplImage* pImage = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
-//		memcpy(pImage->imageData, buf, size);
-//		cvFlip(pImage);
-//		//cvSaveImage(".\\jietu_opencv.jpg", pImage);
-//		memcpy(buf, pImage->imageData, size);
-//		cvReleaseImage(&pImage);
-//#endif
+#ifndef RVC_OS_WIN
+		//linux需翻转图像
+		int width = rc.right - rc.left;
+		int height = rc.bottom - rc.top;
+		Dbg("size = %d, 3*width*height= %d", size, 3 * width * height);
+		IplImage* pImage = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
+		memcpy(pImage->imageData, buf, size);
+		cvFlip(pImage);
+		//cvSaveImage(".\\jietu_opencv.jpg", pImage);
+		memcpy(buf, pImage->imageData, size);
+		cvReleaseImage(&pImage);
+#endif
 
 		ChannelService_Send_Info Info;
 		Info.compress = false;
@@ -412,16 +414,18 @@ public:
 			}
 		}
 
-//#ifndef RVC_OS_WIN
-//		//linux需翻转图像
-//		Dbg("size = %d, 3*width*height= %d", size, 3 * width * height);
-//		IplImage* pImage = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
-//		memcpy(pImage->imageData, buf, size);
-//		cvFlip(pImage);
-//		//cvSaveImage(".\\jietu_opencv.jpg", pImage);
-//		memcpy(buf, pImage->imageData, size);
-//		cvReleaseImage(&pImage);
-//#endif
+#ifndef RVC_OS_WIN
+		//linux需翻转图像
+		int width = rc.right - rc.left;
+		int height = rc.bottom - rc.top;
+		Dbg("size = %d, 3*width*height= %d", size, 3 * width * height);
+		IplImage* pImage = cvCreateImage(cvSize(width, height), IPL_DEPTH_8U, 3);
+		memcpy(pImage->imageData, buf, size);
+		cvFlip(pImage);
+		//cvSaveImage(".\\jietu_opencv.jpg", pImage);
+		memcpy(buf, pImage->imageData, size);
+		cvReleaseImage(&pImage);
+#endif
 
 		ChannelService_Send_Info Info;
 		Info.compress = false;

+ 2 - 0
Module/mod_snapshot/CMakeLists.txt

@@ -55,6 +55,8 @@ target_include_directories(${MODULE_NAME} PRIVATE
 	${CONAN_RVCFRAMEWORK_ROOT}/include
     ${MODULE_BASE_DIR}
 	${MODULE_BASE_DIR}/include
+	${CONAN_INCLUDE_DIRS_OPENCV}
+    ${CONAN_INCLUDE_DIRS_OPENCV}/opencv
 	${OTHER_LIB_BASE_DIR}/libvideoqueue
 	${OTHER_LIB_BASE_DIR}/libfacecapture
 	${OTHER_LIB_BASE_DIR}/libvideoframework

+ 12 - 10
Module/mod_snapshot/mod_snapshot.cpp

@@ -17,6 +17,8 @@ using namespace AssistantChannel;
 #include "y2k_time.h"
 #include "EventCode.h"
 #include "CommEntityUtil.hpp"
+#include "cv.h"
+#include "highgui.h"
 
 
 #define LOG_EVT_SELFCHECK_ASSISTANTCHANNEL_IDLE		0x50500001  //协助通道重启
@@ -259,16 +261,16 @@ public:
 			}
 		}
 
-//#ifndef RVC_OS_WIN
-//		//linux需翻转图像
-//		int size = frm->width * frm->height * 3;
-//		IplImage* pImage = cvCreateImage(cvSize(frm->width, frm->height), IPL_DEPTH_8U, 3);
-//		memcpy(pImage->imageData, frm->data[0], size);
-//		cvFlip(pImage);
-//		//cvSaveImage(".\\jietu_opencv.jpg", pImage);
-//		memcpy(frm->data[0], pImage->imageData, size);
-//		cvReleaseImage(&pImage);
-//#endif
+#ifndef RVC_OS_WIN
+		//linux需翻转图像
+		int size = frm->width * frm->height * 3;
+		IplImage* pImage = cvCreateImage(cvSize(frm->width, frm->height), IPL_DEPTH_8U, 3);
+		memcpy(pImage->imageData, frm->data[0], size);
+		cvFlip(pImage);
+		//cvSaveImage(".\\jietu_opencv.jpg", pImage);
+		memcpy(frm->data[0], pImage->imageData, size);
+		cvReleaseImage(&pImage);
+#endif
 
 		jpeg2k_coded_image codec_image = {0};
 		if((rc == 0)||(rc==Error_TimeOut))