Quantcast
Channel: OpenCV Q&A Forum - RSS feed
Viewing all 41027 articles
Browse latest View live

Opencv findCountours is not find all contours

$
0
0
I'm trying to find the contours of this image, but the method findContours only returns 1 contour, the contour is highlighted in image 2. I'm trying to find all external contours like these circles where the numbers are inside. What am i doing wrong? What can i do to accomplish it? ![image description](/upfiles/15337399138826449.png) image 1 ![image description](/upfiles/15337399282312009.png) image 2 Below is the relevant portion of my code. thresh = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY_INV | cv2.THRESH_OTSU)[1] cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)

How to crop the image as wide as possible?

$
0
0
I want to be able to crop any image with the smallest bounding box possible. Example: ![image description](/upfiles/15337462065346094.jpg) I have the "a" image and want to crop the image with the smallest rectangle that encompasses my image.

Is VS2018 supported for development?

$
0
0
I just forked on github and cloned with VS2018 enterprise. It seems many solutions contain files that throw version incompatibility errors, or throw version incompatibility errors themselves. Is VS development at all supported? If so, how are these errors generally resolved? EDIT: The default VS update procedure does not seem to be often successful, but I've only looked at a couple of files.

I want the resolution of the capture file to be different from the resolution of the preview.

$
0
0
Hi. I am South Korea Student. I'm sorry I did not speak English well. I want the resolution of the capture file to be different from the resolution of the preview. I am using raspberry pi 3 b+ and usb camera, opencv, python. I want capture file resolution (1024, 768) but my LCD resolution (320, 240). The resolution of the preview image on my LCD is (320,240) and when the capture is done, the resolution of the capture file should be saved as (1024, 768). Is this possible? What if I can? Thank you for reading.

UBUNTU 16.04 Opencv 3.3.1 fatal error: cvconfig.h: No such file or directory

$
0
0
I am trying to compile & run the ukf test in the following directory: ~/opencv_contrib/modules/tracking/test/test_ukf.cpp when I try to compile it using ( **g++ test_ukf.cpp** ) command I get: > In file included from> test_ukf.cpp:42:0:> test_precomp.hpp:13:26: fatal error:> opencv2/ts.hpp: No such file or> directory compilation terminated. Then I specify the include directory where ts.hpp exists using : **g++ -o app -I/home/akde/opencv/modules/ts/include/ test_ukf.cpp** But this time I get > In file included from> test_precomp.hpp:13:0,> from test_ukf.cpp:42: /home/akde/opencv/modules/ts/include/opencv2/ts.hpp:22:22:> fatal error: cvconfig.h: No such file> or directory compilation terminated. Finally I searched for the **cvconfig.h** and found it in 2 places: 1-/home/akde/opencv/build/opencv2/cvconfig.h 2-/home/akde/opencv/build/cvconfig.h I specified the locations and compiled using: **g++ -o app -I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build/opencv2 test_ukf.cpp** and **g++ -o app -I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build test_ukf.cpp** and **g++ test_ukf.cpp -o app "pkg-config --cflags --libs opencv" -I/home/akde/opencv/modules/ts/include/ -I/home/akde/opencv/build** This time I get a gigantic error: > /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/crt1.o: In function `_start': (.text+0x20): undefined reference to `main' /tmp/cc1Bc7jy.o: In function `UKF_br_landing_point_Test::TestBody()': test_ukf.cpp:(.text+0x29): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)' test_ukf.cpp:(.text+0x42): undefined reference to `cv::ipp::setIppStatus(int, char const*, char const*, int)' test_ukf.cpp:(.text+0x47): undefined reference to `cv::theRNG()' test_ukf.cpp:(.text+0x51): undefined reference to `cvtest::param_seed' test_ukf.cpp:(.text+0x70): undefined reference to `cvtest::checkIppStatus()' /tmp/cc1Bc7jy.o: In function `UKF_br_landing_point_Test::Body()': test_ukf.cpp:(.text+0x1cd): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x2cf): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x342): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x381): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x414): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x487): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x5ef): undefined reference to `cv::Mat::eye(int, int, int)' test_ukf.cpp:(.text+0x621): undefined reference to `cv::operator*(double, cv::MatExpr const&)' test_ukf.cpp:(.text+0x763): undefined reference to `cv::tracking::UnscentedKalmanFilterParams::UnscentedKalmanFilterParams(int, int, int, double, double, cv::Ptr, int)' test_ukf.cpp:(.text+0x8cc): undefined reference to `cv::tracking::createUnscentedKalmanFilter(cv::tracking::UnscentedKalmanFilterParams const&)' test_ukf.cpp:(.text+0x910): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x9fc): undefined reference to `cv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0xa49): undefined reference to `cv::operator*(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text+0xb1b): undefined reference to `cv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0xb68): undefined reference to `cv::operator*(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text+0xc23): undefined reference to `cv::noArray()' test_ukf.cpp:(.text+0xd45): undefined reference to `testing::internal::DoubleNearPredFormat(char const*, char const*, char const*, double, double, double)' test_ukf.cpp:(.text+0xd6b): undefined reference to `testing::Message::Message()' test_ukf.cpp:(.text+0xd9e): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)' test_ukf.cpp:(.text+0xdb7): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const' test_ukf.cpp:(.text+0xdc6): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x12ef): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_br_mean_squared_error_Test::TestBody()': test_ukf.cpp:(.text+0x148d): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)' test_ukf.cpp:(.text+0x14a6): undefined reference to `cv::ipp::setIppStatus(int, char const*, char const*, int)' test_ukf.cpp:(.text+0x14ab): undefined reference to `cv::theRNG()' test_ukf.cpp:(.text+0x14b5): undefined reference to `cvtest::param_seed' test_ukf.cpp:(.text+0x14d4): undefined reference to `cvtest::checkIppStatus()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_br_mean_squared_error_Test::Body()': test_ukf.cpp:(.text+0x1631): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x1733): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x17a6): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x17e5): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x1878): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x18eb): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x1a6c): undefined reference to `cv::Mat::eye(int, int, int)' test_ukf.cpp:(.text+0x1a9e): undefined reference to `cv::operator*(double, cv::MatExpr const&)' test_ukf.cpp:(.text+0x1be0): undefined reference to `cv::tracking::UnscentedKalmanFilterParams::UnscentedKalmanFilterParams(int, int, int, double, double, cv::Ptr, int)' test_ukf.cpp:(.text+0x1d95): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x1ddf): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x1e37): undefined reference to `cv::tracking::createUnscentedKalmanFilter(cv::tracking::UnscentedKalmanFilterParams const&)' test_ukf.cpp:(.text+0x1f3c): undefined reference to `cv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0x1f89): undefined reference to `cv::operator*(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text+0x205b): undefined reference to `cv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0x20a8): undefined reference to `cv::operator*(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text+0x2163): undefined reference to `cv::noArray()' test_ukf.cpp:(.text+0x2241): undefined reference to `cv::operator-(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text+0x2368): undefined reference to `cv::operator/(cv::Mat const&, double)' test_ukf.cpp:(.text+0x23db): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x23fe): undefined reference to `cv::noArray()' test_ukf.cpp:(.text+0x244f): undefined reference to `cv::norm(cv::_InputArray const&, int, cv::_InputArray const&)' test_ukf.cpp:(.text+0x247e): undefined reference to `cv::noArray()' test_ukf.cpp:(.text+0x24cf): undefined reference to `cv::norm(cv::_InputArray const&, int, cv::_InputArray const&)' test_ukf.cpp:(.text+0x24fe): undefined reference to `cv::noArray()' test_ukf.cpp:(.text+0x254f): undefined reference to `cv::norm(cv::_InputArray const&, int, cv::_InputArray const&)' test_ukf.cpp:(.text+0x257e): undefined reference to `cv::noArray()' test_ukf.cpp:(.text+0x25cf): undefined reference to `cv::norm(cv::_InputArray const&, int, cv::_InputArray const&)' test_ukf.cpp:(.text+0x264c): undefined reference to `testing::Message::Message()' test_ukf.cpp:(.text+0x267f): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)' test_ukf.cpp:(.text+0x2698): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const' test_ukf.cpp:(.text+0x26a7): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x2736): undefined reference to `testing::Message::Message()' test_ukf.cpp:(.text+0x2769): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)' test_ukf.cpp:(.text+0x2782): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const' test_ukf.cpp:(.text+0x2791): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x2820): undefined reference to `testing::Message::Message()' test_ukf.cpp:(.text+0x2853): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)' test_ukf.cpp:(.text+0x286c): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const' test_ukf.cpp:(.text+0x287b): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x290a): undefined reference to `testing::Message::Message()' test_ukf.cpp:(.text+0x293d): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)' test_ukf.cpp:(.text+0x2956): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const' test_ukf.cpp:(.text+0x2965): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x303d): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x307c): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x30b8): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x30f4): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_ungm_mean_squared_error_Test::TestBody()': test_ukf.cpp:(.text+0x32b9): undefined reference to `cv::utils::trace::details::Region::Region(cv::utils::trace::details::Region::LocationStaticStorage const&)' test_ukf.cpp:(.text+0x32d2): undefined reference to `cv::ipp::setIppStatus(int, char const*, char const*, int)' test_ukf.cpp:(.text+0x32d7): undefined reference to `cv::theRNG()' test_ukf.cpp:(.text+0x32e1): undefined reference to `cvtest::param_seed' test_ukf.cpp:(.text+0x3300): undefined reference to `cvtest::checkIppStatus()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_ungm_mean_squared_error_Test::Body()': test_ukf.cpp:(.text+0x34a8): undefined reference to `cv::tracking::UnscentedKalmanFilterParams::UnscentedKalmanFilterParams(int, int, int, double, double, cv::Ptr, int)' test_ukf.cpp:(.text+0x34d8): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x3546): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x35b9): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x35f8): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x3666): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x36d9): undefined reference to `cv::sqrt(cv::_InputArray const&, cv::_OutputArray const&)' test_ukf.cpp:(.text+0x3718): undefined reference to `cv::Mat::eye(int, int, int)' test_ukf.cpp:(.text+0x3978): undefined reference to `cv::Mat::zeros(int, int, int)' test_ukf.cpp:(.text+0x39f3): undefined reference to `cv::tracking::createUnscentedKalmanFilter(cv::tracking::UnscentedKalmanFilterParams const&)' test_ukf.cpp:(.text+0x3ae8): undefined reference to `cv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0x3bbf): undefined reference to `cv::RNG::fill(cv::_InputOutputArray const&, int, cv::_InputArray const&, cv::_InputArray const&, bool)' test_ukf.cpp:(.text+0x3c0c): undefined reference to `cv::operator*(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text+0x3c54): undefined reference to `cv::operator*(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text+0x3f81): undefined reference to `testing::Message::Message()' test_ukf.cpp:(.text+0x3fb4): undefined reference to `testing::internal::AssertHelper::AssertHelper(testing::TestPartResult::Type, char const*, int, char const*)' test_ukf.cpp:(.text+0x3fcd): undefined reference to `testing::internal::AssertHelper::operator=(testing::Message const&) const' test_ukf.cpp:(.text+0x3fdc): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' test_ukf.cpp:(.text+0x44d2): undefined reference to `testing::internal::AssertHelper::~AssertHelper()' /tmp/cc1Bc7jy.o: In function `__static_initialization_and_destruction_0(int, int)': test_ukf.cpp:(.text+0x5142): undefined reference to `testing::internal::GetTestTypeId()' test_ukf.cpp:(.text+0x51b0): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' test_ukf.cpp:(.text+0x51f9): undefined reference to `testing::internal::GetTestTypeId()' test_ukf.cpp:(.text+0x5267): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' test_ukf.cpp:(.text+0x52b0): undefined reference to `testing::internal::GetTestTypeId()' test_ukf.cpp:(.text+0x531e): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, testing::internal::CodeLocation, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' /tmp/cc1Bc7jy.o: In function `testing::internal::scoped_ptr::reset(perf::(anonymous namespace)::MatDepth const*)': test_ukf.cpp:(.text+0x579c): undefined reference to `testing::internal::IsTrue(bool)' /tmp/cc1Bc7jy.o: In function `testing::internal::ValuesInIteratorRangeGenerator::Iterator::Equals(testing::internal::ParamIteratorInterface const&) const': test_ukf.cpp:(.text+0x59bb): undefined reference to `testing::internal::IsTrue(bool)' test_ukf.cpp:(.text+0x59da): undefined reference to `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)' test_ukf.cpp:(.text+0x5a26): undefined reference to `testing::internal::GTestLog::~GTestLog()' test_ukf.cpp:(.text+0x5a69): undefined reference to `testing::internal::GTestLog::~GTestLog()' /tmp/cc1Bc7jy.o: In function `testing::internal::ValuesInIteratorRangeGenerator::Iterator const* testing::internal::CheckedDowncastToActualType::Iterator const, testing::internal::ParamIteratorInterface const>(testing::internal::ParamIteratorInterface const*)': test_ukf.cpp:(.text+0x5b66): undefined reference to `testing::internal::IsTrue(bool)' test_ukf.cpp:(.text+0x5b8c): undefined reference to `testing::internal::GTestLog::GTestLog(testing::internal::GTestLogSeverity, char const*, int)' test_ukf.cpp:(.text+0x5bb1): undefined reference to `testing::internal::GTestLog::~GTestLog()' test_ukf.cpp:(.text+0x5bf8): undefined reference to `testing::internal::GTestLog::~GTestLog()' /tmp/cc1Bc7jy.o: In function `cv::Mat::~Mat()': test_ukf.cpp:(.text._ZN2cv3MatD2Ev[_ZN2cv3MatD5Ev]+0x39): undefined reference to `cv::fastFree(void*)' /tmp/cc1Bc7jy.o: In function `cv::Mat::operator=(cv::Mat const&)': test_ukf.cpp:(.text._ZN2cv3MataSERKS0_[_ZN2cv3MataSERKS0_]+0x115): undefined reference to `cv::Mat::copySize(cv::Mat const&)' /tmp/cc1Bc7jy.o: In function `cv::Mat::col(int) const': test_ukf.cpp:(.text._ZNK2cv3Mat3colEi[_ZNK2cv3Mat3colEi]+0x56): undefined reference to `cv::Mat::Mat(cv::Mat const&, cv::Range const&, cv::Range const&)' /tmp/cc1Bc7jy.o: In function `cv::Mat::clone() const': test_ukf.cpp:(.text._ZNK2cv3Mat5cloneEv[_ZNK2cv3Mat5cloneEv]+0x4e): undefined reference to `cv::Mat::copyTo(cv::_OutputArray const&) const' /tmp/cc1Bc7jy.o: In function `cv::Mat::create(int, int, int)': test_ukf.cpp:(.text._ZN2cv3Mat6createEiii[_ZN2cv3Mat6createEiii]+0x9d): undefined reference to `cv::Mat::create(int, int const*, int)' /tmp/cc1Bc7jy.o: In function `cv::Mat::release()': test_ukf.cpp:(.text._ZN2cv3Mat7releaseEv[_ZN2cv3Mat7releaseEv]+0x4b): undefined reference to `cv::Mat::deallocate()' /tmp/cc1Bc7jy.o: In function `cv::utils::trace::details::Region::~Region()': test_ukf.cpp:(.text._ZN2cv5utils5trace7details6RegionD2Ev[_ZN2cv5utils5trace7details6RegionD5Ev]+0x1f): undefined reference to `cv::utils::trace::details::Region::destroy()' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult::AppendMessage(testing::Message const&)': test_ukf.cpp:(.text._ZN7testing15AssertionResult13AppendMessageERKNS_7MessageE[_ZN7testing15AssertionResult13AppendMessageERKNS_7MessageE]+0x73): undefined reference to `testing::Message::GetString[abi:cxx11]() const' /tmp/cc1Bc7jy.o: In function `BallisticModel::stateConversionFunction(cv::Mat const&, cv::Mat const&, cv::Mat const&, cv::Mat&)': test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x8a): undefined reference to `cv::operator*(double, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x143): undefined reference to `cv::operator+(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x1a7): undefined reference to `cv::operator*(double, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x1c7): undefined reference to `cv::operator+(cv::Mat const&, cv::MatExpr const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x23e): undefined reference to `cv::operator+(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x2a2): undefined reference to `cv::operator*(double, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x2c2): undefined reference to `cv::operator+(cv::Mat const&, cv::MatExpr const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x339): undefined reference to `cv::operator+(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x3a2): undefined reference to `cv::operator*(double, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x3c2): undefined reference to `cv::operator+(cv::Mat const&, cv::MatExpr const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x439): undefined reference to `cv::operator+(cv::Mat const&, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x4a2): undefined reference to `cv::operator*(double, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x4d4): undefined reference to `cv::operator*(double, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x4f4): undefined reference to `cv::operator+(cv::Mat const&, cv::MatExpr const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x514): undefined reference to `cv::operator+(cv::MatExpr const&, cv::MatExpr const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x534): undefined reference to `cv::operator+(cv::MatExpr const&, cv::Mat const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x561): undefined reference to `cv::operator*(double, cv::MatExpr const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x581): undefined reference to `cv::operator+(cv::Mat const&, cv::MatExpr const&)' test_ukf.cpp:(.text._ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_[_ZN14BallisticModel23stateConversionFunctionERKN2cv3MatES3_S3_RS1_]+0x5a1): undefined reference to `cv::operator+(cv::MatExpr const&, cv::Mat const&)' /tmp/cc1Bc7jy.o: In function `UKF_br_landing_point_Test::UKF_br_landing_point_Test()': test_ukf.cpp:(.text._ZN25UKF_br_landing_point_TestC2Ev[_ZN25UKF_br_landing_point_TestC5Ev]+0x14): undefined reference to `testing::Test::Test()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_br_mean_squared_error_Test::UKF_DISABLED_br_mean_squared_error_Test()': test_ukf.cpp:(.text._ZN39UKF_DISABLED_br_mean_squared_error_TestC2Ev[_ZN39UKF_DISABLED_br_mean_squared_error_TestC5Ev]+0x14): undefined reference to `testing::Test::Test()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_ungm_mean_squared_error_Test::UKF_DISABLED_ungm_mean_squared_error_Test()': test_ukf.cpp:(.text._ZN41UKF_DISABLED_ungm_mean_squared_error_TestC2Ev[_ZN41UKF_DISABLED_ungm_mean_squared_error_TestC5Ev]+0x14): undefined reference to `testing::Test::Test()' /tmp/cc1Bc7jy.o: In function `testing::internal::scoped_ptr, std::allocator>>::reset(std::__cxx11::basic_string, std::allocator>*)': test_ukf.cpp:(.text._ZN7testing8internal10scoped_ptrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE5resetEPS7_[_ZN7testing8internal10scoped_ptrINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEE5resetEPS7_]+0x29): undefined reference to `testing::internal::IsTrue(bool)' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult testing::internal::CmpHelperGE(char const*, char const*, double const&, double const&)': test_ukf.cpp:(.text._ZN7testing8internal11CmpHelperGEIddEENS_15AssertionResultEPKcS4_RKT_RKT0_[_ZN7testing8internal11CmpHelperGEIddEENS_15AssertionResultEPKcS4_RKT_RKT0_]+0x49): undefined reference to `testing::AssertionSuccess()' /tmp/cc1Bc7jy.o: In function `testing::internal::scoped_ptr, std::allocator>>::reset(std::__cxx11::basic_stringstream, std::allocator>*)': test_ukf.cpp:(.text._ZN7testing8internal10scoped_ptrINSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEE5resetEPS7_[_ZN7testing8internal10scoped_ptrINSt7__cxx1118basic_stringstreamIcSt11char_traitsIcESaIcEEEE5resetEPS7_]+0x28): undefined reference to `testing::internal::IsTrue(bool)' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult testing::internal::CmpHelperOpFailure(char const*, char const*, double const&, double const&, char const*)': test_ukf.cpp:(.text._ZN7testing8internal18CmpHelperOpFailureIddEENS_15AssertionResultEPKcS4_RKT_RKT0_S4_[_ZN7testing8internal18CmpHelperOpFailureIddEENS_15AssertionResultEPKcS4_RKT_RKT0_S4_]+0x81): undefined reference to `testing::AssertionFailure()' test_ukf.cpp:(.text._ZN7testing8internal18CmpHelperOpFailureIddEENS_15AssertionResultEPKcS4_RKT_RKT0_S4_[_ZN7testing8internal18CmpHelperOpFailureIddEENS_15AssertionResultEPKcS4_RKT_RKT0_S4_]+0x138): undefined reference to `testing::AssertionResult::AssertionResult(testing::AssertionResult const&)' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult& testing::AssertionResult::operator<<(char const (&) [12])': test_ukf.cpp:(.text._ZN7testing15AssertionResultlsIA12_cEERS0_RKT_[_ZN7testing15AssertionResultlsIA12_cEERS0_RKT_]+0x28): undefined reference to `testing::Message::Message()' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult& testing::AssertionResult::operator<<(char const* const&)': test_ukf.cpp:(.text._ZN7testing15AssertionResultlsIPKcEERS0_RKT_[_ZN7testing15AssertionResultlsIPKcEERS0_RKT_]+0x28): undefined reference to `testing::Message::Message()' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult& testing::AssertionResult::operator<<(char const (&) [3])': test_ukf.cpp:(.text._ZN7testing15AssertionResultlsIA3_cEERS0_RKT_[_ZN7testing15AssertionResultlsIA3_cEERS0_RKT_]+0x28): undefined reference to `testing::Message::Message()' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult& testing::AssertionResult::operator<<, std::allocator>>(std::__cxx11::basic_string, std::allocator> const&)': test_ukf.cpp:(.text._ZN7testing15AssertionResultlsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERS0_RKT_[_ZN7testing15AssertionResultlsINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEERS0_RKT_]+0x28): undefined reference to `testing::Message::Message()' /tmp/cc1Bc7jy.o: In function `testing::AssertionResult& testing::AssertionResult::operator<<(char const (&) [5])': test_ukf.cpp:(.text._ZN7testing15AssertionResultlsIA5_cEERS0_RKT_[_ZN7testing15AssertionResultlsIA5_cEERS0_RKT_]+0x28): undefined reference to `testing::Message::Message()' /tmp/cc1Bc7jy.o:(.rodata._ZTV41UKF_DISABLED_ungm_mean_squared_error_Test[_ZTV41UKF_DISABLED_ungm_mean_squared_error_Test]+0x20): undefined reference to `testing::Test::SetUp()' /tmp/cc1Bc7jy.o:(.rodata._ZTV41UKF_DISABLED_ungm_mean_squared_error_Test[_ZTV41UKF_DISABLED_ungm_mean_squared_error_Test]+0x28): undefined reference to `testing::Test::TearDown()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_ungm_mean_squared_error_Test::~UKF_DISABLED_ungm_mean_squared_error_Test()': test_ukf.cpp:(.text._ZN41UKF_DISABLED_ungm_mean_squared_error_TestD2Ev[_ZN41UKF_DISABLED_ungm_mean_squared_error_TestD5Ev]+0x20): undefined reference to `testing::Test::~Test()' /tmp/cc1Bc7jy.o:(.rodata._ZTV39UKF_DISABLED_br_mean_squared_error_Test[_ZTV39UKF_DISABLED_br_mean_squared_error_Test]+0x20): undefined reference to `testing::Test::SetUp()' /tmp/cc1Bc7jy.o:(.rodata._ZTV39UKF_DISABLED_br_mean_squared_error_Test[_ZTV39UKF_DISABLED_br_mean_squared_error_Test]+0x28): undefined reference to `testing::Test::TearDown()' /tmp/cc1Bc7jy.o: In function `UKF_DISABLED_br_mean_squared_error_Test::~UKF_DISABLED_br_mean_squared_error_Test()': test_ukf.cpp:(.text._ZN39UKF_DISABLED_br_mean_squared_error_TestD2Ev[_ZN39UKF_DISABLED_br_mean_squared_error_TestD5Ev]+0x20): undefined reference to `testing::Test::~Test()' /tmp/cc1Bc7jy.o:(.rodata._ZTV25UKF_br_landing_point_Test[_ZTV25UKF_br_landing_point_Test]+0x20): undefined reference to `testing::Test::SetUp()' /tmp/cc1Bc7jy.o:(.rodata._ZTV25UKF_br_landing_point_Test[_ZTV25UKF_br_landing_point_Test]+0x28): undefined reference to `testing::Test::TearDown()' /tmp/cc1Bc7jy.o: In function `UKF_br_landing_point_Test::~UKF_br_landing_point_Test()': test_ukf.cpp:(.text._ZN25UKF_br_landing_point_TestD2Ev[_ZN25UKF_br_landing_point_TestD5Ev]+0x20): undefined reference to `testing::Test::~Test()' /tmp/cc1Bc7jy.o:(.rodata._ZTI41UKF_DISABLED_ungm_mean_squared_error_Test[_ZTI41UKF_DISABLED_ungm_mean_squared_error_Test]+0x10): undefined reference to `typeinfo for testing::Test' /tmp/cc1Bc7jy.o:(.rodata._ZTI39UKF_DISABLED_br_mean_squared_error_Test[_ZTI39UKF_DISABLED_br_mean_squared_error_Test]+0x10): undefined reference to `typeinfo for testing::Test' /tmp/cc1Bc7jy.o:(.rodata._ZTI25UKF_br_landing_point_Test[_ZTI25UKF_br_landing_point_Test]+0x10): undefined reference to `typeinfo for testing::Test' /tmp/cc1Bc7jy.o:(.rodata._ZTIN6cvtest17SkipTestExceptionE[_ZTIN6cvtest17SkipTestExceptionE]+0x10): undefined reference to `typeinfo for cv::Exception' collect2: error: ld returned 1 exit status So what is the problem and what should I do to run test_ukf.cpp? PS: I can run basic .cpp programs which uses cv::KalmanFilter like in here https://docs.opencv.org/3.3.1/d1/da2/kalman_8cpp-example.html[link text](https://docs.opencv.org/3.3.1/d1/da2/kalman_8cpp-example.html)

Gradient Directions: Shouldn't they range from 0-360 around a circles edge?

$
0
0
I have the below image and I am inspection the gradient directions around the circle edge. When I print out the gradient direction values they are only ever 2 values `44.99` and `224.99` (for the edges around the circle) the black and white areas are `0`. ![image description](/upfiles/15338017852421339.png) I thought the gradient directions around a circles edge would always point perpendicular to the edge. So my gradient directions would range from 0-360 degrees. Is my calculation of the gradient direction wrong or my understanding of image gradient directions? src = cv2.imread('../images/circle.png', cv2.IMREAD_GRAYSCALE) dX = cv2.Sobel(src, cv2.CV_32F, 1, 0) dY = cv2.Sobel(src, cv2.CV_32F, 1, 0) # mag, direction = cv2.cartToPolar(dX, dY, angleInDegrees=True) mag = cv2.magnitude(dX, dY) direction = cv2.phase(dX, dY, angleInDegrees=True) print(direction)

cv::Mat serialization to binary file

$
0
0
How can I read\write cv::Mat from binary file in C++? Also I'm using C# with OpencvSharp and I need serialization\deserialization IplImage from binary file how can I do it?

Snapchat filter

$
0
0
Hello, Is it possible to create snapchat filters with OpenCV, then propose them at Snapchat ? Thx cjacquel

Resize batch of images

$
0
0
I want to resize a batch of images how can i do that.

Getting pixels of a bounding box

$
0
0
Hi, I am conducting template matching over an image to get the bounding boxes, and it works. # Apply template Matching # loop over the list of templates and draw bounding boxes around them in the image for i in range(len(templates)): w, h = templates[i].shape[::-1] res = cv2.matchTemplate(backgroundImage_Gray, templates[i], cv2.TM_SQDIFF_NORMED) min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) top_left = min_loc bottom_right = (top_left[0] + w, top_left[1] + h) cv2.rectangle(backgroundImage, top_left, bottom_right, 255, 2) # get the pixels of the rectangle in a variable that can hold them all conveniently I'd like to keep the pixels in each bounding box in a list though, so that I can, later on, access them. Does anyone know how to keep the pixels in a suitable container? I'd appreciate any suggestion.

interface cusolver SVD with GpuMat

$
0
0
Hello everyone I try to devellop a function that like `SVDecomp` but which work with cuda and take `GpuMat` as input containers. In order not to reinvent everything from zero I base my code on cusolver library. Inpired from OpenCV's `hal_internal.cpp` and `lapack.cpp` as well as [this](https://github.com/luyuechao/RLAgpu/blob/master/src/math_util_gpu.cpp) code I wrote my own code. In order to evaluate it I just take a look to matlab example for the SVD function. When I tried it I did not arrive to make it work properly, I mean receive the flag `CUSOLVER_STATUS_SUCCESS` from the processing function. Here is the code I wrote: **header** #ifndef SUPPORT_H #define SUPPORT_H #include #include #include namespace support { namespace cuda { void SVDDecomp(cv::InputArray _src, cv::OutputArray _w, cv::OutputArray _u, cv::OutputArray _vt, int flags = 0,cv::cuda::Stream& stream = cv::cuda::Stream::Null()); } } #endif // SUPPORT_H **source file** #include "support.h" #include namespace support { namespace cuda { namespace { template bool allocate_buffer(cusolverDnHandle_t& handle,int m, int n, int* lwork); template<> inline bool allocate_buffer(cusolverDnHandle_t& handle,int m, int n, int* lwork) { return cusolverDnSgesvd_bufferSize(handle,m,n,lwork) == CUSOLVER_STATUS_SUCCESS; } template<> inline bool allocate_buffer(cusolverDnHandle_t& handle,int m, int n, int* lwork) { return cusolverDnDgesvd_bufferSize(handle,m,n,lwork) == CUSOLVER_STATUS_SUCCESS; } template<> inline bool allocate_buffer(cusolverDnHandle_t& handle,int m, int n, int* lwork) { return cusolverDnCgesvd_bufferSize(handle,m,n,lwork) == CUSOLVER_STATUS_SUCCESS; } template<> inline bool allocate_buffer(cusolverDnHandle_t& handle,int m, int n, int* lwork) { return cusolverDnZgesvd_bufferSize(handle,m,n,lwork) == CUSOLVER_STATUS_SUCCESS; } template bool apply_svd(cusolverDnHandle_t& handle, const schar& job, int& m, int& n, type* A, int lda, channel_type* S, type* U, int ldu, type* VT, int ldvt, type* work, int lwork, channel_type* rwork, int* info); template<> inline bool apply_svd(cusolverDnHandle_t& handle, const schar& job, int& m, int& n, float* A, int lda, float* S, float* U, int ldu, float* VT, int ldvt, float* work, int lwork, float* rwork, int* info) { return cusolverDnSgesvd(handle,job,job,m,n,A,lda,S,U,ldu,VT,ldvt,work,lwork,rwork,info) == CUSOLVER_STATUS_SUCCESS; } template<> inline bool apply_svd(cusolverDnHandle_t& handle, const schar& job, int& m, int& n, double* A, int lda, double* S, double* U, int ldu, double* VT, int ldvt, double* work, int lwork, double* rwork, int* info) { return cusolverDnDgesvd(handle,job,job,m,n,A,lda,S,U,ldu,VT,ldvt,work,lwork,rwork,info) == CUSOLVER_STATUS_SUCCESS; } template<> inline bool apply_svd(cusolverDnHandle_t& handle, const schar& job, int& m, int& n, cv::Vec2f* A, int lda, float* S, cv::Vec2f* U, int ldu, cv::Vec2f* VT, int ldvt, cv::Vec2f* work, int lwork, float* rwork, int* info) { return cusolverDnCgesvd(handle,job,job,m,n,reinterpret_cast(A),lda,S,reinterpret_cast(U),ldu,reinterpret_cast(VT),ldvt,reinterpret_cast(work),lwork,rwork,info) == CUSOLVER_STATUS_SUCCESS; } template<> inline bool apply_svd(cusolverDnHandle_t& handle, const schar& job, int& m, int& n, cv::Vec2d* A, int lda, double* S, cv::Vec2d* U, int ldu, cv::Vec2d* VT, int ldvt, cv::Vec2d* work, int lwork, double* rwork, int* info) { return cusolverDnZgesvd(handle,job,job,m,n,reinterpret_cast(A),lda,S,reinterpret_cast(U),ldu,reinterpret_cast(VT),ldvt,reinterpret_cast(work),lwork,rwork,info) == CUSOLVER_STATUS_SUCCESS; } template void calcSVD(cusolverDnHandle_t& handle, cv::cuda::GpuMat& src, cv::cuda::GpuMat& w, cv::cuda::GpuMat& u, cv::cuda::GpuMat& vt, const int& flags, cv::cuda::Stream& stream) { typedef typename cv::DataType::channel_type value_type; static const int wtype = CV_MAKE_TYPE(cv::DataType::depth,cv::DataType::channels); static const int wdepth = CV_MAT_DEPTH(wtype); int m = src.rows; int n = src.cols; int urows = flags & CV_HAL_SVD_FULL_UV ? m : n; w.create(n,1,wtype); u.create(urows,1, wtype); vt.create(n,n,wtype); int lwork=0; if(!allocate_buffer(handle, m, n, &lwork)) throw cv::Exception(cv::Error::StsBadSize,"Not Enough Allocable Memory On The Device.",__FUNCTION__,__FILE__, __LINE__); schar jobs=0; if(flags & CV_HAL_SVD_NO_UV) jobs = 'N'; else if((flags & CV_HAL_SVD_SHORT_UV) && (flags & CV_HAL_SVD_MODIFY_A)) //short SVD, U stored in a jobs = 'O'; else if((flags & CV_HAL_SVD_SHORT_UV) && !(flags & CV_HAL_SVD_MODIFY_A)) //short SVD, U stored in u if m>=n jobs = 'S'; else if(flags & CV_HAL_SVD_FULL_UV) //full SVD, U stored in u or in a jobs = 'A'; if((flags & CV_HAL_SVD_MODIFY_A) && (flags & CV_HAL_SVD_FULL_UV)) //U stored in a u.create(m,m,u.type()); CV_DbgAssert(jobs); cv::cuda::GpuMat work(1,lwork,wtype,0.); cv::cuda::GpuMat info(1,1,CV_32S); cv::cuda::GpuMat S(1,urows,wdepth); if(!apply_svd(handle, jobs, m, n, src.ptr(), src.step1(), S.ptr(), u.ptr(), u.step1(), vt.ptr(), vt.step1(), work.ptr(), lwork, nullptr, info.ptr())) throw cv::Exception(cv::Error::StsError,"Unexpected Error During the Processing of The SVD",__FUNCTION__,__FILE__,__LINE__); } inline bool check_output(cv::OutputArray& a) { return !a.needed() || (a.needed() && a.isGpuMat()); } } void SVDDecomp(cv::InputArray _src, cv::OutputArray _w, cv::OutputArray _u, cv::OutputArray _vt, int flags,cv::cuda::Stream& stream) { CV_Assert(_src.isGpuMat() && (_src.rows()>=_src.cols()) && (_src.channels()<=2) && check_output(_w) && check_output(_u) && check_output(_vt) ); // Choose the correct function depending of the case. typedef void(*function_type)(cusolverDnHandle_t&,cv::cuda::GpuMat&, cv::cuda::GpuMat&, cv::cuda::GpuMat&,cv::cuda::GpuMat&, const int&,cv::cuda::Stream&); static const function_type funcs[2][2] = { {calcSVD, calcSVD},{calcSVD,calcSVD} }; static cusolverDnHandle_t handle = nullptr; if(!handle) cusolverDnCreate(&handle); cv::cuda::GpuMat src = _src.getGpuMat(); const int wdepth = std::max(src.depth(),CV_32F); if(src.depth() #include "support.h" int main() { cv::Mat1d A = (cv::Mat1d(3,3)<<1,0,1,-1,-2,0,0,1,-1); cv::cuda::GpuMat gA; gA.upload(A); cv::cuda::GpuMat gS; support::cuda::SVDDecomp(gA, gS, cv::noArray(), cv::noArray()); cv::Mat S; gS.download(S); std::cout<

loading tensorflow model without .pbtxt file

$
0
0
Hi, complete DNN newbie here. I'm loading opencv_face_detector_uint8.pb with its associated opencv_face_detector.pbtxt file. When I omit the second argument to the readNet function, the unconnected output layer vector is different. Why? Net net = dnn::experimental_dnn_v5::readNetFromTensorflow("opencv_face_detector_uint8.pb", "opencv_face_detector.pbtxt"); vector vi = net.getUnconnectedOutLayers(); vector node_names; for(int i : vi) node_names.push_back(net.getLayer(i)->name); for(auto& s : node_names) cout << s << " "; /* outputs "detection_out"*/ Net net = dnn::experimental_dnn_v5::readNetFromTensorflow("opencv_face_detector_uint8.pb"); ... /*outputs: mbox_loc mbox_conf_flatten, i.e. two nodes*/ A side question is: why can't I call net.forward(node_name); /*node_name is a string containing an output node name*/ on the two nodes I get in the second example? I hope someone can clarify, thanks.

Error when building on android

$
0
0
Hi all i am getting the below error and the files are compiling correctly. error: undefined reference to 'cv::boxFilter and the boxFilter is available in the code. Anyone know how to solve this?

How to draw contours in a grayscale image in a for loop

$
0
0
Hi, I used "drawContours" function to draw gray level contours onto a grayscale image in a for loop. I think it draw the first contour successfully but it gave a runtime error for the second contour. How can I solve the problem? drawContours( drawing, contours, IDXC, cv::Scalar(255));

how to detect only 60-degree lines (a question from 《learning opencv3》chapter 10)

$
0
0
hi,guys learningOpencv3 chapter10 question15 ,says> 15 Use cv::filter2D() to create a filter that detects only 60-degree lines in an image. Display the results on a sufficiently interesting image scene. I know how to detects 45-degree lines ,as Mat srcLines(100,100,CV_8UC1,Scalar::all(0));//draw lines line(srcLines,Point(0,0),Point(100,100),Scalar(255),1); line(srcLines,Point(50,50),Point(100,0),Scalar(255),1);//45 - degree line(srcLines,Point(0,100),Point(50,0),Scalar(255),1);//60 - degree Mat srcH(3,3,CV_8UC1,Scalar::all(0)); srcH.at(0,0) = 255; srcH.at(1,1) = 255; srcH.at(2,2) = 255; filter2D(srcLines,dst,srcLines.depth(),srcH); but ,how to create a 60-degree kenrel? any help will be welcomed. thanks

DNN Net crashed after pausing for a long period.

$
0
0
Hi All, I followed this tutorial https://github.com/opencv/opencv/blob/3.4/samples/dnn/object_detection.cpp I used yolov3 model, backend = Intel's Deep Learning Inference Engine, target = OpenCL fp16. It worked well if I let it run continuously. However, if I pause halfway (cv::waitKey(0)) and resume some moment later (a few minutes), it gives an error at the call net.forward... (line 128 in the tutorial). On the console window, only show this error: *Abort was called at 767 line in file: D:\qb\workspace\19992\src\vpg-compute-neo\runtime\os_interface\windows\wddm.cpp* (The Call Stack is below.) I couldn't find this file anywhere. I also don't know which exception to catch, tried both std::exception and cv::Exception but didn't catch anything. Thanks for help. Here is the Call Stack window when it crashed: igdrclneo64.dll!00007fff052c3e0c() Unknown igdrclneo64.dll!00007fff050ccc19() Unknown igdrclneo64.dll!00007fff050ccc8a() Unknown igdrclneo64.dll!00007fff050e7dd3() Unknown igdrclneo64.dll!00007fff052271f8() Unknown igdrclneo64.dll!00007fff051cf922() Unknown igdrclneo64.dll!00007fff051776dd() Unknown igdrclneo64.dll!00007fff050d10ee() Unknown clDNN64.dll!00007ffeff97a337() Unknown clDNN64.dll!00007ffeff8bde96() Unknown clDNN64.dll!00007ffeff89618f() Unknown clDNN64.dll!00007ffeff89ce9b() Unknown clDNN64.dll!00007ffeff89e81e() Unknown clDNNPlugin.dll!00007fff174c2e99() Unknown clDNNPlugin.dll!00007fff1742f886() Unknown clDNNPlugin.dll!00007fff174da238() Unknown clDNNPlugin.dll!00007fff174de1a7() Unknown inference_engine.dll!00007fff437e7a08() Unknown inference_engine.dll!00007fff437e7c4c() Unknown clDNNPlugin.dll!00007fff174b7f8b() Unknown clDNNPlugin.dll!00007fff174bd5e0() Unknown clDNNPlugin.dll!00007fff174b64a7() Unknown opencv_dnn342.dll!InferenceEngine::InferRequest::Infer(void) C++ opencv_dnn342.dll!cv::dnn::forwardInfEngine(struct cv::Ptr&) C++ opencv_dnn342.dll!cv::dnn::experimental_dnn_v5::Net::Impl::forwardLayer(struct cv::dnn::experimental_dnn_v5::LayerData &) C++ opencv_dnn342.dll!cv::dnn::experimental_dnn_v5::Net::Impl::forwardToLayer(struct cv::dnn::experimental_dnn_v5::LayerData &,bool) C++ opencv_dnn342.dll!cv::dnn::experimental_dnn_v5::Net::forward(class cv::_OutputArray const &,class std::vector> const &) C++

Skip frames and seek to end of RTSP stream

$
0
0
Hi I capture and process an IP camera RTSP stream in a OpenCV 3.4.2 on Raspberry Pi. Unfortunately the processing takes quite a lot of time, roughly 0.2s per frame, and the stream quickly gets delayed. I don't mind if I skip some frames so I'm looking for a way to seek to the end of the stream before capturing and processing the next frame. vcap = cv2.VideoCapture("rtsp://{IPcam}/12") while(1): ret, frame = vcap.read() time.sleep(0.2) # <= Simulate processing time cv2.imshow('VIDEO', frame) if cv2.waitKey(1) == 27: break vcap.seek_to_end() # <== How to do this? How can I do that `vcap.seek_to_end()` to catch up with the stream, discard the missed frames, and start processing the most current one? Thanks!

Tracking multiobjects recognized by Haar

$
0
0
I have made a simple code to recognize cars in a highway. The prediction works Ok, however the challenge comes when I would like to track them using the Multitrack method in OpenCV. The problem is, in each frame the cascade recognizes say, 3 cars. These 3 cars feed the multiobject track, so for every next frame there would be tracked. However the cascade keep recognizing cars that goes into the tracking. Of course a car is the same, so it doesn't need to be recognized again and again. I am using the video from [here](https://www.youtube.com/watch?v=UM0hX7nomi8) - so you can download it and rename it to uk_road.avi. Here is the image of the result - which you can see multiple boxes are drawn because the multi-object and the cascade are not synchronized. ![image description](/upfiles/15338918541971701.png) I am using python 3.6.6 and opencv version 3.4.2 #! /usr/bin/python import cv2 import numpy as np import imutils def diffUpDown(img): # compare top and bottom size of the image # 1. cut image in two # 2. flip the top side # 3. resize to same size # 4. compare difference height, width, depth = img.shape half = int(height/2) top = img[0:half, 0:width] bottom = img[half:half+half, 0:width] top = cv2.flip(top,1) bottom = cv2.resize(bottom, (32, 64)) top = cv2.resize(top, (32, 64)) return ( mse(top,bottom) ) def diffLeftRight(img): # compare left and right size of the image # 1. cut image in two # 2. flip the right side # 3. resize to same size # 4. compare difference height, width, depth = img.shape half = int(width/2) left = img[0:height, 0:half] right = img[0:height, half:half + half-1] right = cv2.flip(right,1) left = cv2.resize(left, (32, 64)) right = cv2.resize(right, (32, 64)) return ( mse(left,right) ) def mse(imageA, imageB): err = np.sum((imageA.astype("float") - imageB.astype("float")) ** 2) err /= float(imageA.shape[0] * imageA.shape[1]) return err def isNewRoi(rx,ry,rw,rh,rectangles): for r in rectangles: if abs(r[0] - rx) < 30 and abs(r[1] - ry) < 30: return False return True def detectRegionsOfInterest(frame, cascade): scaleDown = 2 frameHeight, frameWidth, fdepth = frame.shape # Resize frame = cv2.resize(frame, (int(frameWidth/scaleDown), int(frameHeight/scaleDown))) frameHeight, frameWidth, fdepth = frame.shape # haar detection. cars = cascade.detectMultiScale(frame, 2, 1) newRegions = [] minY = int(frameHeight*0.1) # iterate regions of interest for (x,y,w,h) in cars: roi = [x,y,w,h] roiImage = frame[y:y+h, x:x+w] if y > minY: diffX = diffLeftRight(roiImage) diffY = round(diffUpDown(roiImage)) if diffX > 200 and diffY > 1200 : rx,ry,rw,rh = roi newRegions.append( [rx*scaleDown,ry*scaleDown,rw*scaleDown,rh*scaleDown] ) return newRegions def detectCars(filename): trackers = cv2.MultiTracker_create() rectangles = [] cascade = cv2.CascadeClassifier('cars.xml') vc = cv2.VideoCapture(filename) if vc.isOpened(): rval , frame = vc.read() else: rval = False frameCount = 0 while frameCount < 40 : rval, frame = vc.read() frame = imutils.resize(frame, width=600) frameHeight, frameWidth, fdepth = frame.shape newRegions = detectRegionsOfInterest(frame, cascade) # for region in newRegions: # if isNewRoi(region[0],region[1],region[2],region[3],rectangles): # rectangles.append(region) # tracker = cv2.TrackerKCF_create() # trackers.add(tracker, frame, tuple(region)) tracker = cv2.TrackerKCF_create() for region in newRegions: trackers.add(tracker, frame, tuple(region)) ok, trackbox = trackers.update(frame) #for r in rectangles: #cv2.rectangle(frame,(r[0],r[1]),(r[0]+r[2],r[1]+r[3]),(0,0,255),3) for newbox in trackbox: p1 = (int(newbox[0]), int(newbox[1])) p2 = (int(newbox[0] + newbox[2]), int(newbox[1] + newbox[3])) cv2.rectangle(frame, p1, p2, (200,0,0)) # frameCount = frameCount + 1 # if frameCount > 5: # frameCount = 0 # rectangles = [] # show result # cv2.line(frame, (750, 400), (1070, 400), (0,255,0), 14) cv2.imshow("tracking",frame) if cv2.waitKey(1) & 0xFF == ord('q'): break cv2.waitKey(1); print(trackers) print(type(trackers)) frameCount = frameCount + 1 vc.release() cv2.destroyAllWindows() # destroy all the opened windows detectCars('uk_road.avi')

boundingRect selects all image instead of target object

$
0
0
Hello, I am trying to track an object in an image, using examples that I have found in opencv documention as well as from other users, and right now I am able to use drawCounters but cannot use boundingRect, instead of selecting just the object, it selects the whole image. Here is the source image: ![image description](/upfiles/15338918081382183.jpg) Here is the result image with drawContours and the failed boundingRect: ![image description](/upfiles/15338923071425796.jpg) This is the code that I am using: import numpy as np import cv2 img = cv2.imread('20180801_172750_Film2.jpg') img_gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) img_blur = cv2.GaussianBlur(img_gray,(5,5),0) img_bgr = cv2.cvtColor(img_blur,cv2.COLOR_GRAY2BGR) img_hsv = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) #### Object Tracking A # define range of color in HSV lowHue = 0 lowSat = 0 lowVal = 135 highHue = 255 highSat = 55 highVal = 255 # creation of mask colorLow = np.array([lowHue,lowSat,lowVal]) colorHigh = np.array([highHue,highSat,highVal]) img_mask = cv2.inRange(img_hsv, colorLow, colorHigh) # find and draw contours #find im2, contours, hierarchy = cv2.findContours(img_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) #draw cv2.drawContours(img, contours, -1, (0,255,0), 3) #find largest contour contour_sizes = [(cv2.contourArea(contour), contour) for contour in contours] #print (contour_sizes) biggest_contour = max(contour_sizes, key=lambda x: x[0])[1] # bounding rectangle x,y,w,h = cv2.boundingRect(biggest_contour) print ('rectangle size: x=%s y=%s w=%s h=%s' %(x,y,w,h)) img_rect = cv2.rectangle(img,(x,y),(x+w,y+h),(0,255,0),2) #### cv2.imshow('img',img) #cv2.imshow('img_gray',img_gray) #cv2.imshow('img_blur',img_blur) #cv2.imshow('img_bgr',img_bgr) #cv2.imshow('img_hsv',img_hsv) cv2.imshow('img_mask',img_mask) cv2.waitKey(0) cv2.destroyAllWindows()

Using FLANN to match ORB descriptors

$
0
0
I'm am investigating methods on how to speed up an object tracking algorithm that uses local feature matching in each frame of the sequence. I think it would be attractive to use the FLANN kNN neighbor search since a database of descriptors is initialized in the first frame (ie database is not updated), and during every frame the new detected keypoints and descriptors are matched to the database, to attempt to find kNN for each descriptor. It would be attractive to build a tree during initialization and thus during each frame the kNN matching/searching should be significantly faster as we do not traverse the entire database for the given query descriptor's best match, as we have prior knowledge of the search space. However since ORB features are ideal when computing resources are limited, how does one use the FLANN matcher? I have read [here](http://example.com/ "title") that we should convert the descriptors to CV_32F, but also [here](http://answers.opencv.org/question/11209/unsupported-format-or-combination-of-formats-in-buildindex-using-flann-algorithm/) that this does make sense for binary descriptors to float. What would be the ideal way to use the FLANN matcher with ORB descriptors? cv::FlannBasedMatcher matcher = cv::FlannBasedMatcher(cv::makePtr(12, 20, 2)); database.convertTo(database32F, CV_32F); matcher.add(database32F); matcher.train(); However the error : Unsupported format or combination of formats (type=5) in buildIndex_, file /home/user/opencv-3.4.0/modules/flann/src/miniflann.cpp, line 315 is produced when I called matcher.train(). What is the correct manner to build the tree in an initialization step?
Viewing all 41027 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>