Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version
#!/usr/bin/env python3
#Raspberry pi 3B+, debian Strect, kernel 4.19.5 v7
#OpenCV 4.0-pre
#Date 1st December, 2018

import cv2
import numpy as np

if __name__ == '__main__' :

    # Read image
    im = cv2.imread("leaf.jpg")

    # Select ROI
    fromCenter = False
    r = cv2.selectROI(im, fromCenter )

    # Crop image
    imCrop = im[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]

    cv2.imwrite('leaf2.jpg', imCrop) 
    # Display cropped image
    cv2.imshow("Image", imCrop)
    cv2.waitKey(0)

Drag rectangle to specify are. Then press space-bar to see second window. leaf2

!/usr/bin/env python3

#!/usr/bin/env python3
#Raspberry pi 3B+, debian Strect, kernel 4.19.5 v7
#OpenCV 4.0-pre
#Date 1st December, 2018

import cv2
import numpy as np

if __name__ == '__main__' :

    # Read image
    im = cv2.imread("leaf.jpg")

    # Select ROI
    fromCenter = False
    r = cv2.selectROI(im, fromCenter )

    # Crop image
    imCrop = im[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]

    cv2.imwrite('leaf2.jpg', imCrop) 
    # Display cropped image
    cv2.imshow("Image", imCrop)
    cv2.waitKey(0)

Drag rectangle to specify are. area. Then press space-bar to see second window. leaf2

!/usr/bin/env python3

#Raspberry pi 3B+, debian Strect, kernel 4.19.5 v7
#OpenCV 4.0-pre
#Date 1st December, 2018

import cv2
import numpy as np

if __name__ == '__main__' :

    # Read image
    im = cv2.imread("leaf.jpg")

    # Select ROI
    fromCenter = False
    r = cv2.selectROI(im, fromCenter )

    # Crop image
    imCrop = im[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]

    cv2.imwrite('leaf2.jpg', imCrop) 
    # Display cropped image
    cv2.imshow("Image", imCrop)
    cv2.waitKey(0)

Drag rectangle to specify area. Then press space-bar to see second window. leaf2

!/usr/bin/env python3

#Raspberry pi 3B+, debian Strect, kernel 4.19.5 v7
#OpenCV 4.0-pre
#Date 1st December, 2018

import cv2
import numpy as np

if __name__ == '__main__' :

    # Read image
    im = cv2.imread("leaf.jpg")

    # Select ROI
    fromCenter = False
    r = cv2.selectROI(im, fromCenter )

    # Crop image
    imCrop = im[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]

    cv2.imwrite('leaf2.jpg', imCrop) 
    # Display cropped image
    cv2.imshow("Image", imCrop)
    cv2.waitKey(0)

Drag rectangle to specify area. Then press space-bar to see second window. leaf2

!/usr/bin/env python3

#Raspberry pi 3B+, debian Strect, kernel 4.19.5 v7
#OpenCV 4.0-pre
#Date 1st December, 2018

import cv2
import numpy as np

if __name__ == '__main__' :

    # Read image
    im = cv2.imread("leaf.jpg")

    # Select ROI
    fromCenter = False
    r = cv2.selectROI(im, fromCenter )

    # Crop image
    imCrop = im[int(r[1]):int(r[1]+r[3]), int(r[0]):int(r[0]+r[2])]

    cv2.imwrite('leaf2.jpg', imCrop) 
    # Display cropped image
    cv2.imshow("Image", imCrop)
    cv2.waitKey(0)

Drag rectangle to specify area. Then press space-bar to see second window. leaf2