PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, July 27, 2022

[FIXED] How to save cropped image using openCV?

 July 27, 2022     crop, face-recognition, image, opencv, python     No comments   

Issue

I am capturing image using opencv and face_recognition library in python, Here is the snippet of my program

while True:
ret,frame = video_capture.read()
rgb_frame = frame[:,:,::-1]
face_locations = fr.face_locations(rgb_frame)
face_encodings = fr.face_encodings(rgb_frame,face_locations)
cv2.imwrite('test.png', frame)
if len(face_encodings)!=0:
    print(face_locations)
    temp = list(face_locations[0])
    img = cv2.imread('test.png')
    cropped = img[temp[0]:temp[2],temp[0]:temp[1]]
    cv2.imshow("cropped", cropped)
    cv2.imwrite('face.png',cropped)

I am trying to save cropped image to my directory. But the code above doesn't work. Do you know the way how can I save cropped Image using opencv ?


Solution

Try this cv2.imwrite('path/to/face.png',cropped)



Answered By - Client
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing