Did you have a chance to play with it on Raspberry Pi?
Yes of course ! For know I use it in order to register 2 images in mechanics (we call it Digital Image Correlation (DIC)). Once the flow is computed, we project it on projective tranformation in order to drive an experimental tensile test from a raspberry pi !
The raspberry pi process to build and control tensile test machine is not published yet, but we've done it using
CRAPPy our laboratory software platform to control experiment.
You can try it on RPi with this
program
I'm curious about the performance of this approach. If you have a kind of tutorial (or can do a draft one) - this will be great!
You can try with this code
Code: Select all
import cv2
# Set DISFLOW parameters
DIS = cv2.DISOpticalFlow_create()
DIS.setFinestScale(0)
DIS.setPatchStride(1)
DIS.setPatchSize(2)
DIS.setGradientDescentIterations(10)
DIS.setVariationalRefinementIterations(5)
DIS.setVariationalRefinementDelta(1)
DIS.setVariationalRefinementGamma(0)
DIS.setVariationalRefinementAlpha(3)
# Load images for test purpose
img_left = cv2.imread("My_left_camera_image",0)
img_right = cv2.imread("My_right_camera_image",0)
flow = DIS.calc(img_left,img_right,None)
# Extract the the good component of your rectified image 0 or 1
disparity_map=flow[::,::,1]
What a misunderstanding ! I didn't talk about your code, but the StereoBM of OpenCV that is quite outdated in the image registration field ! Sorry for that !
It is one of the most optimized algo prior to the DeepLearning ones.
You can trade the accuracy for speed, tuning the parameter I give you.
If you want something very fast you can set :
Code: Select all
DIS.setFinestScale(1) # or even 2 !
DIS.setVariationalRefinementIterations(0)
if you want Variational improvement you have to increase
Code: Select all
DIS.setVariationalRefinementIterations(15) # ! it can increase the loop time drasticly
If you want a smooth field you can increase the alpha parameter in variational refinement
Code: Select all
DIS.setVariationalRefinementAlpha(20)
it will lead you to a gradient between the foreground and the background ... It should be balanced on each scene, but the first parameters should be good enough ...
If img_left is far from img_right, you can initialize with a flow that come from stereoBM (you can pad the vertical displacement with 0 or RBT ).
Is it clear enough ?