Hello everyone,
I am using cv::grabcut to remove the background from the face photos, but it seems, that it ruins my code. I am using OpenCV 3.4.2 and valgrind is showing me following issue:
<?xml version="1.0"?>
<valgrindoutput>
<protocolversion>4</protocolversion>
<protocoltool>memcheck</protocoltool>
<preamble>
<line>Memcheck, a memory error detector</line>
<line>Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.</line>
<line>Using Valgrind-3.13.0 and LibVEX; rerun with -h for copyright info</line>
<line>Command: /home/ben/Development/OpenCV_tests/cmake-build-release/OpenCV_tests Orbik_3_combination</line>
</preamble>
<pid>23545</pid>
<ppid>765</ppid>
<tool>memcheck</tool>
<args>
<vargv>
<exe>/usr/bin/valgrind.bin</exe>
<arg>--tool=memcheck</arg>
<arg>--xml=yes</arg>
<arg>--xml-file=/tmp/valgrind</arg>
<arg>--gen-suppressions=all</arg>
<arg>--leak-check=full</arg>
<arg>--leak-resolution=med</arg>
<arg>--track-origins=yes</arg>
</vargv>
<argv>
<exe>/home/ben/Development/OpenCV_tests/cmake-build-release/OpenCV_tests</exe>
<arg>Orbik_3_combination</arg>
</argv>
</args>
<status>
<state>RUNNING</state>
<time>00:00:00:00.087 </time>
</status>
<status>
<state>FINISHED</state>
<time>00:00:42:50.777 </time>
</status>
<error>
<unique>0xa65</unique>
<tid>1</tid>
<kind>Leak_PossiblyLost</kind>
<xwhat>
<text>2,576 bytes in 7 blocks are possibly lost in loss record 2,662 of 2,701</text>
<leakedbytes>2576</leakedbytes>
<leakedblocks>7</leakedblocks>
</xwhat>
<stack>
<frame>
<ip>0x4C31B25</ip>
<obj>/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so</obj>
<fn>calloc</fn>
</frame>
<frame>
<ip>0x40134A6</ip>
<obj>/lib/x86_64-linux-gnu/ld-2.27.so</obj>
<fn>allocate_dtv</fn>
<dir>/build/glibc-OTsEL5/glibc-2.27/elf/../elf</dir>
<file>dl-tls.c</file>
<line>286</line>
</frame>
<frame>
<ip>0x40134A6</ip>
<obj>/lib/x86_64-linux-gnu/ld-2.27.so</obj>
<fn>_dl_allocate_tls</fn>
<dir>/build/glibc-OTsEL5/glibc-2.27/elf/../elf</dir>
<file>dl-tls.c</file>
<line>530</line>
</frame>
<frame>
<ip>0xBD86227</ip>
<obj>/lib/x86_64-linux-gnu/libpthread-2.27.so</obj>
<fn>allocate_stack</fn>
<dir>/build/glibc-OTsEL5/glibc-2.27/nptl</dir>
<file>allocatestack.c</file>
<line>627</line>
</frame>
<frame>
<ip>0xBD86227</ip>
<obj>/lib/x86_64-linux-gnu/libpthread-2.27.so</obj>
<fn>pthread_create@@GLIBC_2.2.5</fn>
<dir>/build/glibc-OTsEL5/glibc-2.27/nptl</dir>
<file>pthread_create.c</file>
<line>644</line>
</frame>
<frame>
<ip>0x8B2C044</ip>
<obj>/usr/local/lib/libopencv_core.so.3.4.2</obj>
<fn>cv::WorkerThread::WorkerThread(cv::ThreadPool&, unsigned int)</fn>
</frame>
<frame>
<ip>0x8B2D851</ip>
<obj>/usr/local/lib/libopencv_core.so.3.4.2</obj>
<fn>cv::ThreadPool::reconfigure_(unsigned int)</fn>
</frame>
<frame>
<ip>0x8B2E7EC</ip>
<obj>/usr/local/lib/libopencv_core.so.3.4.2</obj>
<fn>cv::parallel_for_pthreads(cv::Range const&, cv::ParallelLoopBody const&, double)</fn>
</frame>
<frame>
<ip>0x8B2A51C</ip>
<obj>/usr/local/lib/libopencv_core.so.3.4.2</obj>
<fn>cv::parallel_for_(cv::Range const&, cv::ParallelLoopBody const&, double)</fn>
</frame>
<frame>
<ip>0x89E09FA</ip>
<obj>/usr/local/lib/libopencv_core.so.3.4.2</obj>
<fn>cv::kmeans(cv::_InputArray const&, int, cv::_InputOutputArray const&, cv::TermCriteria, int, int, cv::_OutputArray const&)</fn>
</frame>
<frame>
<ip>0x61FB3E4</ip>
<obj>/usr/local/lib/libopencv_imgproc.so.3.4.2</obj>
<fn>cv::grabCut(cv::_InputArray const&, cv::_InputOutputArray const&, cv::Rect_<int>, cv::_InputOutputArray const&, cv::_InputOutputArray const&, int, int)</fn>
</frame>
<frame>
<ip>0x12FB28</ip>
<obj>/home/ben/Development/OpenCV_tests/cmake-build-release/OpenCV_tests</obj>
<fn>filterAndCutImage(cv::Mat const&, cv::Mat&, cv::Size_<int> const&)</fn>
</frame>
<frame>
<ip>0x1283DC</ip>
<obj>/home/ben/Development/OpenCV_tests/cmake-build-release/OpenCV_tests</obj>
<fn>validateParameter(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::vector<cv::Mat, std::allocator<cv::Mat> > const&, std::vector<int, std::allocator<int> > const&, cv::Size_<int> const&, cv::Size_<int> const&)</fn>
</frame>
<frame>
<ip>0x111176</ip>
<obj>/home/ben/Development/OpenCV_tests/cmake-build-release/OpenCV_tests</obj>
<fn>main</fn>
</frame>
</stack>
<suppression>
<sname>insert_a_suppression_name_here</sname>
<skind>Memcheck:Leak</skind>
<skaux>match-leak-kinds: possible</skaux>
<sframe> <fun>calloc</fun> </sframe>
<sframe> <fun>allocate_dtv</fun> </sframe>
<sframe> <fun>_dl_allocate_tls</fun> </sframe>
<sframe> <fun>allocate_stack</fun> </sframe>
<sframe> <fun>pthread_create@@GLIBC_2.2.5</fun> </sframe>
<sframe> <fun>_ZN2cv12WorkerThreadC1ERNS_10ThreadPoolEj</fun> </sframe>
<sframe> <fun>_ZN2cv10ThreadPool12reconfigure_Ej</fun> </sframe>
<sframe> <fun>_ZN2cv21parallel_for_pthreadsERKNS_5RangeERKNS_16ParallelLoopBodyEd</fun> </sframe>
<sframe> <fun>_ZN2cv13parallel_for_ERKNS_5RangeERKNS_16ParallelLoopBodyEd</fun> </sframe>
<sframe> <fun>_ZN2cv6kmeansERKNS_11_InputArrayEiRKNS_17_InputOutputArrayENS_12TermCriteriaEiiRKNS_12_OutputArrayE</fun> </sframe>
<sframe> <fun>_ZN2cv7grabCutERKNS_11_InputArrayERKNS_17_InputOutputArrayENS_5Rect_IiEES5_S5_ii</fun> </sframe>
<sframe> <fun>_Z17filterAndCutImageRKN2cv3MatERS0_RKNS_5Size_IiEE</fun> </sframe>
<sframe> <fun>_Z17validateParameterRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_RKSt6vectorIN2cv3MatESaIS9_EERKS7_IiSaIiEERKNS8_5Size_IiEESL_</fun> </sframe>
<sframe> <fun>main</fun> </sframe>
<rawtext>
<![CDATA[
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: possible
fun:calloc
fun:allocate_dtv
fun:_dl_allocate_tls
fun:allocate_stack
fun:pthread_create@@GLIBC_2.2.5
fun:_ZN2cv12WorkerThreadC1ERNS_10ThreadPoolEj
fun:_ZN2cv10ThreadPool12reconfigure_Ej
fun:_ZN2cv21parallel_for_pthreadsERKNS_5RangeERKNS_16ParallelLoopBodyEd
fun:_ZN2cv13parallel_for_ERKNS_5RangeERKNS_16ParallelLoopBodyEd
fun:_ZN2cv6kmeansERKNS_11_InputArrayEiRKNS_17_InputOutputArrayENS_12TermCriteriaEiiRKNS_12_OutputArrayE
fun:_ZN2cv7grabCutERKNS_11_InputArrayERKNS_17_InputOutputArrayENS_5Rect_IiEES5_S5_ii
fun:_Z17filterAndCutImageRKN2cv3MatERS0_RKNS_5Size_IiEE
fun:_Z17validateParameterRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_RKSt6vectorIN2cv3MatESaIS9_EERKS7_IiSaIiEERKNS8_5Size_IiEESL_
fun:main
}
]]>
</rawtext>
</suppression>
</error>
<suppression>
<sname>insert_a_suppression_name_here</sname>
<skind>Memcheck:Leak</skind>
<skaux>match-leak-kinds: possible</skaux>
<sframe> <fun>calloc</fun> </sframe>
<sframe> <fun>allocate_dtv</fun> </sframe>
<sframe> <fun>_dl_allocate_tls</fun> </sframe>
<sframe> <fun>allocate_stack</fun> </sframe>
<sframe> <fun>pthread_create@@GLIBC_2.2.5</fun> </sframe>
<sframe> <fun>_ZN2cv12WorkerThreadC1ERNS_10ThreadPoolEj</fun> </sframe>
<sframe> <fun>_ZN2cv10ThreadPool12reconfigure_Ej</fun> </sframe>
<sframe> <fun>_ZN2cv21parallel_for_pthreadsERKNS_5RangeERKNS_16ParallelLoopBodyEd</fun> </sframe>
<sframe> <fun>_ZN2cv13parallel_for_ERKNS_5RangeERKNS_16ParallelLoopBodyEd</fun> </sframe>
<sframe> <fun>_ZN2cv6kmeansERKNS_11_InputArrayEiRKNS_17_InputOutputArrayENS_12TermCriteriaEiiRKNS_12_OutputArrayE</fun> </sframe>
<sframe> <fun>_ZN2cv7grabCutERKNS_11_InputArrayERKNS_17_InputOutputArrayENS_5Rect_IiEES5_S5_ii</fun> </sframe>
<sframe> <fun>_Z17filterAndCutImageRKN2cv3MatERS0_RKNS_5Size_IiEE</fun> </sframe>
<sframe> <fun>_Z17validateParameterRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_RKSt6vectorIN2cv3MatESaIS9_EERKS7_IiSaIiEERKNS8_5Size_IiEESL_</fun> </sframe>
<sframe> <fun>main</fun> </sframe>
<rawtext>
<![CDATA[
{
<insert_a_suppression_name_here>
Memcheck:Leak
match-leak-kinds: possible
fun:calloc
fun:allocate_dtv
fun:_dl_allocate_tls
fun:allocate_stack
fun:pthread_create@@GLIBC_2.2.5
fun:_ZN2cv12WorkerThreadC1ERNS_10ThreadPoolEj
fun:_ZN2cv10ThreadPool12reconfigure_Ej
fun:_ZN2cv21parallel_for_pthreadsERKNS_5RangeERKNS_16ParallelLoopBodyEd
fun:_ZN2cv13parallel_for_ERKNS_5RangeERKNS_16ParallelLoopBodyEd
fun:_ZN2cv6kmeansERKNS_11_InputArrayEiRKNS_17_InputOutputArrayENS_12TermCriteriaEiiRKNS_12_OutputArrayE
fun:_ZN2cv7grabCutERKNS_11_InputArrayERKNS_17_InputOutputArrayENS_5Rect_IiEES5_S5_ii
fun:_Z17filterAndCutImageRKN2cv3MatERS0_RKNS_5Size_IiEE
fun:_Z17validateParameterRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEES6_RKSt6vectorIN2cv3MatESaIS9_EERKS7_IiSaIiEERKNS8_5Size_IiEESL_
fun:main
}
]]>
</rawtext>
</suppression>
<errorcounts>
</errorcounts>
<suppcounts>
</suppcounts>
</valgrindoutput>
Is there any other algorithm in OpenCV which would allow me the image background segmentation? I am doing it based on the single image, so something like BackgroundSubtractorMOG2
will not be of much use here.