โครงงานสมองกลฝังตัว

  • หน้าหลัก
  • อิคคิวซัง
    • ปีการศึกษา 2562
    • ปีการศึกษา 2561
    • ปีการศึกษา 2560
    • ปีการศึกษา 2559
    • ปีการศึกษา 2558
    • ปีการศึกษา 2557
    • ปีการศึกษา 2556
  • ทสรช.
    • ปีการศึกษา 2562
    • ปีการศึกษา 2561
    • ปีการศึกษา 2560
    • ปีการศึกษา 2559
  • สถานพินิจ
    • ปีการศึกษา 2562
  • โรงเรียนคนพิการ
    • ปีการศึกษา 2562
  • มหาวิทยาลัย
    • ปีการศึกษา 2560
    • ปีการศึกษา 2559
  • STEM ปี 2560
  • Show&Share2022
    • โครงงานสิ่งประดิษฐ์เพื่อศึกษาและดูแลสิ่งแวดล้อม
    • โครงงานสิ่งประดิษฐ์เพื่อการเกษตรอัจฉริยะ
    • โครงงานสิ่งประดิษฐ์เพื่อพัฒนาคุณภาพชีวิตและชุมชน
    • โครงงานลิฟต์
    • รายชื่อผู้เข้าแข่งขันอื่นๆ

AC13 โครงงานห้องเรียนอัจฉริยะ บ้านนา “นายกพิทยากร” นครนายก ม.ต้น

Posted on March 23, 2018 by puser34 Posted in ทสรช ปีการศึกษา 2560 .

     โครงงานห้องเรียนอัจฉริยะ

 

 

ที่มาและความสำคัญ

 

ในปัจจุบันเทคโนโลยีได้เข้ามามีส่วนร่วมในชีวิตประจำวันของพวกเราทุกคน ในด้านที่สำคัญ คือ ด้านการอำนวยความสะดวกสะบายของมนุษย์ด้วยการนำเทคโนโลยีต่างๆมาประยุกต์หรือช่วยแก้ปัญหาเพื่อตอบสนอง ความสะดวกสบาย อันเห็นได้จากสิ่งประดิษฐ์และนวัตกรรม หลายๆอย่าง เช่น รถยนต์ คอมพิวเตอร์ โทรศัพท์มือถือ  ที่สร้างขึ้นเพื่อความสะดวกสบาย

ในการเปิด-ปิดไฟพัดลมในบางครั้ง เด็กนักเรียนที่มีหน้าที่รับผิดชอบประจำวันที่ลืมปิดไฟพัดลม และมีนักเรียนจากห้องอื่นเข้ามาก่อความวุ่นวายภายในห้องขณะที่นักเรียนไม่ได้อยู่ในห้องเช่น ช่วงพักกลางวัน และช่วงย้ายไปเรียนที่ห้องอื่น ทำให้สิ่งของภายในห้องสูญหายหรือไม่ได้จัดวางไว้ที่เดิม ทำให้เกิดปัญหากับนักเรียนที่เป็นเจ้าของสิ่งนั้น

เนื่องจากสาเหตุนี้ เราจึงได้สร้างแบบจำลองการทำงานของ smart classroom ขึ้นมาเพื่ออำนวยความสะดวกสบาย ตรวจสอบนักเรียนที่เข้าภายในห้องและใช้เป็นแบบอย่างในการพัฒนาต่อเป็นสิ่งที่สามารถใช้งานจริงได้

 

วัตถุประสงค์

 

  1. เพื่อสร้างแบบจำลอง smart classroom
  2. เพื่ออำนวยความสะดวกสบายในการเปิด-ปิดไฟพัดลม และตรวจสอบนักเรียนที่เข้าออกภายในห้อง

 

วัสดุอุปกรณ์

  • บอร์ด Raspberry Pi
  • มอเตอร์
  • หลอด LED
  • กล้อง

  • ultrasonic sensor

ผังโครงสร้าง

 

ผังงาน

 

หลักการทำงาน

ใช้webcamในการแสกนใบกน้าแล้วเปิดประตูเมื่อเดินเขาไปในห้องจะมีเซนเซอร์ตรวจจับการเคลือนไหวถ้ามีการเคลื่อนไหวก็จะเปิดไฟจนกว่าจะไม่มีการเคลื่อนไหวและเมื่อจะออกจากห้องก็จะมีเซนเซอร์ ultasonic คอยเปิดประตูอัตโนมัติ

 

