You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

496 lines
16 KiB

7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
7 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #include "FSVideoWidget.h"
  2. #include "VideoWidget.h"
  3. #define LOG( X ) m_pLog->Log( "FSVideoWidget", this, X )
  4. #define LOG_ERROR( X ) m_pLog->Log( "FSVideoWidget", this, _LOG_ERROR, X )
  5. FSVideoWidget::FSVideoWidget(QWidget *parent) :
  6. QWidget(parent),
  7. basicMediaDestination(){
  8. m_bGrayScale = false;
  9. m_bEnhanced = false;
  10. m_bDirectDrawing = true;
  11. m_bUpdateIsPending = false;
  12. //setFixedSize( 640, 480 );
  13. setMouseTracking( true );
  14. //grabKeyboard();
  15. //releaseKeyboard();
  16. m_nKeyCode = 0;
  17. m_nOldKeyCode = 0;
  18. m_nManualControlMode = CD_AUTO;
  19. m_pCamera = NULL;
  20. m_pLog = basicLogCollection::getInstance();
  21. m_eStreamAspectRatio = FAR_UNKNOWN;
  22. //m_eWidgetAspectRatio = detectAspectRatio(width(), height());
  23. //setGeometry(m_nPosX, m_nPosY, m_nWidth+1, m_nHeight+1);
  24. //setMinimumSize(QSize(320, 240));
  25. //setSizeIncrement(QSize(20, 20));
  26. //m_backingStore = new QBackingStore( );
  27. //setBackgroundRole(QPalette::Window);
  28. setAutoFillBackground(false);
  29. setAttribute(Qt::WA_OpaquePaintEvent);
  30. setCursor(QCursor(Qt::PointingHandCursor));
  31. //create();
  32. m_pParentViewer = NULL;
  33. m_pPixmap = NULL;
  34. //m_pOverlayPixmap = NULL;
  35. m_pGraber = NULL;
  36. m_mFrame = NULL;
  37. m_mOutput = NULL;
  38. m_pTimer = NULL;
  39. //m_bMouseActive = false;
  40. m_nMouseX = 0;
  41. m_nMouseY = 0;
  42. m_pPropertiesProtectorMutex = new basicMutex();
  43. m_pWidgetProtectorMutex = new basicMutex();
  44. };
  45. void FSVideoWidget::setBindingSize(basicMediaDestination *P, int x, int y){
  46. m_pWidgetProtectorMutex->lock();
  47. m_pParentViewer = P;
  48. setFixedSize(x, y);
  49. m_eWidgetAspectRatio = detectAspectRatio(width(), height());
  50. if (m_pPixmap != NULL) delete m_pPixmap;
  51. m_pPixmap = new QPixmap(width(), height());
  52. m_pPixmap->fill(Qt::black);
  53. m_pWidgetProtectorMutex->unlock();
  54. };
  55. void FSVideoWidget::setCameraControl(basicCamera *C, objectCaps CC){
  56. if (m_pCamera != NULL){
  57. #ifndef NO_PTZ_CAMERAS
  58. if (m_nCameraCaps & OC_PAN_CONTROLL){
  59. if (m_nManualControlMode&CD_LEFT)((basicCameraPTZ *)m_pCamera)->cmdEndManualPan();
  60. if (m_nManualControlMode&CD_RIGHT)((basicCameraPTZ *)m_pCamera)->cmdEndManualPan();
  61. };
  62. if (m_nCameraCaps & OC_TILT_CONTROLL){
  63. if (m_nManualControlMode&CD_UP)((basicCameraPTZ *)m_pCamera)->cmdEndManualTilt();
  64. if (m_nManualControlMode&CD_DOWN)((basicCameraPTZ *)m_pCamera)->cmdEndManualTilt();
  65. };
  66. if (m_nCameraCaps & OC_ZOOM_CONTROLL){
  67. if (m_nManualControlMode&CD_TELE)((basicCameraPTZ *)m_pCamera)->cmdEndManualZoom();
  68. if (m_nManualControlMode&CD_WIDE)((basicCameraPTZ *)m_pCamera)->cmdEndManualZoom();
  69. };
  70. #endif
  71. m_nManualControlMode = CD_AUTO;
  72. };
  73. m_nCameraCaps = CC;
  74. m_pCamera = C;
  75. };
  76. bool FSVideoWidget::event(QEvent *event){
  77. if( event->type() == QEvent::UpdateRequest ){
  78. m_bUpdateIsPending = false;
  79. renderNow();
  80. return true;
  81. }
  82. if (event->type() == QEvent::MouseButtonRelease){
  83. if (((QMouseEvent*)event)->button() == Qt::LeftButton){
  84. if (m_nManualControlMode & CD_MANUAL){
  85. #ifndef NO_PTZ_CAMERAS
  86. if (m_nManualControlMode&(CD_TELE | CD_WIDE)) ((basicCameraPTZ *)m_pCamera)->cmdEndManualZoom();
  87. if (m_nManualControlMode&(CD_UP | CD_DOWN)) ((basicCameraPTZ *)m_pCamera)->cmdEndManualZoom();
  88. if (m_nManualControlMode&(CD_LEFT | CD_RIGHT)) ((basicCameraPTZ *)m_pCamera)->cmdEndManualZoom();
  89. #endif
  90. m_nManualControlMode = CD_AUTO;
  91. }
  92. else{
  93. m_nManualControlMode = CD_MANUAL;
  94. grabKeyboard();
  95. m_nMenuActivityCounter = 75;
  96. };
  97. return true;
  98. };
  99. };
  100. if (event->type() == QEvent::MouseButtonDblClick){
  101. ((VideoWidget *)m_pParentViewer)->hideFullScreen();
  102. return true;
  103. }
  104. if (m_nManualControlMode & CD_MANUAL){
  105. if (event->type() == QEvent::KeyPress){
  106. m_nKeyCode = ((QKeyEvent *)event)->key();
  107. switch (m_nKeyCode){
  108. case 32:
  109. ((VideoWidget *)m_pParentViewer)->hideFullScreen();
  110. break;
  111. case 87://w
  112. if (m_nCameraCaps & OC_ZOOM_CONTROLL){
  113. if ((m_nManualControlMode & CD_TELE) == 0){
  114. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_WIDE));
  115. m_nManualControlMode = (ControlDirection)(m_nManualControlMode | CD_TELE);
  116. #ifndef NO_PTZ_CAMERAS
  117. ((basicCameraPTZ *)m_pCamera)->cmdBeginZoomTele();
  118. #endif
  119. }
  120. else {
  121. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_TELE));
  122. #ifndef NO_PTZ_CAMERAS
  123. ((basicCameraPTZ *)m_pCamera)->cmdEndManualZoom();
  124. #endif
  125. };
  126. m_nMenuActivityCounter = 75;
  127. };
  128. break;
  129. case 65://A
  130. if (m_nCameraCaps & OC_ZOOM_CONTROLL){
  131. if ((m_nManualControlMode & CD_WIDE) == 0){
  132. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_TELE));
  133. m_nManualControlMode = (ControlDirection)(m_nManualControlMode | CD_WIDE);
  134. #ifndef NO_PTZ_CAMERAS
  135. ((basicCameraPTZ *)m_pCamera)->cmdBeginZoomWide();
  136. #endif
  137. }
  138. else {
  139. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_WIDE));
  140. #ifndef NO_PTZ_CAMERAS
  141. ((basicCameraPTZ *)m_pCamera)->cmdEndManualZoom();
  142. #endif
  143. };
  144. m_nMenuActivityCounter = 75;
  145. };
  146. break;
  147. case 0x01000012://Left
  148. if (m_nCameraCaps & OC_PAN_CONTROLL){
  149. if ((m_nManualControlMode & CD_LEFT) == 0){
  150. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_RIGHT));
  151. m_nManualControlMode = (ControlDirection)(m_nManualControlMode | CD_LEFT);
  152. #ifndef NO_PTZ_CAMERAS
  153. ((basicCameraPTZ *)m_pCamera)->cmdBeginPanLeft();
  154. #endif
  155. }
  156. else {
  157. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_LEFT));
  158. #ifndef NO_PTZ_CAMERAS
  159. ((basicCameraPTZ *)m_pCamera)->cmdEndManualPan();
  160. #endif
  161. };
  162. m_nMenuActivityCounter = 75;
  163. };
  164. break;
  165. case 0x01000013://Up
  166. if (m_nCameraCaps & OC_TILT_CONTROLL){
  167. if ((m_nManualControlMode & CD_UP) == 0){
  168. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_DOWN));
  169. m_nManualControlMode = (ControlDirection)(m_nManualControlMode | CD_UP);
  170. #ifndef NO_PTZ_CAMERAS
  171. ((basicCameraPTZ *)m_pCamera)->cmdBeginTiltUp();
  172. #endif
  173. }
  174. else {
  175. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_UP));
  176. #ifndef NO_PTZ_CAMERAS
  177. ((basicCameraPTZ *)m_pCamera)->cmdEndManualTilt();
  178. #endif
  179. };
  180. m_nMenuActivityCounter = 75;
  181. };
  182. break;
  183. case 0x01000014://Right
  184. if (m_nCameraCaps & OC_PAN_CONTROLL){
  185. if ((m_nManualControlMode & CD_RIGHT) == 0){
  186. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_LEFT));
  187. m_nManualControlMode = (ControlDirection)(m_nManualControlMode | CD_RIGHT);
  188. #ifndef NO_PTZ_CAMERAS
  189. ((basicCameraPTZ *)m_pCamera)->cmdBeginPanRight();
  190. #endif
  191. }
  192. else {
  193. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_RIGHT));
  194. #ifndef NO_PTZ_CAMERAS
  195. ((basicCameraPTZ *)m_pCamera)->cmdEndManualPan();
  196. #endif
  197. };
  198. m_nMenuActivityCounter = 75;
  199. };
  200. break;
  201. case 0x01000015://Down
  202. if (m_nCameraCaps & OC_TILT_CONTROLL){
  203. if ((m_nManualControlMode & CD_DOWN) == 0){
  204. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_UP));
  205. m_nManualControlMode = (ControlDirection)(m_nManualControlMode | CD_DOWN);
  206. #ifndef NO_PTZ_CAMERAS
  207. ((basicCameraPTZ *)m_pCamera)->cmdBeginTiltDown();
  208. #endif
  209. }
  210. else {
  211. m_nManualControlMode = (ControlDirection)(m_nManualControlMode & (~CD_DOWN));
  212. #ifndef NO_PTZ_CAMERAS
  213. ((basicCameraPTZ *)m_pCamera)->cmdEndManualTilt();
  214. #endif
  215. };
  216. m_nMenuActivityCounter = 75;
  217. };
  218. break;
  219. };
  220. m_nOldKeyCode = m_nKeyCode;
  221. return true;
  222. };
  223. };
  224. return QWidget::event(event);
  225. }
  226. //! [7]
  227. //! [6]
  228. void FSVideoWidget::renderLater(){
  229. if (!m_bUpdateIsPending) {
  230. m_bUpdateIsPending = true;
  231. QCoreApplication::postEvent(this, new QEvent(QEvent::UpdateRequest));
  232. LOG("Delayed Rendering Request");
  233. }
  234. }
  235. //! [6]
  236. //! [5]
  237. //void VideoWidget::resizeEvent(QResizeEvent *resizeEvent){
  238. // //m_backingStore->resize(resizeEvent->size());
  239. // this->backingStore()->resize(resizeEvent->size());
  240. // if( this->isEnabled() )
  241. // renderNow();
  242. //}
  243. //! [5]
  244. //! [2]
  245. void FSVideoWidget::exposeEvent(QExposeEvent *){
  246. LOG_ERROR("Expose EVT!");
  247. }
  248. //! [2]
  249. void FSVideoWidget::paintEvent(QPaintEvent *evt){
  250. renderNow();
  251. }
  252. //! [3]
  253. void FSVideoWidget::renderNow(){
  254. m_pWidgetProtectorMutex->lock();
  255. try{
  256. if (m_nMenuActivityCounter)m_nMenuActivityCounter--;
  257. else if (m_nManualControlMode & CD_MANUAL){
  258. m_nManualControlMode = CD_AUTO;
  259. releaseKeyboard();
  260. };
  261. QPainter painter(this);
  262. //painter.setRenderHint(QPainter::Antialiasing);
  263. painter.setRenderHint((QPainter::RenderHint)7);// QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing
  264. //if( !painter.isActive() ) painter.begin(this);
  265. render(&painter);
  266. //if (pa inter.isActive()) painter.end();
  267. }catch (std::exception& e){
  268. LOG_ERROR("RenderNow exception!");
  269. };
  270. m_pWidgetProtectorMutex->unlock();
  271. }
  272. //! [3]
  273. //! [4]
  274. void FSVideoWidget::render(QPainter *painter){
  275. if( painter != NULL ){
  276. try{
  277. char buffer[64];
  278. sprintf(buffer, "Coords: %d %d Key: %d", m_nMouseX, m_nMouseY, m_nKeyCode);
  279. painter->save();
  280. painter->drawPixmap(QRect(0, 0, width(), height()), *m_pPixmap);
  281. QPen BgPen(Qt::SolidPattern, 2);
  282. BgPen.setColor(Qt::black);
  283. QPen FgPen(Qt::SolidPattern, 0);
  284. FgPen.setColor(Qt::yellow);
  285. painter->setPen(BgPen);
  286. painter->drawText(QRect(0, 0, width(), height()), Qt::AlignHCenter | Qt::AlignBaseline, buffer);
  287. painter->setPen(FgPen);
  288. painter->drawText(QRect(0, 0, width(), height()), Qt::AlignHCenter | Qt::AlignBaseline, buffer);
  289. if (m_pCamera != NULL){
  290. if (m_nManualControlMode & CD_MANUAL){
  291. QRect ManualRect(10, height() - m_pManualMode->height() - 10, m_pManualMode->width(), m_pManualMode->height());
  292. if (m_nCameraCaps & OC_TILT_CONTROLL){
  293. QRect UpRect(
  294. (width() - m_pPixUp->width()) / 2,
  295. (height() / 2) - m_pPixUp->height() - 10,
  296. m_pPixUp->width(),
  297. m_pPixUp->height());
  298. QRect DownRect(
  299. (width() - m_pPixDown->width()) / 2,
  300. (height() / 2) + 10,
  301. m_pPixDown->width(),
  302. m_pPixDown->height());
  303. if (m_nManualControlMode & CD_UP) {
  304. painter->fillRect(UpRect, QColor(255, 255, 255, 63));
  305. }
  306. else {
  307. painter->drawRect(UpRect);
  308. };
  309. if (m_nManualControlMode & CD_DOWN){
  310. painter->fillRect(DownRect, QColor(255, 255, 255, 63));
  311. }
  312. else {
  313. painter->drawRect(DownRect);
  314. };
  315. painter->drawPixmap(UpRect, *m_pPixUp);
  316. painter->drawPixmap(DownRect, *m_pPixDown);
  317. };
  318. if (m_nCameraCaps & OC_PAN_CONTROLL){
  319. QRect LeftRect(
  320. (width() / 2) - m_pPixLeft->width() - 10 - (m_pPixLeft->width() / 2),
  321. (height() / 2) - (m_pPixLeft->height() / 2),
  322. m_pPixLeft->width(),
  323. m_pPixLeft->height());
  324. QRect RightRect(
  325. (width() / 2) + 10 + (m_pPixRight->width() / 2),
  326. (height() / 2) - (m_pPixRight->height() / 2),
  327. m_pPixRight->width(),
  328. m_pPixRight->height());
  329. if (m_nManualControlMode & CD_RIGHT){
  330. painter->fillRect(RightRect, QColor(255, 255, 255, 63));
  331. }
  332. else {
  333. painter->drawRect(RightRect);
  334. };
  335. if (m_nManualControlMode & CD_LEFT){
  336. painter->fillRect(LeftRect, QColor(255, 255, 255, 63));
  337. }
  338. else {
  339. painter->drawRect(LeftRect);
  340. };
  341. painter->drawPixmap(LeftRect, *m_pPixLeft);
  342. painter->drawPixmap(RightRect, *m_pPixRight);
  343. };
  344. if (m_nCameraCaps & OC_ZOOM_CONTROLL){
  345. QRect WideRect(
  346. 25,
  347. 25,
  348. m_pManualMode->width(),
  349. m_pManualMode->height());
  350. QRect TeleRect(
  351. width() - m_pPixTele->height() - 25,
  352. 25,
  353. m_pPixTele->width(),
  354. m_pPixTele->height());
  355. if (m_nManualControlMode & CD_WIDE){
  356. painter->fillRect(WideRect, QColor(255, 255, 255, 63));
  357. }
  358. else {
  359. painter->drawRect(WideRect);
  360. };
  361. if (m_nManualControlMode & CD_TELE){
  362. painter->fillRect(TeleRect, QColor(255, 255, 255, 63));
  363. }
  364. else {
  365. painter->drawRect(TeleRect);
  366. };
  367. painter->drawPixmap(WideRect, *m_pPixWide);
  368. painter->drawPixmap(TeleRect, *m_pPixTele);
  369. };
  370. painter->fillRect(ManualRect, QColor(255, 255, 255, 63));
  371. painter->drawPixmap(ManualRect, *m_pManualMode);
  372. };
  373. };
  374. //char buffer[64];
  375. //sprintf(buffer, "Coords: %dx%d %d %d ? %d %d", pos().x(), pos().y(), width(), height(), m_nMouseX, m_nMouseY);
  376. //painter->save();
  377. //painter->fillRect(QRect(0, 0, width(), height()), Qt::green);
  378. //int x, y;
  379. //x = width();
  380. //y = height();
  381. //painter->drawPixmap(QRect(0, 0, width(), height()), *m_pPixmap);
  382. //QPen BgPen(Qt::SolidPattern,2);
  383. //BgPen.setColor(Qt::black);
  384. //QPen FgPen(Qt::SolidPattern,0);
  385. //FgPen.setColor(Qt::yellow);
  386. //painter->setPen(BgPen);
  387. //painter->drawText(QRect(0, 0, width(), height()), Qt::AlignHCenter | Qt::AlignBaseline, buffer);
  388. //painter->setPen(FgPen);
  389. //painter->drawText(QRect(0, 0, width(), height()), Qt::AlignHCenter | Qt::AlignBaseline , buffer);
  390. painter->restore();
  391. }catch (std::exception& e){
  392. LOG_ERROR("Render exception!");
  393. };
  394. };
  395. }
  396. bool FSVideoWidget::init( void ){
  397. LOG("init.");
  398. m_pPixmap = new QPixmap(width(), height()); //, QImage::Format_RGB888 );
  399. if( m_pPixmap==NULL ) return false;
  400. //m_pOverlayPixmap = new QPixmap("640x480.png", "PNG");
  401. m_pManualMode = new QPixmap(":pictures/appbar.controller.snes.png", "PNG");
  402. m_pPixUp = new QPixmap(":pictures/appbar.chevron.up.png", "PNG");
  403. m_pPixDown = new QPixmap(":pictures/appbar.chevron.down.png", "PNG");
  404. m_pPixLeft = new QPixmap(":pictures/appbar.chevron.left.png", "PNG");
  405. m_pPixRight = new QPixmap(":pictures/appbar.chevron.right.png", "PNG");
  406. m_pPixWide = new QPixmap(":pictures/appbar.arrow.expand.png", "PNG");
  407. m_pPixTele = new QPixmap(":pictures/appbar.arrow.collapsed.png", "PNG");
  408. m_pTimer = new QTimer();
  409. if (m_pTimer != NULL){
  410. connect(m_pTimer, SIGNAL(timeout()), this, SLOT(update()));
  411. m_pTimer->start(40);
  412. };
  413. m_eWidgetAspectRatio = detectAspectRatio(width(), height());
  414. m_pPixmap->fill(Qt::black);
  415. m_pPropertiesProtectorMutex->lock();
  416. m_pPropertiesProtectorMutex->unlock();
  417. return false;
  418. };
  419. FSVideoWidget::~FSVideoWidget(){
  420. if (m_pCamera)m_pCamera->setViewer(NULL);
  421. if (m_pTimer)m_pTimer->stop();
  422. delete( m_pPropertiesProtectorMutex );
  423. delete( m_pWidgetProtectorMutex );
  424. };
  425. void FSVideoWidget::setGrayScale( bool AAA ){
  426. m_pPropertiesProtectorMutex->lock();
  427. m_bGrayScale = AAA;
  428. m_pPropertiesProtectorMutex->unlock();
  429. LOG("GRAYSCALE");
  430. };
  431. void FSVideoWidget::setEnhanced( bool AAA ){
  432. m_pPropertiesProtectorMutex->lock();
  433. m_bEnhanced = AAA;
  434. m_pPropertiesProtectorMutex->unlock();
  435. LOG("ENHANCED");
  436. };
  437. void FSVideoWidget::pushFrame(cv::Mat *Frame, void *src){
  438. if( Frame != NULL ){
  439. try{
  440. m_pWidgetProtectorMutex->lock();
  441. m_mOutput = Frame;
  442. assert(m_mOutput->isContinuous());
  443. m_eStreamAspectRatio = detectAspectRatio(Frame->cols, Frame->rows);
  444. QPainter dbPainter(m_pPixmap);
  445. if (m_eStreamAspectRatio != m_eWidgetAspectRatio){
  446. int tOffset;
  447. if (m_eStreamAspectRatio > m_eWidgetAspectRatio){
  448. int tHeight;
  449. tHeight = (int)((float)m_pPixmap->width() / m_eStreamAspectRatio);
  450. tOffset = (m_pPixmap->height() - tHeight) >> 1;
  451. dbPainter.drawImage(QRect(0, tOffset, width(), tHeight ),
  452. QImage((unsigned char*)m_mOutput->data, m_mOutput->cols, m_mOutput->rows, QImage::Format_RGB888),
  453. QRect(0, 0, m_mOutput->cols, m_mOutput->rows ));
  454. } else {
  455. int tWidth;
  456. tWidth = (int)((float)m_pPixmap->height() * m_eStreamAspectRatio);
  457. tOffset = (m_pPixmap->width() - tWidth) >> 1;
  458. dbPainter.drawImage(QRect(tOffset, 0, tWidth, height()),
  459. QImage((unsigned char*)m_mOutput->data, m_mOutput->cols, m_mOutput->rows, QImage::Format_RGB888),
  460. QRect(0, 0, m_mOutput->cols, m_mOutput->rows));
  461. };
  462. } else {
  463. dbPainter.drawImage(QRect(0, 0, width(), height()), QImage((unsigned char*)m_mOutput->data, m_mOutput->cols, m_mOutput->rows, QImage::Format_RGB888), QRect(0, 0, m_mOutput->cols, m_mOutput->rows));
  464. };
  465. m_pWidgetProtectorMutex->unlock();
  466. } catch (std::exception& e){
  467. LOG_ERROR("Exception catched:");
  468. LOG_ERROR(e.what());
  469. };
  470. m_pPropertiesProtectorMutex->unlock();
  471. //delete(Frame);
  472. };
  473. };
  474. #undef LOG
  475. #undef LOG_ERROR