An warware: yadda ake daidaita opencv c++ a cikin ubuntu

OpenCV ɗakin karatu ne mai buɗewa wanda ya haɗa da ɗaruruwan hangen nesa na kwamfuta. Kuna iya amfani da shi don aiwatar da hotuna da bidiyo don gano fuskoki, gano abubuwa, rarraba ayyukan ɗan adam a cikin bidiyo, waƙa da motsin kyamara, bin abubuwan motsi, da sauransu. Laburaren yana da ingantattun algorithms sama da 2500, wanda shine cikakken saiti don ayyukan hangen nesa na kwamfuta. .

Don haɗa OpenCV C++ a cikin Ubuntu, kuna buƙatar bin takamaiman matakai waɗanda aka zayyana a ƙasa.

Abubuwan da ake bukata da Shirye-shirye

Shigar da OpenCV akan Ubuntu yana buƙatar yanayin ci gaba. Yanayin ci gaba shine haɗin software da saitunan da kuke amfani da su don ƙirƙirar aikace-aikace.

Da farko, kana buƙatar shigar da mai tarawa wanda ke goyan bayan C++. Ga Ubuntu, mai tarawa shine GCC, wanda zaku iya girka ta Cibiyar Software ta Ubuntu. Hakanan kuna buƙatar ɗakin karatu na software wanda ke goyan bayan GUI (hanyar mai amfani da hoto), kamar GTK.

Na biyu, kuna buƙatar shigar da laburaren da ake buƙata don OpenCV:

  • Libavcodec
  • Libavformat
  • Libswscale

Waɗannan ɗakunan karatu suna ba da tallafin multimedia, suna ba ku damar karanta fayilolin bidiyo da hotuna ta nau'i daban-daban.

sudo dace-samun shigar gina-mahimmanci libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev

Zazzage kuma shigar da OpenCV

Zazzage OpenCV daga rukunin yanar gizon. Cire shi kuma ƙirƙirar sabon kundin adireshi 'gina' a cikin kundin adireshin OpenCV da aka fitar.

cd ~/Zazzagewa/opencv-xx.xx.x/
mkdir ginawa
cd gina

Yanzu, zaku iya tattarawa da shigar da OpenCV.

cmake -D CMAKE_BUILD_TYPE=SAKI -D CMAKE_INSTALL_PREFIX=/usr/local ..
yi
sudo shigar

Rubutun da Gudun OpenCV Code

Anan akwai misalin lambar C++ mai sauƙi wanda ke loda hoto, kuma yana nuna shi:

#include
#include

int main ()
{
cv:: Mat img = cv:: imread("image.jpg",1);
cv :: mai suna Window ("Window", cv :: WINDOW_NORMAL);
cv :: imshow ("Window", img);
cv::waitKey(0);
dawo 0;
}

Don haɗawa da gudanar da lambar OpenCV ɗin ku, zaku iya amfani da umarni mai zuwa:

g++ `pkg-config –cflags –libs opencv` example.cpp -o misali
./misali

Yanzu kun shirya don tattarawa, gudanar da haɓaka aikace-aikacen OpenCV C++ akan Ubuntu.

Fahimtar Code

The imread() Aiki yana karanta fayil ɗin hoton daga ƙayyadadden wuri kuma yana adana shi a cikin 'img' matt abu. Da mai suna Window() Aiki yana ƙirƙirar taga inda za'a nuna hoton. The imshow() Aiki yana nuna hoton a cikin taga mai suna. jiran key(0) yana jiran mai amfani ya danna kowane maɓalli. Wannan ya zama dole don kiyaye shirin daga ƙarewa nan da nan.

Ina fatan labarin ya taimaka wajen farawa da aiki da sauri tare da OpenCV a cikin yanayin Ubuntu. Ci gaba da gwadawa da bincika ƙarin ayyuka da fasalulluka na OpenCV.

Tukwici da Shirya matsala

Wani lokaci, kuna iya fuskantar matsaloli yayin tattarawa ko gudanar da lambar. Ga wasu batutuwan gama gari da hanyoyin magance su:

Kuskure yayin yin: Tabbatar cewa an shigar da duk ɗakunan karatu da ake buƙata daidai. Duba daidaiton sigar.

Kuskuren buɗe fayil a cikin imread(): Tabbatar cewa fayil ɗin hoton yana cikin madaidaicin wuri kuma an ƙayyade hanyar fayil daidai a cikin aikin 'imread()'.

Ka tuna, aiki da juriya sune maɓalli yayin shiga cikin sabbin yankuna kamar haɗa OpenCV C++ a cikin Ubuntu. Ci gaba da bincike da yin rikodin farin ciki!

Shafi posts:

Leave a Comment