我們一直在處理OpenCV兩週,使其在Android上運行。 您知道我們在哪裏可以找到Android光流實施?如果使用OpenCV實現它將會很好。Android中的光流量
2
A
回答
0
0
試試這個
@覆蓋 公共墊onCameraFrame(CvCameraViewFrame inputFrame){
mRgba = inputFrame.rgba();
if (mMOP2fptsPrev.rows() == 0) {
//Log.d("Baz", "First time opflow");
// first time through the loop so we need prev and this mats
// plus prev points
// get this mat
Imgproc.cvtColor(mRgba, matOpFlowThis, Imgproc.COLOR_RGBA2GRAY);
// copy that to prev mat
matOpFlowThis.copyTo(matOpFlowPrev);
// get prev corners
Imgproc.goodFeaturesToTrack(matOpFlowPrev, MOPcorners, iGFFTMax, 0.05, 20);
mMOP2fptsPrev.fromArray(MOPcorners.toArray());
// get safe copy of this corners
mMOP2fptsPrev.copyTo(mMOP2fptsSafe);
}
else
{
//Log.d("Baz", "Opflow");
// we've been through before so
// this mat is valid. Copy it to prev mat
matOpFlowThis.copyTo(matOpFlowPrev);
// get this mat
Imgproc.cvtColor(mRgba, matOpFlowThis, Imgproc.COLOR_RGBA2GRAY);
// get the corners for this mat
Imgproc.goodFeaturesToTrack(matOpFlowThis, MOPcorners, iGFFTMax, 0.05, 20);
mMOP2fptsThis.fromArray(MOPcorners.toArray());
// retrieve the corners from the prev mat
// (saves calculating them again)
mMOP2fptsSafe.copyTo(mMOP2fptsPrev);
// and save this corners for next time through
mMOP2fptsThis.copyTo(mMOP2fptsSafe);
}
/*
Parameters:
prevImg first 8-bit input image
nextImg second input image
prevPts vector of 2D points for which the flow needs to be found; point coordinates must be single-precision floating-point numbers.
nextPts output vector of 2D points (with single-precision floating-point coordinates) containing the calculated new positions of input features in the second image; when OPTFLOW_USE_INITIAL_FLOW flag is passed, the vector must have the same size as in the input.
status output status vector (of unsigned chars); each element of the vector is set to 1 if the flow for the corresponding features has been found, otherwise, it is set to 0.
err output vector of errors; each element of the vector is set to an error for the corresponding feature, type of the error measure can be set in flags parameter; if the flow wasn't found then the error is not defined (use the status parameter to find such cases).
*/
Video.calcOpticalFlowPyrLK(matOpFlowPrev, matOpFlowThis, mMOP2fptsPrev, mMOP2fptsThis, mMOBStatus, mMOFerr);
cornersPrev = mMOP2fptsPrev.toList();
cornersThis = mMOP2fptsThis.toList();
byteStatus = mMOBStatus.toList();
y = byteStatus.size() - 1;
for (x = 0; x < y; x++) {
if (byteStatus.get(x) == 1) {
pt = cornersThis.get(x);
pt2 = cornersPrev.get(x);
Core.circle(mRgba, pt, 5, colorRed, iLineThickness - 1);
Core.line(mRgba, pt, pt2, colorRed, iLineThickness);
}
}
return mRgba;
}
0
了openFrameworks已經在openCV中出爐了,還有很多其他的有趣的庫。它有一個非常優雅的結構,我已經用它與android使用相機的運動估計來製作手機的虛擬鼠標。
查看端口這裏http://openframeworks.cc/setup/android-studio/
看來Android他們最近增加了對Android的支持工作室,否則蝕偉大的作品。
相關問題
- 1. 在Android中測量光線
- 2. 光學流量與哈爾級聯
- 3. android中的背光
- 4. 實時光流
- 5. 水上光流
- 6. 如何在OpenCV Python中查找實時視頻流(Android IPWebcam)的光流?
- 7. 相當於3D光流的場景流?
- 8. 如何從密集光流中提取速度矢量?
- 9. 基於光流的分割
- 10. 光流的簡單情況
- 11. OpenCV繪製ROI中的Farneback光流。
- 12. 流星光纖中運行與setTimeout的
- 13. Android中的背光操作
- 14. android - 檢測流量變化
- 15. 監視android的TLS流量的方法
- 16. 我的Javascript/Html流量燈光序列需要一個循環
- 17. 製作「發光」 Android Studio中的矢量圖像
- 18. LK在iOS或Android上使用OpenGL ES的光流
- 19. 的Android Startmanaging光標
- 20. eclipse監控android的網絡流量
- 21. 平滑流支持閃光?
- 22. 重用流光對象
- 23. 如何使用流光
- 24. Horn-Schunck光流計算
- 25. 光流測試模式
- 26. OpenCV密集光流矩陣
- 27. 盧卡斯卡納德光學流向,方向矢量
- 28. 跟蹤是否意味着連接光流向量?
- 29. 如何在android中給光標留出餘量?
- 30. 無法在mac上爲android創建流光標教程