CODE คำสั่งการทำงาน

 


import RPi.GPIO as GPIO # import RPi.GPIO module
import time
import face_recognition
import cv2
Minute_For_ON = 0.1 # % minutes for Fan On
__FanOn = False
bFanOn = False
Forward = 23
Backward = 24
GPIO.setmode(GPIO.BCM) # choose BCM or BOARD
GPIO.setup(21, GPIO.OUT) # set GPIO18 as an output
GPIO.output(21, 0)#GPIO.setup(Forward, GPIO.OUT) # set GPIO18 as an output
#GPIO.setup(Backward, GPIO.OUT) # set GPIO18 as an output
# set GPIO18 to 1/GPIO.HIGH/True
# This is a demo of running face recognition on live video from your webcam. It’s a little more complicated than the
# other example, but it includes some basic performance tweaks to make things run a lot faster:
# 1. Process each video frame at 1/4 resolution (though still display it at full resolution)
# 2. Only detect faces in every other frame of video.# PLEASE NOTE: This example requires OpenCV (the cv2 library) to be installed only to read from your webcam.
# OpenCV is not required to use the face_recognition library. It’s only required if you want to run this
# specific demo. If you have trouble installing it, try any of the other demos that don’t require it instead.

# Get a reference to webcam #0 (the default one)
video_capture = cv2.VideoCapture(0)

# Load a sample picture and learn how to recognize it.
Sun_Image = face_recognition.load_image_file(“Sun.jpg”)
Sun_face_encoding = face_recognition.face_encodings(Sun_Image)[0]

# Load a second sample picture and learn how to recognize it.
Heart_image = face_recognition.load_image_file(“Heart.jpg”)
Heart_face_encoding = face_recognition.face_encodings(Heart_image)[0]

# Load a second sample picture and learn how to recognize it.
A_image = face_recognition.load_image_file(“A.jpg”)
A_encoding = face_recognition.face_encodings(A_image)[0]

# Create arrays of known face encodings and their names
known_face_encodings = [
Sun_face_encoding,
Heart_face_encoding,
A_encoding
]
known_face_names = [
“Sun”,
“Heart”,
“A”
]

# Initialize some variables
face_locations = []
face_encodings = []
face_names = []
process_this_frame = True
state =1
door =1

#def forward(x):
#GPIO.output(Forward, GPIO.HIGH)
# print(“Moving Forward”)
#time.sleep(x)
#GPIO.output(Forward, GPIO.LOW)

#def reverse(x):
#GPIO.output(Backward, GPIO.HIGH)
#print(“Moving Backward”)
#time.sleep(x)
#GPIO.output(Backward, GPIO.LOW)

while True:
# Grab a single frame of video
ret, frame = video_capture.read()

# Resize frame of video to 1/4 size for faster face recognition processing
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)

# Convert the image from BGR color (which OpenCV uses) to RGB color (which face_recognition uses)
rgb_small_frame = small_frame[:, :, ::-1]

# Only process every other frame of video to save time

if process_this_frame:
# Find all the faces and face encodings in the current frame of video
face_locations = face_recognition.face_locations(rgb_small_frame)
face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)

face_names = []
bFanOn = False
for face_encoding in face_encodings:
# See if the face is a match for the known face(s)
matches = face_recognition.compare_faces(known_face_encodings, face_encoding)
name = “Unknown”

# If a match was found in known_face_encodings, just use the first one.
if True in matches:
first_match_index = matches.index(True)
name = known_face_names[first_match_index]
bFanOn = True or bFanOn

face_names.append(name)

process_this_frame = not process_this_frame

if( state == 1 ):
GPIO.output(21, 0) # Fan Off
if ( bFanOn ==True ):
print(“Fan ON”)
start_time = time.time()
state = 2
# door = 2

if( state == 2 ):
GPIO.output(21, 1) # Fan On
if ( time.time() – start_time > 10*Minute_For_ON ) :
state = 1
print(“Fan OFF”)
#if( door == 2):
#forward(5)
#reverse(5)
#door = 1
# Display the results
for (top, right, bottom, left), name in zip(face_locations, face_names):
# Scale back up face locations since the frame we detected in was scaled to 1/4 size
top *= 4
right *= 4
bottom *= 4
left *= 4

