Skip to content
BCKM edited this page Oct 12, 2024 · 10 revisions

Create an instance of a Neosoco object


from neopia import *

n = Neosoco()

Basic functions

camera_open(param1)

  • param1 - komputerga ulangan kemeraning raqami. 1-ta kamera bor paytda qiymat '0', 2-ta bor bo'lsa '0' yoki '1' ni tanlash kerak.

start_detection()

  • Continuously checks for faces and returns the number of faces detected.

Face detection

FaceDetection()

  • Yuz tanish bo'yicha hamma funksiyalarga ega python obyektini yaratish

Misol: Nazorat AI kamerasi


fd = FaceDetection()
if fd.camera_open(0):
    while True:
        if fd.start_detection() > 0:
            print('Kimdir kirdi!!!')
            n.led_on()
            n.buzzer()
            n.led_off()

Face mesh detection

FaceMeshDetection()

  • Yuz tanish bo' yicha hamma funksiyalarga ega python obyektini yaratish

Misol: Nazorat AI camerasi 2


fd = FaceMeshDetection()
if fd.camera_open(0):
    while True:
        if fd.start_detection() > 0:
            print('Kimdir kirdi!!!')
            n.led_on()
            n.buzzer()
            n.led_off()

Pose detection


pd = PoseDetection()
if pd.camera_open(0):
    while True:
        nose = pd.start_detection()
        print(nose)

Object detection

ObjectDetection()

  • Buyumlarni tanish bo' yicha hamma funksiyalarga ega python obyektini yaratish start_detection (target_fps=param1)
  • param1 - komputer protsessor kuchiga qarab kamera orgali ma'lumotlarni o'qish tezligini sozlaydi. Parametr kiritilmasa, 30 FPS bo'ladi

Misol: Obyekt topish AI


od = ObjectDetection()
if od.camera_open(0):
    while True:
        result = od.start detection()
        if result:
            obj_names, obj_coords = result
            if 'sports ball' in obj_names:
                n.led_on('out1', '100') n.motor_rotate('both', 'forward', '10*)
                wait(1000)
                n.led_off ('out1')
            else:
                n.motor_rotate('both', 'left', '10')

Gesture detection


gd = GestureDetection()
if gd.camera_open(0):
    while True:
        category = gd.start_detection()
        if category == "Open_Palm":
            n.motor_move('forward')  
        elif category == "Closed_Fist":
            n.motor_stop()
        elif category == "Thumb_Up":
            n.motor_move('right')
        elif category == "Thumb_Down":
            n.motor_move('left')
        elif category == "Pointing_Up":
            n.motor_move('backward')

QR code detection

If your camera is able to find QR code but not decode it, you might want to check if your camera image is flipped


qr = QRDetection()
if qr.camera_open(1):
    while True:
        decode_data = qr.start_detection()
        if decode_data:
            print(decode_data)
            n.led_on()
            n.buzzer()
            n.led_off()

Voice TTS / STT

Voice.tts(param1)

  • param1: AI dan gapirib berish xohlaydigan gaplar

Voice.stt(language=param1)

  • param1: Al tushunib oladigan tilini sozlash: inglizcha uchun "en-US", Ruscha uchun "ru-RU". Hech sozlanmasa, o'zbek tili bo'ladi.

Misol: Ovoz orqali LEDni boshqarish


result = False
while not result:
    try:    
        Voice.tts("I'm hearing. Please speak in 3 secconds.")
        print("Eshityapman. 3 soniya ichida gapirib bering.")
        result = Voice.stt()
        print(result)
        if result == "Chiroqni yoq":
            n.led_on()
            wait(3000)
        elif result == "Chiroqni o'chir":
            n.led_off()
            wait(3000)
    except:
        result = False