Ask Your Question

Reduce Blurring/Warping of image after repeated warpAffine

asked 2018-10-08 08:59:39 -0500

My code uses input from a rotary encoder connected to a Rapsberry Pi send over TCP:

num_rows, num_cols = img.shape[:2]   

data = s.recv(BUFFER_SIZE)
speed = data.decode("utf-8")
print("Speed = ", speed)

translation_matrix = np.float32([ [1,0,np.float32(speed)], [0,1,0] ])
img = cv2.warpAffine(img, translation_matrix, (num_cols, num_rows))

I use this input to make a translation matrix so that i can shift my image according the input from the encoder.

My initial Image looks like this: image description

After a few warpAffines it looks like this: image description

Is there a way to reduce the blurring/warping of the image while still being able to move it in a nice way

edit retag flag offensive close merge delete


Have you tried cv::INTER_NEAREST instead of the default cv::INTER_LINEAR?

Der Luftmensch gravatar imageDer Luftmensch ( 2018-10-09 12:11:42 -0500 )edit

instead of repeatedly warping the same image: add up the speed, and warp the original image ?

berak gravatar imageberak ( 2018-10-16 08:08:36 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2018-10-16 08:03:48 -0500

Instead of using np.float32(speed) i am now using int(float(speed)) this helps getting a much smoother image

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower


Asked: 2018-10-08 08:59:39 -0500

Seen: 143 times

Last updated: Oct 16 '18