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