sensor_save_and_restore_settings.py

# هذا العمل مرخص بموجب ترخيص MIT.
# حقوق النشر (c) 2013-2023 OpenMV LLC. جميع الحقوق محفوظة.
# https://github.com/openmv/openmv/blob/master/LICENSE
#
# حفظ واستعادة إعدادات الحساس
#
# يوضح هذا المثال كيفية حفظ إعدادات الكاميرا ثم استعادتها
# بعد إعادة ضبط الحساس و/أو إيقاف تشغيله.

import csi
import time

# تعيين تنسيق البكسل إلى RGB565 (أو GRAYSCALE)
target_pixformat = csi.RGB565

# تعيين حجم الإطار إلى QVGA (320x240)
target_framesize = csi.QVGA

csi0 = csi.CSI()
csi0.reset()
csi0.pixformat(target_pixformat)
csi0.framesize(target_framesize)

# انتظار 3 ثوانٍ للسماح لدوال الكاميرا التلقائية بالعمل وقياس معدل الإطارات.
t = time.ticks_ms()
clock = time.clock()
fps = 0
while time.ticks_diff(time.ticks_ms(), t) < 3000:
    clock.tick()
    csi0.snapshot()
    fps = clock.fps()

# يجب أن يكون لدى الحساس الآن وقت كافٍ للإحماء والتكيّف مع البيئة الحالية.
# احصل على الإعدادات الآن قبل إيقاف تشغيل الحساس.

gain = csi0.gain_db()
exposure = csi0.exposure_us()
rgb_gain = csi0.rgb_gain_db()

print("Gain == %f db" % gain)
print("Exposure == %d us" % exposure)
print("RGB Gain == %f db, %f db, %f db" % (rgb_gain[0], rgb_gain[1], rgb_gain[2]))

print("Powering Off Sensor")
csi0.shutdown(True)
time.sleep(2)
del csi0

# تعطيل جميع تأخيرات زمن الاستقرار في كود مشغّل الحساس. تعطيل هذا سينتج عنه
# ظهور صور تالفة عند تعديل الإعدادات. لكن، يمكنك الآن تغيير إعدادات الحساس
# بشكل جماعي وبسرعة.

ts = time.ticks_ms()
print("Powering On Sensor")
csi0 = csi.CSI(delays=False)
csi0.reset()
csi0.pixformat(target_pixformat)
csi0.framesize(target_framesize)
csi0.auto_gain(False, gain_db=gain)
csi0.auto_exposure(False, exposure_us=exposure)
csi0.auto_whitebal(False, rgb_gain_db=rgb_gain)

# يجب عليك الانتظار قبل استدعاء snapshot لأن الصورة الخارجة من الكاميرا الآن
# من المرجح أن تكون تالفة جدًا. المدة الدقيقة للانتظار أدناه تعتمد على
# التطبيق. مع ذلك، يجب عليك على الأرجح الانتظار لمدة إطار واحد.
time.sleep(1.0 / fps)

print("Restore Delay %d ms" % (time.ticks_ms() - ts))

gain = csi0.gain_db()
exposure = csi0.exposure_us()
rgb_gain = csi0.rgb_gain_db()

print("Gain == %f db" % gain)
print("Exposure == %d us" % exposure)
print("RGB Gain == %f db, %f db, %f db" % (rgb_gain[0], rgb_gain[1], rgb_gain[2]))

clock = time.clock()

# يجب أن تبدو الصورة كما كانت قبل الحفظ والاستعادة.
while True:
    clock.tick()
    img = csi0.snapshot()
    # print(clock.fps())

results matching ""

    No results matching ""