sudo apt-get install php-mysql

 

 

/var/www/html   경로에 test.php 생성후 실행 

 

 

 

test.php

 

 <?php 
$mysql_hostname = '127.0.0.1';
$mysql_username = 'root';
$mysql_password = 'shinhan3262';
$mysql_database = 'iot_main';
$mysql_port = '3306';
$mysql_charset = 'UTF8';
    
$connect = new mysqli($mysql_hostname, $mysql_username, $mysql_password, $mysql_database, $mysql_port, $mysql_charset);
 
if($connect->connect_errno){
    echo '!연결실패'.$connect->connect_error.'';
}else{
    echo '연결성공!';
}
      
    
?>
 <?php echo 'End Hellow'; ?>

 

 

sudo apt-get install mysql-server

 

"Y" 누르면 설치가 진행된다.

 

외버 접속 허용 

sudo ufw allow mysql  

 

실행

sudo systemctl start mysql

 

자동실행등록 

 sudo systemctl enable mysql

 

접속

sudo mysql -u root

 

 

접속 방법 변경 

select user, plugin  from user;

 

 

update user set plugin='mysql_native_password' where user='root';

종료후 

 

 

sudo mysql -u root -p

 

 

 

 

 

PHP 설치

 

sudo apt-get install php

 

아파치 기본 폴더  /var/www/html

 

폴더 권한 부여 

sudo chmod 777 /var/www/html -R

 

폴더 권한이 부여되어 문서 생성이 됨

 

 

test.php 생성

 

파일 편집기로  test.php 파일 편집

<?php echo "Hello PHP" ?> 

 

 

 

 

 

 

 

.php  => 확장자 없이 사용 하는 법

 

/etc/apache2/apache2.conf 

 

권한부여

 sudo chmod 7777 /etc/apache2/apache.conf

 

 

 

파일열기

<Directory /var/www/>
Options FollowSymLinks MultiViews
AddType application/x-httpd-php .php .jsp
AllowOverride FileInfo
Require all granted
</Directory>

 

수정후 저장

 

아파치 재시작

sudo service apache2 stop

sudo service apache2 start 

 

터미널을 열고 

 

페키지 업데이트

 sudo apt update 

 

 sudo apt upgrade

Y 눌러주고

 

아파치 설치 

 

sudo apt install apache2

 

 

아파치 서버 가동

 

sudo service apache2 start

 

 

브라우저를 열고  주소에 127.0.0.1   아파치 기본 페이지가 나오면 성공

import cv2
from ultralytics import YOLO

 

model = YOLO('yolov8x.pt')
webcam = cv2.VideoCapture(0)

blue_color = (255,0,0)

if not webcam.isOpened():
    print("Could not open webcam")
    exit()

while webcam.isOpened():
    status, frame = webcam.read()

    if status:
        results = model.predict(classes=0, device=0, conf=0.5, source=frame)

        for result in results:
            annotated_frame = result.plot(line_width=2, labels=False, boxes=False)
            boxes = result.boxes

            if boxes :
                for box in boxes :
                    x1 = int(box.xyxy[0,0])
                    y1 = int(box.xyxy[0,1])
                    x2 = int(box.xyxy[0,2])
                    y2 = int(box.xyxy[0,3])
                    cv2.rectangle(annotated_frame, (x1,y1), (x2,y2), blue_color, 3 )

                cv2.imshow("cam", annotated_frame)

    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

webcam.release()
cv2.destroyAllWindows()

     참조

      https://docs.ultralytics.com/modes/predict/#sources

 

        weights=ROOT / 'yolov5s.pt',  # model path or triton URL
        source=ROOT / 'data/images',  # file/dir/URL/glob/screen/0(webcam)
        data=ROOT / 'data/coco128.yaml',  # dataset.yaml path
        imgsz=(640, 640),  # inference size (height, width)
        conf_thres=0.25,  # confidence threshold
        iou_thres=0.45,  # NMS IOU threshold
        max_det=1000,  # maximum detections per image
        device='',  # cuda device, i.e. 0 or 0,1,2,3 or cpu
        view_img=False,  # show results
        save_txt=False,  # save results to *.txt
        save_conf=False,  # save confidences in --save-txt labels
        save_crop=False,  # save cropped prediction boxes
        nosave=False,  # do not save images/videos
        classes=None,  # filter by class: --class 0, or --class 0 2 3
        agnostic_nms=False,  # class-agnostic NMS
        augment=False,  # augmented inference
        visualize=False,  # visualize features
        update=False,  # update all models
        project=ROOT / 'runs/detect',  # save results to project/name
        name='exp',  # save results to project/name
        exist_ok=False,  # existing project/name ok, do not increment
        line_thickness=3,  # bounding box thickness (pixels)
        hide_labels=False,  # hide labels
        hide_conf=False,  # hide confidences
        half=False,  # use FP16 half-precision inference
        dnn=False,  # use OpenCV DNN for ONNX inference
        vid_stride=1,  # video frame-rate stride

 

results = model.predict(source=frame, show=True, device="0", hide_labels=True) # yolo 표시


from ultralytics import YOLO
import os
import cv2 as cv


model = YOLO("yolov8s.pt")

os.environ["OPENCV_FFMPEG_CAPTURE_OPTIONS"] = "rtsp_transport;udp"
cap = cv.VideoCapture('rtsp://210.99.70.120:1935/live/cctv001.stream')

while cap.isOpened():
ret, frame = cap.read()

if not ret:
print("Can't receive frame")
break

# cv.imshow('frame', frame) 영상표시
results = model.predict(source=frame, show=True, device="0") # yolo 표시

if cv.waitKey(1) == ord('q'):
break
cap.release()
cv.destroyAllWindows()

 

  1. Person
  2. Bicycle
  3. Car
  4. Motorcycle
  5. Airplane
  6. Bus
  7. Train
  8. Truck
  9. Boat
  10. Traffic light
  11. Fire hydrant
  12. Stop sign
  13. Parking meter
  14. Bench
  15. Bird
  16. Cat
  17. Dog
  18. Horse
  19. Sheep
  20. Cow
  21. Elephant
  22. Bear
  23. Zebra
  24. Giraffe
  25. Backpack
  26. Umbrella
  27. Handbag
  28. Tie
  29. Suitcase
  30. Frisbee
  31. Skis
  32. Snowboard
  33. Sports ball
  34. Kite
  35. Baseball bat
  36. Baseball glove
  37. Skateboard
  38. Surfboard
  39. Tennis racket
  40. Bottle
  41. Wine glass
  42. Cup
  43. Fork
  44. Knife
  45. Spoon
  46. Bowl
  47. Banana
  48. Apple
  49. Sandwich
  50. Orange
  51. Broccoli
  52. Carrot
  53. Hot dog
  54. Pizza
  55. Donut
  56. Cake
  57. Chair
  58. Couch
  59. Potted plant
  60. Bed
  61. Dining table
  62. Toilet
  63. TV
  64. Laptop
  65. Mouse
  66. Remote
  67. Keyboard
  68. Cell phone
  69. Microwave
  70. Oven
  71. Toaster
  72. Sink
  73. Refrigerator
  74. Book
  75. Clock
  76. Vase
  77. Scissors
  78. Teddy bear
  79. Hair drier
  80. Toothbrush

classes=0  하면 사람만 감지한다. 

yolo 모델을 변경합니다. "yolov8s.pt 

from ultralytics import YOLO

model = YOLO("yolov8s.pt")
results = model.predict(source="0", show=Truedevice="0" classes=0 )

 

 

+ Recent posts