# Draw a box around the face
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)

# Draw a label with a name below the face
cv2.rectangle(frame, (left, bottom – 35), (right, bottom), (0, 0, 255), 2)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left + 6, bottom – 6), font, 1.0, (255, 255, 255), 1)

# Display the resulting image
cv2.imshow(‘Video’, frame)

# Hit ‘q’ on the keyboard to quit!
if cv2.waitKey(1) & 0xFF == ord(‘q’):
break

# Release handle to the webcam
video_capture.release()
cv2.destroyAllWindows()
GPIO.cleanup()

# Import required Python libraries
from _future_ import print_function
import time
import RPi.GPIO as GPIO
# Use BCM GPIO references
# instead of physical pin numbers
GPIO.setmode(GPIO.BCM)# Define GPIO to use on Pi
GPIO_TRIGGER = 23
GPIO_ECHO = 24
Forward = 25
Backward = 8
door = 0
# Speed of sound in cm/s at temperature
temperature = 20
speedSound = 33100 + (0.6*temperature)

print(“Ultrasonic Measurement”)
print(“Speed of sound is”,speedSound/100,”m/s at “,temperature,”deg”)

# Set pins as output and input
GPIO.setup(GPIO_TRIGGER,GPIO.OUT) # Trigger
GPIO.setup(GPIO_ECHO,GPIO.IN) # Echo
GPIO.setup(Forward,GPIO.OUT)
GPIO.setup(Backward,GPIO.OUT)
def forward(x):
GPIO.output(Forward, GPIO.HIGH)
print(“Moving Forward”)
#time.sleep(x)
#GPIO.output(Forward, GPIO.LOW)

def reverse(x):
GPIO.output(Backward, GPIO.HIGH)
print(“Moving Backward”)
time.sleep(x)
GPIO.output(Backward, GPIO.LOW)

while True:

# Set trigger to False (Low)
GPIO.output(GPIO_TRIGGER, False)

# Allow module to settle
time.sleep(0.5)

# Send 10us pulse to trigger
GPIO.output(GPIO_TRIGGER, True)
# Wait 10us
time.sleep(0.00001)
GPIO.output(GPIO_TRIGGER, False)
start = time.time()

while GPIO.input(GPIO_ECHO)==0:
start = time.time()

while GPIO.input(GPIO_ECHO)==1:
stop = time.time()

# Calculate pulse length
elapsed = stop-start

# Distance pulse travelled in that time is time
# multiplied by the speed of sound (cm/s)
distance = elapsed * speedSound

# That was the distance there and back so halve the value
distance = distance / 2
##distance
print(“Distance : {0:5.1f}”.format(distance))
if (distance < 40):
print (“do”)
# = time.time()
forward(5)
door = 1

else :
GPIO.output(Forward, GPIO.LOW)
time.sleep(1)
if ( door == 1) :
reverse(1.5)
door = 0

GPIO.cleanup()

 

สิ้นสุดการสนทนาผ่านแชท
พิมพ์ข้อความ…

 

 

 

ผลของการทดสอบ

 

 

เราได้ทำการให้ผู้ทดสอบ มาทดสอบในการใช้กล้องเว็ปแคมจดจำใบหน้าและระบุชื่อเจ้าของใบหน้านั้น ผลปรากฏดังงนี้

ครั้งที ผู้ทดสอบคนที่1 ผู้

ทดสอบคนที่2

ผู้ทดสอบคนที่3 ผู้ทดสอบคนที่4
1

2  

 

3

4

5

 

วิธีการดำเนินการ

  1 กำหนดปัญหาที่ต้องแก้ไข

จากการสังเกต พบว่ามีนักเรียนผู้รับผิดชอบเวรประจำวันหลายห้อง ลืมปิดไฟ พัดลม และมีนักเรียนต่างห้องเข้ามาทำให้สิ่งของสูญหาย จึงทำให้เราต้องการที่จะจัดทำโครงงานนี้ขึ้นมาเพื่อแก้ไขปัญหานี้

2 ทำการรวบรวมข้อมูล

เนื่องจาก เราต้องการจะทำที่เกี่ยวกับบอร์ด Raspberry Pi และเว็ปแคม ดังนั้น ข้อมูลที่  เราต้องศึกษา ก็คือข้อมูลเกี่ยวกับบอร์ด Raspberry Pi และเว็ปแคม บอร์ด Raspberry Pi คือ  เครื่องคอมพิวเตอร์ขนาดจิ๋ว ที่มีขนาดเพียงเท่ากับบัตรเครดิต ที่สำคัญคือ ราสเบอร์รี่พายนี้มีราคาที่ถูกมาก เมื่อเทียบกับคอมพิวเตอร์เดสก์ท็อปปกติ คือมีราคาเพียงแค่หนึ่งพันบาทแต่สามารถทำงาน  ได้เหมือนเครื่องคอมพิวเตอร์ทุกอย่าง เราสามารถต่อราสเบอร์รี่พายนี้เข้ากับจอคอมพิวเตอร์หรือ   จอทีวีที่รองรับ HDMI หรือถ้าไม่มีพอร์ต HDMI ก็ไม่ต้องกังวล สามารถต่อผ่านสายสัญญาณวิดีโอปกติ (เส้นสีเหลือง) แต่ความละเอียดอาจจะต่ำกว่า เซนเซอร์ คือ อุปกรณ์ตรวจจับสัญญาณหรืองปริมาณทางฟิสิกส์ต่างๆ

3 เลือกวิธีที่จะทำการแก้ปัญหา

ต้องการที่จะทำแบบจำลองห้องเรียนเพื่อใช้ในการอำนวยความสะดวกสบายในการเปิดปิดไฟ พัดลม

4 ทำการออกแบบและลงมือปฎิบัติ

ใช้ภาพร่าง 2 มิติในการอออกแบบตัวเครื่องจ่ายไฟอัตโนมัติและใช้ภาพ 3 มิติในการออกแบบโมเดลขึ้นเป็นชินงานต้นแบบ จากนั้นก็ลงมือปฎิบัติตามแผนที่วางไว้

5 เริ่มทำการทดสอบแบบจำลอง smart room

เริ่มทำการทดสอบแบบจำลอง smart roomโดยนำเซ็นเซอร์จับการเคลื่อนไหวมาคอยควบคุมการเปิดปิดประตู และใช้กล้องเวบแคมในตรวจจับใบหน้าเพื่อตรวจสอบผู้เข้าออกในห้อง

6 ทำการปรับปรุงแก้ไขปัญหาที่เกิดขึ้น

ปัญหาของพวกเราก็คือมอเตอร์ไม่ทำงานเนื่องจากกำลังไฟไม่พอพวกเราคณะผู้จัดทำจึงได้นำRelayมาช่วยเพื่มกำลังไฟ

7 ทำการประเมินผลที่ได้มา

เราได้ทำการทดลองโดยการใช้กล้องเวปแคมในการตรวจจับใบหน้า ผลปรากฏว่ากล้องเวปแคมสามารถตรวจจับใบหน้าได้ค่อนข้างแม่นยำ

 

คณะผู้จัดทำโครงงาน

  1. ด.ช.ณัฐวัฒน์ ด้วงเงิน
  2. ด.ช.ภูชิต  เกตุสมบูรณ์
  3. ด.ช.อภิวิชญ์  ปาลิกา

 

 

อาจารย์ที่ปรึกษา

ครูอภิชาติ ชัยชนะ                                 สอนวิชา คอมพิวเตอร์

โทรศัพท์  0812743551                 อีเมล chaicha.ap@gmail.com

ครูนารีรัตน์ อินอิว                                  สอนวิชา คณิตศาสตร์

โทรศัพท์ 0885269988                   อีเมล ineiw2525@gmail.com

โรงเรียนพุทธโกศัยวิทยา

ที่อยู่ของโรงเรียน            โรงเรียนบ้านนา”นายกพิทยากร”

« AS11 โครงงานระบบแปลงเกษตร IOT ราชประชานุเคราะห์ 37 กระบี่ ม.ต้น
AC14 โครงงานฟาร์มต้นอ่อนทานตะวันอัจฉริยะ ราชประชานุเคราะห์ 48 จันทบุรี ม.ต้น »

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

CyberChimps WordPress Themes

© โครงงานสมองกลฝังตัว