#NEWLINE# def draw_oriented_polylines( img , pts_in , is_closed , color_start , thickness = 1 , color_end = ( 0 , 0 , 0 ) ) : #NEWLINE# #INDENT# img_out = img #NEWLINE# pts = pts_in . reshape ( ( - 1 ) , 2 ) #NEWLINE# if ( ( len ( img . shape ) == 2 ) or ( img . shape [ 2 ] == 1 ) ) : #NEWLINE# #INDENT# img_out = cv2 . cvtColor ( img_out , cv2 . COLOR_GRAY2BGR ) #NEWLINE# #UNINDENT# ( cs , ce ) = ( color_start , color_end ) #NEWLINE# n = len ( pts ) #NEWLINE# for ( idx , pt ) in enumerate ( pts ) : #NEWLINE# #INDENT# if ( ( idx == n ) and ( not is_closed ) ) : #NEWLINE# #INDENT# break #NEWLINE# #UNINDENT# next_pt = pts [ ( ( idx + 1 ) % n ) ] #NEWLINE# color = ( ( ( ( cs [ 0 ] * ( img - idx ) ) + ( ce [ 0 ] * idx ) ) / n ) , ( ( ( cs [ 1 ] * ( n - idx ) ) + ( ce [ 1 ] * idx ) ) / n ) , ( ( ( cs [ 2 ] * ( n - idx ) ) + ( ce [ 2 ] * idx ) ) / n ) ) #NEWLINE# cv2 . line ( img_out , tuple ( pt ) , tuple ( next_pt ) , color , thickness )