Automatic Fish Counting in Aquariums Francisco João Lourenço Silvério Thesis to obtain the Master of Science Degree in Electrical and Computer Engineering Supervisor(s): Prof. João Nuno de Oliveira e Silva Dr. José Almeida Cruz Examination Committee Chairperson: Prof. Nuno Cavaco Gomes Horta Supervisor(s): Prof. João Nuno de Oliveira e Silva Member of the Committee: Prof. Paulo Luis Serras Lobato Correia May 2016 ii TotheonesIlove “Thisisnottheend,Noteventhe beginningoftheend,Buttheend ofthebeginning.” -SirWinstonChurchill iii iv Acknowledgments IwouldfirstliketoexpressmydeepgratitudetoChampalimaudFoundationCentrefortheUnknownfor havinggivenmetheopportunityofdevelopingsuchaninterestingandmotivatingproject. Also,Iwouldliketotakethischancetodemonstratemymostsinceregratitudeanddeepconsidera- tiontomyextremelydedicatedsupervisors. ProfessorJoa˜oNunoSilvawhowasessentialinaccepting me as a Master student of his, for enlightening me with his precious insights, guidance and always act in my best interest. Dr. Jose´ Cruz, who was crucial in guaranteeing the cooperation with Champali- maudFoundation,forhisextremelyimportanttechnicalinputsinthisprojectaswellashisavailabilityto discussanydifficultiesthateventuallycameup. AnaCatarinaCertal,JoanaMonteiroandallthestaffattheChampalimaudFoundationFishFacility fortheirconstantavailabilityandcooperationinvideorecordingofthefish. Ricardo Ribeiro, Carlos Ma˜o-de-Ferro and Alexandre Laborde, who I now consider as friends, for beingsosupportiveandcooperativeduringmycollaborationattheNeurosciences’SoftwarePlatform. AnotherspecialwordofthankfulnessdirectedtothefriendsIhadthepossibilitytomakeatInstituto SuperiorTe´cnico. Idothoroughlybelievethatallthosememorablemomentsandadventuresweshared willneverperishintime. Amongthesefriends,thereareuniquepeoplewhodeserveaspecialmention for the deep friendship. Miguel Cirne with who I had the privilege to meet at the very beginning of mypresenceatInstitutoSuperiorTe´cnicoandworkinextremelydemandingprojectsinwhichwecould alwayssucceedwithdeepcommitmentanddedication. Ididalsohavetheopportunitytoknowandwork with Miguel Fernandes with who I fought so many difficult battles throughout our engineering degree. Thethreeofuscouldlearnandgrowtogetherasengineersbut,aboveall,aspersonsandIbelievethat thisfriendshipwilllast. Itakethisopportunitytoexpressmymostdeepestgratitudetomyspecialone,AnaFerreira. Words arenotenoughtodescribehowspecialandimportantshewasduringmydegree,givingmehersupport, patience,unconditionalloveandbydemonstratingherextremebeliefinmewhenIneededitthemost. Finally, I conclude with a few words for my family. First I would like to express my gratitude to my brother Joa˜o for representing an example for me of the engineer I would like to be one day, for the technicalhelphecouldprovidemeduringthepastyearsandforbeingthereformeasanolderbrother. To my sister Joana, who always stood beside me as a second mother from the very beginning of my academic path and for the constant encouragement and motivation she could always transmit to me. Por u´ltimo escrevo umas palavras para a minha ma˜e, Irene assim como para o meu pai, Fernando. E´ aos meus pais que devo tudo aquilo que consegui alcanc¸ar ate´ hoje tanto a n´ıvel pessoal como profissional. Semoseuapoio,incentivo,exemplo,sacrif´ıcio,plenaconfianc¸anasminhascapacidadese asuapreocupac¸a˜oconstantecomaminhaeducac¸a˜o,na˜oteriasidoposs´ıvelconcluirestata˜ohe´rculea etapa. E´ destaforma,agradecendoecomorgulho,quelhesdedicoestadissertac¸a˜o. Obrigado. v vi Resumo Fishfacilitiesportodoomundorecorremapeixeszebra(zebrafish)paraefectuarexperieˆncias. Aolongo da sua vida, os peixes zebra sa˜o mantidos em aqua´rios e necessitam de ser contados, manualmente, oqueconstituiumatarefamorosaequeesta´ sujeitaaerros. Estetrabalhoapresentaumsistemaautoma´ticodecontagemdepeixeseumalgoritmobaseadoem visa˜ocomputacionalpararealizaratarefa. Oalgoritmoutilizate´cnicasstandarddevisa˜ocomputacional como subtrac¸a˜o de fundo, isolamento de blobs e compensac¸a˜o de reflexo˜es de forma a realizar uma contagem mais precisa. Dado que as fish facilities teˆm mu´ltiplas categorias de peixes, o algoritmo propostofoicalibradoparagarantirosmelhoresresultadosparamaisdoqueumacategoria. Esteprojectoincluitambe´modesign,desenvolvimentoeimplementac¸a˜odeumsistemadehardware completocomoobjectivodeadquirirvideosdepeixesdentrodeaqua´rios. Experieˆnciasrealizadasem amostrasdevideoreaisdemonstramqueoalgoritmopropostoestimacomsucessoonu´merodepeixes num tanque com uma margem de erro de aproximadamente 15% do nu´mero real. Relativamente ao tempodeexecuc¸a˜odoalgoritmo,concluiu-sequeotemponecessa´rioparaestimaronu´merodepeixes e´,emgeral,inferioraotempoquete´cnicosespecializadosdemoramarealizarumacontagemmanual. Como trabalho futuro, a identicac¸a˜o de diferentes tipos de feno´tipos assim como a contagem do nu´merodemachoefeˆmeasemaqua´rios,sa˜oexemplosdeideiasinteressantesquepodemserimple- mentadasnestetipodeaplicac¸o˜es. Palavras-chave: visa˜ocomputacional,contagemdepeixeszebra,subtrac¸a˜odefundo,opti- calflow,momentosdeHu,processamentodeimagem vii viii Abstract Fishfacilitiesaroundtheworldresorttozebrafishtoperformexperiments. Duringtheirlifetime,fishare maintained in tanks and need to be manually counted representing a time consuming and error prone task. This work presents an automatic fish counting setup and a computer vision based algorithm to per- form the task. The algorithm uses image processing methods such as background subtraction, blob isolationandmirroringcompensationtoperformamoreprecisefishcounting. Sincefishfacilitieshavemultiplecategoriesoffish,theproposedalgorithmwascalibratedtoguaran- tee the best results for more than one category. Moreover, this project does also comprise the design, developmentandimplementationofafullhardwaresetupforthevideorecordingoffishinsidetanks. Experimentsonrealvideosamplesshowthattheproposedalgorithmcansuccessfullyestimatethe numberoffishinatankwithanerrormarginbelow15%oftherealfishnumberinsideatank. Regarding algorithm execution time, we could conclude that the time needed to output an estimate ofthenumberoffishinatankislowerthanthemanualcountingperformedbytechnicians. Infuturework, theidentificationofmultiplephenotypesaswellascountingthenumberofmaleand femaleinsidetanks,areexamplesofveryinterestingideaswhichshouldbeimplementedinthistypeof solution. Keywords: computer vision, zebrafish counting, background subtraction, optical flow, Hu mo- ments,imageprocessing ix x
Description: