這篇文章將為大家詳細(xì)講解有關(guān)Qt如何實(shí)現(xiàn)視頻監(jiān)控畫面,小編覺得挺實(shí)用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
目前創(chuàng)新互聯(lián)公司已為數(shù)千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管運(yùn)營、企業(yè)網(wǎng)站設(shè)計(jì)、修文網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
視頻監(jiān)控系統(tǒng)在整個安防領(lǐng)域,已經(jīng)做到了爛大街的程序,全國起碼幾百家公司做過類似的系統(tǒng),當(dāng)然這一方面的需求量也是非常旺盛的,各種定制化的需求越來越多,尤其是這幾年借著人臉識別的東風(fēng),發(fā)展更加迅猛,人臉識別相關(guān)的技術(shù)和應(yīng)用這幾年處于風(fēng)口浪尖,衍生了特別多的應(yīng)用產(chǎn)品,各種人臉識別的產(chǎn)品遍地開花,刷臉門禁,車站機(jī)場人臉識別,刷臉取票等,但是其實(shí)大部分內(nèi)行人士可能都比較絕望,外行感覺像看科幻片一樣,老板們各種打雞血,今天幾個億明天幾個億。
縱觀Qt的應(yīng)用場景領(lǐng)域,在國內(nèi),基本上在安防、航天船舶、教育、工業(yè)控制領(lǐng)域,占有比較大的比例,其實(shí)個人非常喜愛Qt的,從沒見過如此完美的API封裝,包括命名,最牛逼的就是跨平臺特性,可以說完爆.NET的跨平臺,甚至連那種幾十兆的嵌入式linux版本都能運(yùn)行,這就使得成本大大降低,提高了產(chǎn)品的豐富性。自從用了Qt以后,就再也不想用VC/VB/C#等。
視頻監(jiān)控畫面在任何視頻監(jiān)控系統(tǒng)中是少不了的一個功能,基本上是需要1畫面、4畫面、6畫面、8畫面、9畫面、16畫面等,Qt提供的表格布局非常勝任這個工作,網(wǎng)上幾乎沒有看到qt做的最基礎(chǔ)的視頻監(jiān)控畫面分割的demo,今天特意花幾分鐘提取出來,開源放出來。歡迎大家多多點(diǎn)贊!現(xiàn)在還增加了25畫面、36畫面,里邊的函數(shù)封裝的很好,稍微加幾行可以直接增加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); }
關(guān)于“Qt如何實(shí)現(xiàn)視頻監(jiān)控畫面”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,使各位可以學(xué)到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。