A (มาก) ui lib ง่าย ๆ ที่สร้างขึ้นบนส่วนบนของ OpenCV Drawing Primitives UI libs อื่น ๆ เช่น Imgui ต้องการแบ็กเอนด์กราฟิก (เช่น OpenGL) เพื่อทำงานดังนั้นหากคุณต้องการใช้ IMGUI ในแอพ OpenCV คุณต้องเปิดใช้งาน OpenGL มันไม่ใช่กรณีของ CVUI ซึ่งใช้ เฉพาะ การวาดภาพ OpenCV แบบดั้งเดิมเพื่อทำการเรนเดอร์ทั้งหมด (ไม่จำเป็นต้องใช้ OpenGL หรือ QT)
CVUI เป็น LIB เฉพาะส่วนหัวที่ไม่ต้องการการสร้าง เพียงเพิ่ม cvui.h (หรือ cvui.py ) ลงในโครงการของคุณและคุณก็พร้อมที่จะไป การพึ่งพาเพียงอย่างเดียวคือ OpenCV (เวอร์ชัน 2.x หรือ 3.x ) ซึ่งคุณอาจใช้อยู่แล้ว
ตรวจสอบเอกสารออนไลน์หรือโฟลเดอร์ตัวอย่างเพื่อเรียนรู้วิธีใช้ CVUI การใช้งานทั่วไปใน C ++ และ Python แสดงอยู่ด้านล่าง
การใช้งานใน C ++:
# include < opencv2/opencv.hpp >
// One (and only one) of your C++ files must define CVUI_IMPLEMENTATION
// before the inclusion of cvui.h to ensure its implementaiton is compiled.
# define CVUI_IMPLEMENTATION
# include " cvui.h "
# define WINDOW_NAME " CVUI Hello World! "
int main ( int argc, const char *argv[])
{
// Create a frame where components will be rendered to.
cv::Mat frame = cv::Mat ( 200 , 500 , CV_8UC3);
// Init cvui and tell it to create a OpenCV window, i.e. cv::namedWindow(WINDOW_NAME).
cvui::init (WINDOW_NAME);
while ( true ) {
// Fill the frame with a nice color
frame = cv::Scalar ( 49 , 52 , 49 );
// Render UI components to the frame
cvui::text (frame, 110 , 80 , " Hello, world! " );
cvui::text (frame, 110 , 120 , " cvui is awesome! " );
// Update cvui stuff and show everything on the screen
cvui::imshow (WINDOW_NAME, frame);
if ( cv::waitKey ( 20 ) == 27 ) {
break ;
}
}
return 0 ;
}การใช้งานใน Python:
import numpy as np
import cv2
import cvui
WINDOW_NAME = 'CVUI Hello World!'
# Create a frame where components will be rendered to.
frame = np . zeros (( 200 , 500 , 3 ), np . uint8 )
# Init cvui and tell it to create a OpenCV window, i.e. cv2.namedWindow(WINDOW_NAME).
cvui . init ( WINDOW_NAME )
while True :
# Fill the frame with a nice color
frame [:] = ( 49 , 52 , 49 )
# Render UI components to the frame
cvui . text ( frame , 110 , 80 , 'Hello, world!' )
cvui . text ( frame , 110 , 120 , 'cvui is awesome!' )
# Update cvui stuff and show everything on the screen
cvui . imshow ( WINDOW_NAME , frame )
if cv2 . waitKey ( 20 ) == 27 :
break ลิขสิทธิ์ (C) 2016 Fernando Bevilacqua ได้รับใบอนุญาตภายใต้ใบอนุญาต MIT
ดูการเปลี่ยนแปลงทั้งหมดในไฟล์ Changelog