ÉèÖÃLinuxϵͳÒÔÖ§³ÖʵʱͼÏñ´¦Öóͷ£ÓëÅÌËã»úÊÓ¾õ¿ª·¢
ÉèÖÃlinuxϵͳÒÔÖ§³ÖʵʱͼÏñ´¦Öóͷ£ÓëÅÌËã»úÊÓ¾õ¿ª·¢
СÐò£º
ÅÌËã»úÊÓ¾õ×÷ΪÈ˹¤ÖÇÄܵÄÖ÷Òª·ÖÖ§Ö®Ò»£¬½üÄêÀ´ÔÚ¸÷¸öÁìÓò¶¼È¡µÃÁËÖØ´óµÄÉú³¤¡£ÊµÏÖʵʱͼÏñ´¦Öóͷ£ºÍÅÌËã»úÊÓ¾õ¿ª·¢ÐèÒªÒ»¸öÇ¿Ê¢µÄƽ̨À´Ö§³Ö£¬¶øLinuxϵͳ×÷ΪһÖÖ×ÔÓÉ¿ª·ÅÇÒ¹¦Ð§Ç¿Ê¢µÄ²Ù×÷ϵͳ£¬³ÉΪÁË¿ª·¢ÕßÃǵÄÊ×Ñ¡¡£±¾ÎĽ«ÏÈÈÝÔõÑùÉèÖÃlinuxϵͳÒÔÖ§³ÖʵʱͼÏñ´¦Öóͷ£ÓëÅÌËã»úÊÓ¾õ¿ª·¢£¬²¢Ìṩ´úÂëʾÀý¹©¶ÁÕ߲ο¼¡£
Ò»¡¢×°ÖÃLinuxϵͳ£º
Ê×ÏÈ£¬ÎÒÃÇÐèҪѡÔñÒ»¸öÊʺϵÄLinux¿¯Ðа沢¾ÙÐÐ×°Öᣳ£¼ûµÄLinux¿¯ÐаæÓÐUbuntu¡¢CentOS¡¢FedoraµÈ£¬ÎÒÃÇ¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóºÍϲ»¶Ñ¡ÔñÆäÖÐÖ®Ò»¡£
¶þ¡¢×°ÖÃÐëÒªµÄÒÀÀµ¿âºÍ¹¤¾ß£º
ÔÚ×îÏȾÙÐÐʵʱͼÏñ´¦Öóͷ£ºÍÅÌËã»úÊÓ¾õ¿ª·¢Ö®Ç°£¬ÎÒÃÇÐèҪװÖÃһЩÐëÒªµÄÒÀÀµ¿âºÍ¹¤¾ß¡£ÒÔÏÂÊÇһЩ³£ÓõÄÒÀÀµ¿âºÍ¹¤¾ß£¬¶ÁÕß¿ÉÒÔƾ֤×Ô¼ºµÄÐèÒª¾ÙÐÐ×°Öá£
OpenCV£ºOpenCVÊÇÒ»¸ö¿ªÔ´µÄÅÌËã»úÊÓ¾õ¿â£¬ÌṩÁ˸»ºñµÄͼÏñ´¦Öóͷ£ºÍÅÌËã»úÊÓ¾õËã·¨¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃOpenCV£º
sudo apt-get install libopencv-dev
µÇ¼ºó¸´ÖÆ
NumPy£ºNumPyÊÇPythonÓïÑÔÖÐÓÃÓÚ¿ÆѧÅÌËãµÄÒ»¸ö¿â£¬ÌṩÁ˸ßÐÔÄܵĶàάÊý×éºÍ¾ØÕó²Ù×÷¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃNumPy£º
sudo apt-get install python-numpy
µÇ¼ºó¸´ÖÆ
cmake£ºcmakeÊÇÒ»¸ö¿çƽ̨µÄ×Ô¶¯»¯¹¹½¨¹¤¾ß£¬ÎÒÃÇ¿ÉÒÔʹÓÃËüÀ´±àÒëºÍ×°ÖÃһЩÐèÒªÊÖ¶¯±àÒëµÄ¿â¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃcmake£º
sudo apt-get install cmake
µÇ¼ºó¸´ÖÆ
Èý¡¢ÉèÖÿª·¢ÇéÐΣº
ÔÚÉèÖÿª·¢ÇéÐÎ֮ǰ£¬ÎÒÃÇÐèҪȷ¶¨×Ô¼ºËùʹÓõĿª·¢ÓïÑÔ¡£³£¼ûµÄÅÌËã»úÊÓ¾õ¿ª·¢ÓïÑÔÓÐC++ºÍPython£¬ÎÒÃÇ¿ÉÒÔƾ֤×Ô¼ºµÄϲ»¶ºÍÊìϤˮƽѡÔñÆäÖÐÖ®Ò»¡£
C++¿ª·¢ÇéÐÎÉèÖãº
ÈôÊÇÎÒÃÇÑ¡ÔñʹÓÃC++¾ÙÐпª·¢£¬ÎÒÃÇÐèҪװÖÃÒ»¸öC++±àÒëÆ÷ºÍÒ»¸ö¼¯³É¿ª·¢ÇéÐΣ¨IDE£©¡£³£ÓõÄC++±àÒëÆ÷ÓÐGCCºÍClang£¬³£ÓõÄIDEÓÐCode::Blocks¡¢EclipseµÈ¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃGCC±àÒëÆ÷£º
sudo apt-get install g++
µÇ¼ºó¸´ÖÆ
Python¿ª·¢ÇéÐÎÉèÖãº
ÈôÊÇÎÒÃÇÑ¡ÔñʹÓÃPython¾ÙÐпª·¢£¬ÎÒÃÇÐèҪװÖÃPythonÚ¹ÊÍÆ÷ºÍÒ»¸öPython¿ª·¢ÇéÐΡ£³£ÓõÄPythonÚ¹ÊÍÆ÷ÓÐPython 2ºÍPython 3£¬ÎÒÃÇ¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóÑ¡ÔñÆäÖÐÖ®Ò»¡£³£ÓõÄPython¿ª·¢ÇéÐÎÓÐPyCharm¡¢Jupyter NotebookµÈ¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏÂÏÂÁî×°ÖÃPythonÚ¹ÊÍÆ÷ºÍpip°ü¹ÜÀí¹¤¾ß£º
sudo apt-get install python python-pip
µÇ¼ºó¸´ÖÆ
½ÓÏÂÀ´£¬ÎÒÃÇ¿ÉÒÔʹÓÃpipÀ´×°ÖÃһЩ³£ÓõÄPython¿â£¬ºÃ±È£º
pip install numpy opencv-python
µÇ¼ºó¸´ÖÆ
ËÄ¡¢´úÂëʾÀý£º
ÔÚÍê³ÉÒÔÉÏÉèÖÃÖ®ºó£¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ´úÂëʾÀýÀ´¾ÙÐÐʵʱͼÏñ´¦Öóͷ£ºÍÅÌËã»úÊÓ¾õ¿ª·¢¡£
C++ʾÀý´úÂ룺
#include <iostream> #include <opencv2/opencv.hpp> int main() { cv::VideoCapture cap(0); if (!cap.isOpened()) { std::cout << "Failed to open camera" << std::endl; return -1; } cv::Mat frame; while (cap.read(frame)) { cv::imshow("Camera", frame); if (cv::waitKey(30) == 'q') { break; } } cap.release(); cv::destroyAllWindows(); return 0; }
µÇ¼ºó¸´ÖÆ
PythonʾÀý´úÂ룺
import cv2 cap = cv2.VideoCapture(0) if not cap.isOpened(): print("Failed to open camera") exit(1) while True: ret, frame = cap.read() if not ret: print("Failed to read frame") break cv2.imshow("Camera", frame) if cv2.waitKey(30) == ord('q'): break cap.release() cv2.destroyAllWindows()
µÇ¼ºó¸´ÖÆ
ÒÔÉÏ´úÂëʾÀýʹÓÃOpenCV¿âÀ´ÊµÊ±·¿ªÉãÏñÍ·²¢ÏÔʾÉãÏñÍ·²¶»ñµÄͼÏñ£¬ÈôÊÇ°´Ï¼üÅÌÉϵġ°q¡±¼ü£¬ÔòÍ˳ö³ÌÐò¡£
½áÂÛ£º
ͨ¹ýÒÔÉϵÄÉèÖúʹúÂëʾÀý£¬ÎÒÃÇ¿ÉÒÔÀÖ³ÉʵÏÖLinuxϵͳµÄʵʱͼÏñ´¦Öóͷ£ºÍÅÌËã»úÊÓ¾õ¿ª·¢¡£¶ÁÕß¿ÉÒÔƾ֤×Ô¼ºµÄÐèÇóºÍÐËȤ½øÒ»²½Ñ§Ï°ºÍ̽Ë÷¸ü¶àµÄÅÌËã»úÊÓ¾õËã·¨ºÍÊÖÒÕ¡£
ÒÔÉϾÍÊÇÉèÖÃLinuxϵͳÒÔÖ§³ÖʵʱͼÏñ´¦Öóͷ£ÓëÅÌËã»úÊÓ¾õ¿ª·¢µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