发送彩色视频RGB888时,在上位机,通过BGR2BGR565转换为16位数据,再传输时加上行号,在DMA里也要对读出的数据进行高低位的变换,组成RGB565格式
如下图所示,在灰度图时将每帧刷新改为了每一行刷新,这是因为在彩色图像时,刷新一帧的时间大于2ms,而灰度时为0.7ms,这就会导致在刷新的时候,新的数据已经在发送了,所以图像会出错,
在改为每行刷新时,由于每行的接收也很快,所以如果带宽变大,也会导致接收问题。是否可以使用ACP口进行通信,直接进行硬件上的缓存一致性处理?
1 void MainWindow::on_OpenImage_triggered() 2 { 3 QString path; 4 5 path = OpenImage(); 6 7 if (path.length() > 0) 8 { 9 src_image = imread(path.toStdString(),-1); 10 11 if (src_image.channels() == 3) 12 { 13 cvtColor(src_image, bgr565_image, CV_BGR2BGR565); //RGB888转BGR565 14 } 15 16 cv::resize(src_image, scale_image, Size(img_w_size, img_h_size), 0, 0, INTER_LINEAR); 17 18 dis_image = MatImageToQt(scale_image); 19 pixmap = QPixmap::fromImage(dis_image); 20 ui.img_map->setPixmap(pixmap); 21 22 img_width = src_image.cols; 23 img_height = src_image.rows; 24 25 ui.img_w->setText(QString::number(img_width)); 26 ui.img_h->setText(QString::number(img_height)); 27 28 ui.prog_bar->setRange(0, 1); 29 ui.prog_bar->setValue(0); 30 } 31 }
1 void udpthread::run() 2 { 3 while (!stopped) 4 { 5 if (send_flag == 1) 6 { 7 for (int i = 0; i < pkg_num; i++) 8 { 9 memcpy(send_buf, &i, 4); 10 memcpy(send_buf+4, send_image.data + i*pkg_size, pkg_size); 11 send(hClient, (const char*)send_buf, pkg_size+4, 0); 12 } 13 14 head_buf[0] = 0xA0A1A2F0; 15 head_buf[1] = img_index; 16 17 send(hClient, (const char*)head_buf, 8, 0); 18 19 send_flag = 0; 20 } 21 } 22 }
标签:src,udp,img,image,send,发送,上位,buf,size From: https://www.cnblogs.com/tuzki9611/p/17610709.html