您好,登錄后才能下訂單哦!
這篇文章將為大家詳細講解有關Qt如何實現視頻監控畫面,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
視頻監控系統在整個安防領域,已經做到了爛大街的程序,全國起碼幾百家公司做過類似的系統,當然這一方面的需求量也是非常旺盛的,各種定制化的需求越來越多,尤其是這幾年借著人臉識別的東風,發展更加迅猛,人臉識別相關的技術和應用這幾年處于風口浪尖,衍生了特別多的應用產品,各種人臉識別的產品遍地開花,刷臉門禁,車站機場人臉識別,刷臉取票等,但是其實大部分內行人士可能都比較絕望,外行感覺像看科幻片一樣,老板們各種打雞血,今天幾個億明天幾個億。
縱觀Qt的應用場景領域,在國內,基本上在安防、航天船舶、教育、工業控制領域,占有比較大的比例,其實個人非常喜愛Qt的,從沒見過如此完美的API封裝,包括命名,最牛逼的就是跨平臺特性,可以說完爆.NET的跨平臺,甚至連那種幾十兆的嵌入式linux版本都能運行,這就使得成本大大降低,提高了產品的豐富性。自從用了Qt以后,就再也不想用VC/VB/C#等。
視頻監控畫面在任何視頻監控系統中是少不了的一個功能,基本上是需要1畫面、4畫面、6畫面、8畫面、9畫面、16畫面等,Qt提供的表格布局非常勝任這個工作,網上幾乎沒有看到qt做的最基礎的視頻監控畫面分割的demo,今天特意花幾分鐘提取出來,開源放出來。歡迎大家多多點贊!現在還增加了25畫面、36畫面,里邊的函數封裝的很好,稍微加幾行可以直接增加49畫面等其他的。
void VideoPanel::change_video(int index, int flag) { int count = 0; int row = 0; int column = 0; for (int i = 0; i < videoCount; i++) { if (i >= index) { gridLayout->addWidget(widgets.at(i), row, column); widgets.at(i)->setVisible(true); count++; column++; if (column == flag) { row++; column = 0; } } if (count == (flag * flag)) { break; } } } void VideoPanel::change_video_4(int index) { hide_video_all(); change_video(index, 2); } void VideoPanel::change_video_6(int index) { hide_video_all(); if (index == 0) { gridLayout->addWidget(widgets.at(0), 0, 0, 2, 2); gridLayout->addWidget(widgets.at(1), 0, 2, 1, 1); gridLayout->addWidget(widgets.at(2), 1, 2, 1, 1); gridLayout->addWidget(widgets.at(3), 2, 2, 1, 1); gridLayout->addWidget(widgets.at(4), 2, 1, 1, 1); gridLayout->addWidget(widgets.at(5), 2, 0, 1, 1); for (int i = 0; i < 6; i++) { widgets.at(i)->setVisible(true); } } else if (index == 5) { gridLayout->addWidget(widgets.at(5), 0, 0, 2, 2); gridLayout->addWidget(widgets.at(6), 0, 2, 1, 1); gridLayout->addWidget(widgets.at(7), 1, 2, 1, 1); gridLayout->addWidget(widgets.at(8), 2, 2, 1, 1); gridLayout->addWidget(widgets.at(9), 2, 1, 1, 1); gridLayout->addWidget(widgets.at(10), 2, 0, 1, 1); for (int i = 5; i < 11; i++) { widgets.at(i)->setVisible(true); } } else if (index == 10) { gridLayout->addWidget(widgets.at(10), 0, 0, 2, 2); gridLayout->addWidget(widgets.at(11), 0, 2, 1, 1); gridLayout->addWidget(widgets.at(12), 1, 2, 1, 1); gridLayout->addWidget(widgets.at(13), 2, 2, 1, 1); gridLayout->addWidget(widgets.at(14), 2, 1, 1, 1); gridLayout->addWidget(widgets.at(15), 2, 0, 1, 1); for (int i = 10; i < 16; i++) { widgets.at(i)->setVisible(true); } } } void VideoPanel::change_video_8(int index) { hide_video_all(); if (index == 0) { gridLayout->addWidget(widgets.at(0), 0, 0, 3, 3); gridLayout->addWidget(widgets.at(1), 0, 3, 1, 1); gridLayout->addWidget(widgets.at(2), 1, 3, 1, 1); gridLayout->addWidget(widgets.at(3), 2, 3, 1, 1); gridLayout->addWidget(widgets.at(4), 3, 3, 1, 1); gridLayout->addWidget(widgets.at(5), 3, 2, 1, 1); gridLayout->addWidget(widgets.at(6), 3, 1, 1, 1); gridLayout->addWidget(widgets.at(7), 3, 0, 1, 1); for (int i = 0; i < 8; i++) { widgets.at(i)->setVisible(true); } } else if (index == 8) { gridLayout->addWidget(widgets.at(8), 0, 0, 3, 3); gridLayout->addWidget(widgets.at(9), 0, 3, 1, 1); gridLayout->addWidget(widgets.at(10), 1, 3, 1, 1); gridLayout->addWidget(widgets.at(11), 2, 3, 1, 1); gridLayout->addWidget(widgets.at(12), 3, 3, 1, 1); gridLayout->addWidget(widgets.at(13), 3, 2, 1, 1); gridLayout->addWidget(widgets.at(14), 3, 1, 1, 1); gridLayout->addWidget(widgets.at(15), 3, 0, 1, 1); for (int i = 8; i < 16; i++) { widgets.at(i)->setVisible(true); } } } void VideoPanel::change_video_9(int index) { hide_video_all(); change_video(index, 3); } void VideoPanel::change_video_13(int index) { hide_video_all(); if (index == 0) { gridLayout->addWidget(widgets.at(0), 0, 0, 1, 1); gridLayout->addWidget(widgets.at(1), 0, 1, 1, 1); gridLayout->addWidget(widgets.at(2), 0, 2, 1, 1); gridLayout->addWidget(widgets.at(3), 0, 3, 1, 1); gridLayout->addWidget(widgets.at(4), 1, 0, 1, 1); gridLayout->addWidget(widgets.at(5), 2, 0, 1, 1); gridLayout->addWidget(widgets.at(6), 1, 1, 2, 2); gridLayout->addWidget(widgets.at(7), 1, 3, 1, 1); gridLayout->addWidget(widgets.at(8), 2, 3, 1, 1); gridLayout->addWidget(widgets.at(9), 3, 0, 1, 1); gridLayout->addWidget(widgets.at(10), 3, 1, 1, 1); gridLayout->addWidget(widgets.at(11), 3, 2, 1, 1); gridLayout->addWidget(widgets.at(12), 3, 3, 1, 1); for (int i = 0; i < 13; i++) { widgets.at(i)->setVisible(true); } } else if (index == 3) { gridLayout->addWidget(widgets.at(3), 0, 0, 1, 1); gridLayout->addWidget(widgets.at(4), 0, 1, 1, 1); gridLayout->addWidget(widgets.at(5), 0, 2, 1, 1); gridLayout->addWidget(widgets.at(6), 0, 3, 1, 1); gridLayout->addWidget(widgets.at(7), 1, 0, 1, 1); gridLayout->addWidget(widgets.at(8), 2, 0, 1, 1); gridLayout->addWidget(widgets.at(9), 1, 1, 2, 2); gridLayout->addWidget(widgets.at(10), 1, 3, 1, 1); gridLayout->addWidget(widgets.at(11), 2, 3, 1, 1); gridLayout->addWidget(widgets.at(12), 3, 0, 1, 1); gridLayout->addWidget(widgets.at(13), 3, 1, 1, 1); gridLayout->addWidget(widgets.at(14), 3, 2, 1, 1); gridLayout->addWidget(widgets.at(15), 3, 3, 1, 1); for (int i = 3; i < 16; i++) { widgets.at(i)->setVisible(true); } } } void VideoPanel::change_video_16(int index) { hide_video_all(); change_video(index, 4); } void VideoPanel::change_video_25(int index) { hide_video_all(); change_video(index, 5); } void VideoPanel::change_video_36(int index) { hide_video_all(); change_video(index, 6); } void VideoPanel::change_video_64(int index) { hide_video_all(); change_video(index, 8); }
關于“Qt如何實現視頻監控畫面”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。