例如,我有這個簡單的功能,但我想讓它更緊湊,你有什么建議嗎?
VideoCapture camera = VideoCapture(0);
cv::Mat& OpenCvCamera::getFrame()
{
Mat frame;
camera >> frame;
return frame;
}
我想在不使用臨時變數“frame”的情況下使其行內。
可能嗎?
uj5u.com熱心網友回復:
看起來您想隱藏 VideoCapture 物件的存在。如果是這樣,就只做它。即只需包裝 VideoCapture::read()。不需要其他更改。
//This object is invisible from the function user.
VideoCapture camera = VideoCapture(0);
//Type of this function (argument and return) is same as VideoCapture::read().
bool OpenCvCamera::getFrame( cv::Mat &frame )
{ return camera.read( frame ); }
uj5u.com熱心網友回復:
cv::VideoCapture::read可能是您正在尋找的。
允許您擺脫整個getFrame()功能:
VideoCapture camera = VideoCapture(0);
cv::Mat frame;
camera.read(frame);
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/514996.html
標籤:C opencv
上一篇:錯誤:(-215:斷言失敗)!函式CV2錯誤中的empty()
下一篇:OpenCV檢測哪些引腳彎曲
