簡體   English   中英

將Mat圖像轉換為更大的Mat圖像Opencv

[英]Transposing a Mat image into a larger Mat image, Opencv

我編寫了一個函數,可以將Mat圖像放入其中,並將其轉置到空白圖像中心的三倍大小。 我已經編寫了這樣做的功能,但是我認為可以在效率方面進行改進。

void transposeFrame( cv::Mat &frame){

   Mat new_frame( frame.rows * 3, frame.cols * 3, CV_8UC3, Scalar(0,0,255));

   Rect dim = Rect( frame.rows, frame.cols, frame.rows * 2, frame.cols * 2);

   Mat subview = new_frame(dim);

   frame.copyTo(subview);
   frame = subview;
}

有更好的執行此操作的方法嗎?

我會用類似:-

Mat frame_tpsed;
cv::Mat::transpose(frame, frame_tpsed);
new_frame(Rect(frame.rows, frame.cols, frame.rows*2, frame.cols*2))  = frame_tpsed

在opencvDocs上轉置: http ://docs.opencv.org/modules/core/doc/operations_on_arrays.html#void transpose(InputArray src,OutputArray dst)

沒有嘗試。 忘了提。

您可以使用copyMakeBorder函數。 但是,我認為它的運行速度不會很快。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM