Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
gi.require_version('Gst', '1.0')
gi.require_version('GstRtspServer', '1.0')
from gi.repository import Gst, GstRtspServer, GLib
import cv2
from ultralytics import YOLO
from ultralytics.utils.plotting import Annotator
class RtspMediaFactory(GstRtspServer.RTSPMediaFactory):
def __init__(self):
super(RtspMediaFactory, self).__init__()
# YOLOv8 modelini yükle
self.model = YOLO('yolov8n.pt')
def do_create_element(self, url):
# Kameradan gelen görüntüyü yakalayan pipeline
pipeline_str = (
"nvarguscamerasrc sensor-id=0 ! "
"video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)NV12, framerate=(fraction)30/1 ! "
"nvvidconv ! "
"video/x-raw, format=(string)BGR ! " # YOLO için BGR formatında yakalama
"appsink name=sink emit-signals=true"
)
return Gst.parse_launch(pipeline_str)
def on_new_sample(self, sink):
# appsink'ten gelen görüntü yakalanıyor
sample = sink.emit("pull-sample")
buf = sample.get_buffer()
caps = sample.get_caps()
# Veri boyutlarını alalım
width = caps.get_structure(0).get_value('width')
height = caps.get_structure(0).get_value('height')
# Görüntü verisini numpy array olarak al
success, map_info = buf.map(Gst.MapFlags.READ)
if success:
frame = np.ndarray(
(height, width, 3),
buffer=map_info.data,
dtype=np.uint8
)
buf.unmap(map_info)
# YOLO ile nesne tespiti yap
results = self.model(frame)
annotator = Annotator(frame)
for result in results:
for box in result.boxes:
# Tespit edilen nesne kutularını ekrana çiz
annotator.box_label(box.xyxy, box.cls)
# İşlenmiş kareyi geri döndür
return frame
return None
class RtspServer:
def __init__(self):
self.server = GstRtspServer.RTSPServer()
self.factory = RtspMediaFactory()
self.factory.set_shared(True)
# Mount point ekleme
mount_points = self.server.get_mount_points()
mount_points.add_factory("/test", self.factory)
self.server.attach(None)
def run(self):
loop = GLib.MainLoop()
loop.run()
if __name__ == "__main__":
Gst.init(None)
server = RtspServer()
print("RTSP sunucusu başlatıldı: rtsp://127.0.0.1:8554/test")
server.run()
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team