i just want to flip image vertically without cv2.flip(), but output is completely black image. where is my mistake ?
import cv2
import numpy as np
def flipv(imgg):
    for i in range(480):
        img2= np.zeros([480, 640, 3], np.uint8)
        img2[i,:]=imgg[480-i-1,:]
    return img2
img = cv2.imread("foto\\test.jpg", 1)
ads= flipv(img)
cv2.imshow("qw",ads)
cv2.waitKey(0)
cv2.destroyAllWindows()
                To flip an Image vertically or horizontally with Python pillow, use transpose() method on the PIL Image object.
Flip image with OpenCV: cv2. flip() . Specify the original ndarray as the first argument and a value indicating the directions as the second argument flipCode . The image is flipped according to the value of flipCode as follows: flipcode = 0 : flip vertically.
To vertically flip an image (flip the image about its vertical axis), we use the flip() function. The flip() function takes in 2 parameters. The first parameter is the image you want to flip. The second parameter is 0 (for vertical flipping).
Simple function to flip images using opencv:
def flip(img,axes):
    if (axes == 0) :
        #horizental flip
        return cv2.flip( img, 0 )
    elif(axes == 1):
        #vertical flip
        return cv2.flip( img, 1 )
    elif(axes == -1):
        #both direction
        return cv2.flip( img, -1 ) 
bflp = flip(img,-1)
plt.imshow(bflp)
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With