• Talaba: Abdisalomov Avazbek O‘qituvchi: Norkobilov Salim Toshkent – 2024
  • Talaba: Abdisalomov Avazbek




    Download 243,23 Kb.
    Sana24.05.2024
    Hajmi243,23 Kb.
    #252242
    Bog'liq
    8-practice


    O‘ZBEKISTON RESPUBLIKASI
    RAQAMLI TEXNOLOGIYALAR VAZIRLIGI


    MUHAMMAD AL‑XORAZMIY NOMIDAGI
    TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI

    VIDEOMA’LUMOTLARGA RAQAMLI ISHLOV BERISH”


    FANIDAN
    8-AMALIY MASHG‘ULOT ISHLARI


    HISOBOTI
    Guruh: 811-20


    Talaba: Abdisalomov Avazbek


    O‘qituvchi: Norkobilov Salim


    Toshkent – 2024
    Sun’iy intellekt yordamida yuzni hududlarga ajratish
    Dastur kodi:
    import cv2
    import mediapipe as mp
    mp_face_detection = mp.solutions.face_detection
    mp_drawing = mp.solutions.drawing_utils
    mp_drawing = mp.solutions.drawing_utils
    mp_drawing_styles = mp.solutions.drawing_styles
    mp_face_mesh = mp.solutions.face_mesh

    drawing_spec = mp_drawing.DrawingSpec(thickness=1, circle_radius=1)


    cap = cv2.VideoCapture(0)
    face_mesh= mp_face_mesh.FaceMesh(
    max_num_faces=1,
    refine_landmarks=True,
    min_detection_confidence=0.5,
    min_tracking_confidence=0.5)
    while cap.isOpened():
    success, image = cap.read()
    if not success: continue
    image.flags.writeable = False
    image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    results = face_mesh.process(image)
    image.flags.writeable = True
    image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
    if results.multi_face_landmarks:
    for face_landmarks in results.multi_face_landmarks:
    mp_drawing.draw_landmarks(
    image=image, landmark_list=face_landmarks,
    connections=mp_face_mesh.FACEMESH_TESSELATION,
    landmark_drawing_spec=None,
    connection_drawing_spec=mp_drawing_styles
    .get_default_face_mesh_tesselation_style())
    mp_drawing.draw_landmarks(
    image=image, landmark_list=face_landmarks,
    connections=mp_face_mesh.FACEMESH_CONTOURS,
    landmark_drawing_spec=None,
    connection_drawing_spec=mp_drawing_styles
    .get_default_face_mesh_contours_style())
    mp_drawing.draw_landmarks(
    image=image, landmark_list=face_landmarks,
    connections=mp_face_mesh.FACEMESH_IRISES,
    landmark_drawing_spec=None,
    connection_drawing_spec=mp_drawing_styles
    .get_default_face_mesh_iris_connections_style())
    cv2.imshow('MediaPipe Face Mesh', cv2.flip(image, 1))
    if cv2.waitKey(5) & 0xFF == 27: break
    cap.release()

    Dastur kodi natijasi:





    Xulosa
    Ushbu dastur "MediaPipe" kutubxonasidan foydalanib yuzni aniq hududlarga ajratishni amalga oshiradi.
    Dasturda quyidagi ishlar bajariladi:
    1. Dastur kutubxonalarni import qiladi: cv2, mediapipe.
    2. "mediapipe" kutubxonasi orqali yuz aniqlash uchun kerakli funksiyalar va obyektlar import qilinadi.
    3. Sozlamalar va o'lchamlar belgilanadi. Bu quyidagi obyektlarni o'z ichiga oladi:
    - mp_face_detection: yuz aniqlash uchun obyekt.
    - mp_drawing va mp_drawing_styles: yuzni chizish uchun obyekt va usullar.
    - mp_face_mesh: yuz maydondan foydalanish uchun obyekt.
    4. Kamera bilan bog'lanish (VideoCapture) amalga oshiriladi.
    5. Dastur to'g'rilanib qaytadi toki kamera ochiq bo'lsa:
    - success, image = cap.read() qatorida kameradan yangi rasm o'qiladi.
    - Rasmni 'RGB' dan 'BGR' ga o'tkazib, yuz aniqlash uchun "face_mesh" obyekti orqali ishlatish uchun tayyorlab boriladi.
    - Agar yuz topilsa, uning maydonlari va konturlari chizib yuboriladi.
    - Chizish natijasini ekran ustida ko'rsatish uchun 'imshow' metodi ishlatiladi.
    - 'Esc' tugmasi bosilganda dastur to'xtatiladi.
    Bularning natijasida, dastur o'z ishini bajaradi va ekran ustida kamera orqali yuzni aniqlaydi, uning maydonlarini va konturlarini chizadi. Dastur tugaganda ekran yopiladi.
    Ushbu dastur yuzni aniqlash va yuz maydonlarini chizish uchun "MediaPipe" kutubxonasini qo'llaydi.
    Download 243,23 Kb.




    Download 243,23 Kb.