in 04_detect_segment/utils_box.py [0:0]
def rotate(rois, tile_size, rot_matrix):
# rois: shape [batch, 4] 4 numbers for x1, y1, x2, y2
translation = tf.constant([tile_size/2.0, tile_size/2.0], tf.float32)
translation = tf.expand_dims(translation, axis=0) # to be applied to a batch of points
batch = tf.shape(rois)[0]
rois = tf.reshape(rois, [-1, 2]) # batch of points
# standard trick to apply a rotation matrix to a batch of vectors:
# do vectors * matrix instead of the usual matrix * vector
rois = rois - translation
rois = tf.matmul(rois, rot_matrix)
rois = rois + translation
rois = tf.reshape(rois, [batch, 4])
return rois