Visualizzazione post con etichetta computer vision. Mostra tutti i post
Visualizzazione post con etichetta computer vision. Mostra tutti i post

martedì 13 dicembre 2016

How to read a image sequence with OpenCV


This rough post contains information about the stored image sequence management for still images processing in OpenCV. This post is a reminder, not a tutorial.

Simple assumptions


  • Your image sequence contains images with file name like this: image000001.png. Normally you store images with this sequential file name convention (consider also the case of auto file naming)
  • Your images are in png format (It is only for this example)
  • Your folder absolute path is /folder1/folder2/folder3/ (please consider that Unix and Win paths are different, so use carefully the \ or / chars)


ImageList file

you can use the image list file creator inside the opencv samples, to build a xml file containing the list of the images inside the target folder.
Then you can import the list of images as a vector inside your code

VideoCapture

0. some variables
cv::Mat image_frame;
std::string str_sequenceFileName = "/folder1/folder2/folder3/image%06d.png ";

1. create a videocapture object and then open it, check if is opened and eventually send an error on the shell.

cv::VideoCapture videoCapture;
videoCapture.open(str_sequenceFileName); // open the default camera
if (!videoCapture.isOpened()) {  // check if we succeeded
std::cerr << "[EE] opening video capture OFFLINE device" << std::endl;
return -1;
}
}

2. use the videocapture object instance to grab the current frame. the videocapture grabs the frame from the image sequence folder. You can use it directly inside your main image processing loop.

videoCapture >> image_frame;

Glob

0. some variables
cv::String str_sequenceFolder = "/folder1/folder2/folder3"
cv::String glob_folder = str_sequenceFolder + "/*.png";
std::vector<cv::String> imageFileNamesList;
imageFileNamesList.clear();
cv::Mat image_frame;

1. fill the vector with the image names inside the sequence folder, to obtain the image names list vector

cv::glob(glob_folder, imageFileNamesList);

2. sort the vector (maybe it is not useful)

std::sort(imageFileNamesList.begin(), imageFileNamesList.end());

3. read the current image from the sequence folder

for (int n_frameNumber=0; n_frameNumber < imageFileNamesList.size(); ++n_frameNumber) 
{
    image_frame = cv::imread(imageFileNamesList[n_frameNumber]);
    //some image processing
}

venerdì 22 novembre 2013

Riviste Computer Vision


Breve lista in continuo aggiornamento di riviste su computer vision, pattern recognition o altro di interessante

Pattern Analysis and Machine Intelligence, IEEE Transactions on
http://ieeexplore.ieee.org/xpl/RecentIssue.jsp?punumber=34
2012 if 4.795

International Journal of Computer Visionhttp://www.springer.com/computer/image+processing/journal/11263
2012 Impact Factor 3.623

Machine Vision and Applications
http://www.springer.com/computer/image+processing/journal/138
2012 Impact Factor 1.103

Pattern Recognition Letters
http://www.journals.elsevier.com/pattern-recognition-letters/
2011 IF 2.501
http://journalinsights.elsevier.com/journals/0167-8655/impact

Pattern Recognitionhttp://www.journals.elsevier.com/pattern-recognition/
2011 if 2.632
http://journalinsights.elsevier.com/journals/0031-3203/impact_factor

Machine Learning
2012 if 1.454
http://www.springer.com/computer/ai/journal/10994

martedì 17 settembre 2013

Conversioni per sequenze di immagini

conversion from images sequence to video and viceversa.

FFMPEG

from video to image sequence

ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpeg
 
viceversa, from images to video

ffmpeg -f image2 -i outimage%03d.png -r 12 -qscale 0 foo.avi
 

-sameq does not mean same quality, you have to use -qscale 0 

pay attention to the difference between linux and win operating systems.

reference:
http://www.ffmpeg.org/ffmpeg.html

venerdì 17 maggio 2013

Opencv Mat e GpuMAt

Come si passa da una all'altra, e come associarle, si non sono i termini corretti, ma non è un blog didattico, serve solo per tenere scritte alcune cose base.


cv::Mat image = cv::imread(imageName, CV_LOAD_IMAGE_COLOR);
cv::gpu::GpuMat gpu_image(image);
cv::imshow("image", image);

altro modo (http://stackoverflow.com/questions/9318388/opencv-gpumat-usage)

Mat src;
src = cv::imread("...");
GpuMat dst;
dst.upload(&src);

secondo approccio (http://stackoverflow.com/questions/6965465/how-to-convert-gpumat-to-cvmat-in-opencv)


explicit conversion: Mat -> GPUMat
Mat myMat;
GpuMat myGpuMat;
myGpuMat.upload(myMat); //Via a member function
//Or
GpuMat myGpuMat(myMat) //Via a constructor
 //Use myGpuMat here...

implicit conversion: GpuMat -> Mat
GpuMat myGpuMat;
 Mat myMat = myGpyMat; //Use myMat here...

giovedì 16 maggio 2013

Installa OpenCV ubuntu 12.04

Brevemente per passi come installare opencv su ubuntu 12.04
brevemente perchè questo post è sicuramente da migliorare

Per esempio usiamo ubuntu 12.04
con partizione dati /media/data/qualcosa
con opencv 2.4.5

questa procedura potrebbe andare bene per ogni distro linux

1. scaricare l'ultima versione di opencv dalla pagina ufficiale www.opencv.org

2. il file per linux è un tar.gz, opencv-2.4.5.tar.gz salvarlo in una cartella del filesystem, tenendo conto che questa cartella non va rimossa, meglio se inserita in una parte del filesystem in cui si ha accesso in lettura/scrittura con utente normale, la cartella estratta potrebbe essere /media/data/qualcosa/opencv-2.4.5

3. all'interno della cartella scompattata creare la cartella build, in cui si compila opencv
cd /media/data/qualcosa/opencv-2.4.5
mkdir build
All'interno della cartella build bisogna configurare il makefile, si fa tramite l'utility cmake, deve essere installata nel sistema la versione > 2.8

4. selezionare con 
ccmake ..
le impostazioni per la generazione del makefile che verrà utilizzato per compilare le librerie

5. una volta selezionate tutte le opzioni desiderate premere c per configurare

6. finito premere g per generare il makefile

7. make 

8. sudo make install

9. le librerie sono installate nel sistema operativo

10. sudo ldconfig per configurare pkg config

11. si può controllare la giusta configurazione di pkg config mediante 
pkg-config --libs --cflags opencv

per installare la versione aggiornata, prima di eseguire tutti i passi,
andare nella cartella build delle vecchie librerie e fare
sudo make uninstall

mercoledì 28 novembre 2012

OpenCV su Windows con Visual Studio

per installare opencv su windows con Visual Studio

1. installare opencv: scaricando dal sito il file eseguibile
2. installare opencv in una cartella non di sistema, così non ci sono problemi di permessi
3. aggiornare la variabile PATH del sistema, mettendo la cartella in cui sono presenti sia le dll che le lib

4. dentro a visual studio inserire nel progetto

  • indicazione della cartella degli header D:\opencv...\include
  • indicazione della cartella dei file .lib D:\opencv...\lib
  • elenco dei file lib che si usano (che sono differenti per compilazione in debug e per compilazione in release, si distinguono dalla d finale prima dell'estensione.) 
meglio dare una riavviata prima di usare il codice, per fissare la variabile path.