The configuration of the development board is low, the face interface display control is stuck, and the same as using OpenGL, is there a solution
-
Because I tried OpenGL and found that the difference is very small, the OpenGL module has been removed, and it is judged that it should be because the graphics card of the device is too poor.
Here's the interface display code.void ThreadGetCamPic::run() { bool ret = stVideoCaptrue.open(0); Mat matTemp; QImage img; m_bStop = false; while(!m_bStop){ stVideoCaptrue->matTemp; if(matTemp.empty()){ msleep(50); continue; } img = QImage(matTemp.data,matTemp.cols,matTemp.rows,matTemp.step,QImage::Format_RGB888).copy(); img = convertRGB888toBGR888UsingOpenCV(img); emit sigSendCurImg(img); } } QImage ThreadGetCamPic::convertRGB888toBGR888UsingOpenCV(const QImage &rgbImage) { cv::Mat cvImage(rgbImage.height(), rgbImage.width(), CV_8UC3, (void*)rgbImage.bits(), rgbImage.bytesPerLine()); cv::cvtColor(cvImage, cvImage, cv::COLOR_RGB2BGR); QImage bgrImage(cvImage.data, cvImage.cols, cvImage.rows, cvImage.step, QImage::Format_RGB888); return bgrImage; }
connect(&m_stThreadGetCamPic,&ThreadGetCamPic::sigSendCurImg,this,&Widget::OnFreshCurImg); "other code"
void Widget::OnFreshCurImg(const QImage &img) { m_imgSrc = img.copy(); m_img2Show = m_imgSrc.scaled(ui->campic_label->size(),Qt::KeepAspectRatioByExpanding,Qt::SmoothTransformation); m_pix2Show = QPixmap::fromImage(m_img2Show); ui->campic_label->setPixmap(m_pix2Show); }
-
Hi,
What kind of device is that ?
How did you try to use OpenGL ?
Did you consider using Qt Multimedia to get images from the camera ? -
Also, what are the camera specifications ?
-
I'm very sorry that I've been busy before.,So I didn't come back to reply.,Then I've found the problem.,Now I'm back to answer the question I hope it can help you.,The main reason is that the default frame rate of my device's camera is the lowest, resulting in the number of frames being too low to cause Caton.,So I increased the number of frames to get it solved.
void ThreadGetCamPic::run() { bool ret = stVideoCaptrue.open(0); //The code in the horizontal line is currently known to be only valid for the RK35xx series cameras, if there is a problem with the camera turned on, it should be here, just comment it out, and it is also the reason to solve the freeze of the camera acquisition screen /*---------------------------------------------------------------------------------*/ // stVideoCaptrue.set(cv::CAP_PROP_FRAME_WIDTH, 800); // stVideoCaptrue.set(cv::CAP_PROP_FRAME_HEIGHT, 600); // stVideoCaptrue.set(cv::CAP_PROP_FPS, 20); /*---------------------------------------------------------------------------------*/ Mat matTemp; // QImage img; m_bStop = false; while(!m_bStop){ stVideoCaptrue>>matTemp; if(matTemp.empty()){ msleep(50); continue; } img = QImage(matTemp.data,matTemp.cols,matTemp.rows,matTemp.step,QImage::Format_RGB888).copy(); img = convertRGB888toBGR888UsingOpenCV(img); emit sigSendCurImg(img); } }
-