Commit df8b057b authored by Alexander Alekhin's avatar Alexander Alekhin

avoid `Ptr<> == NULL` checks

parent 64b3c1e6
...@@ -384,21 +384,14 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst ) ...@@ -384,21 +384,14 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
if (_src.dims() <= 2) if (_src.dims() <= 2)
{ {
bool ok = false; bool ok = false;
Ptr<ParallelLoopBody> body; LUTParallelBody body(src, lut, dst, &ok);
if (ok)
if (body == NULL || ok == false)
{
ok = false;
ParallelLoopBody* p = new LUTParallelBody(src, lut, dst, &ok);
body.reset(p);
}
if (body != NULL && ok)
{ {
Range all(0, dst.rows); Range all(0, dst.rows);
if (dst.total()>>18) if (dst.total() >= (size_t)(1<<18))
parallel_for_(all, *body, (double)std::max((size_t)1, dst.total()>>16)); parallel_for_(all, body, (double)std::max((size_t)1, dst.total()>>16));
else else
(*body)(all); body(all);
if (ok) if (ok)
return; return;
} }
......
...@@ -537,7 +537,7 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat ) ...@@ -537,7 +537,7 @@ void read( const FileNode& node, SparseMat& mat, const SparseMat& default_mat )
return; return;
} }
Ptr<CvSparseMat> m((CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node)); Ptr<CvSparseMat> m((CvSparseMat*)cvRead((CvFileStorage*)node.fs, (CvFileNode*)*node));
CV_Assert(CV_IS_SPARSE_MAT(m)); CV_Assert(CV_IS_SPARSE_MAT(m.get()));
m->copyToSparseMat(mat); m->copyToSparseMat(mat);
} }
......
...@@ -288,9 +288,9 @@ protected: ...@@ -288,9 +288,9 @@ protected:
fs["test_sparse_mat"] >> m_s2; fs["test_sparse_mat"] >> m_s2;
Ptr<CvSparseMat> _m_s2(cvCreateSparseMat(m_s2)); Ptr<CvSparseMat> _m_s2(cvCreateSparseMat(m_s2));
if( !m_s || !CV_IS_SPARSE_MAT(m_s) || if( !m_s || !CV_IS_SPARSE_MAT(m_s.get()) ||
!cvTsCheckSparse(m_s, _test_sparse, 0) || !cvTsCheckSparse(m_s.get(), _test_sparse.get(), 0) ||
!cvTsCheckSparse(_m_s2, _test_sparse, 0)) !cvTsCheckSparse(_m_s2.get(), _test_sparse.get(), 0))
{ {
ts->printf( cvtest::TS::LOG, "the read sparse matrix is not correct\n" ); ts->printf( cvtest::TS::LOG, "the read sparse matrix is not correct\n" );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT ); ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
......
...@@ -1820,7 +1820,7 @@ void OCL4DNNConvSpatial<Dtype>::prepareKernel(const UMat &bottom, UMat &top, ...@@ -1820,7 +1820,7 @@ void OCL4DNNConvSpatial<Dtype>::prepareKernel(const UMat &bottom, UMat &top,
std::string previous_key = key_; std::string previous_key = key_;
generateKey(); generateKey();
if (key_.compare(previous_key) == 0 && bestKernelConfig != NULL) if (key_.compare(previous_key) == 0 && bestKernelConfig)
return; return;
if (bestKernelConfig) if (bestKernelConfig)
......
...@@ -237,7 +237,7 @@ TEST(ML_ANN, ActivationFunction) ...@@ -237,7 +237,7 @@ TEST(ML_ANN, ActivationFunction)
x->save(dataname + activationName[i] + ".yml"); x->save(dataname + activationName[i] + ".yml");
#else #else
Ptr<ml::ANN_MLP> y = Algorithm::load<ANN_MLP>(dataname + activationName[i] + ".yml"); Ptr<ml::ANN_MLP> y = Algorithm::load<ANN_MLP>(dataname + activationName[i] + ".yml");
ASSERT_TRUE(y != NULL) << "Could not load " << dataname + activationName[i] + ".yml"; ASSERT_TRUE(y) << "Could not load " << dataname + activationName[i] + ".yml";
Mat testSamples = tdata->getTestSamples(); Mat testSamples = tdata->getTestSamples();
Mat rx, ry, dst; Mat rx, ry, dst;
x->predict(testSamples, rx); x->predict(testSamples, rx);
...@@ -330,7 +330,7 @@ TEST_P(ML_ANN_METHOD, Test) ...@@ -330,7 +330,7 @@ TEST_P(ML_ANN_METHOD, Test)
#endif #endif
ASSERT_FALSE(r_gold.empty()); ASSERT_FALSE(r_gold.empty());
Ptr<ml::ANN_MLP> y = Algorithm::load<ANN_MLP>(filename); Ptr<ml::ANN_MLP> y = Algorithm::load<ANN_MLP>(filename);
ASSERT_TRUE(y != NULL) << "Could not load " << filename; ASSERT_TRUE(y) << "Could not load " << filename;
Mat rx, ry; Mat rx, ry;
for (int j = 0; j < 4; j++) for (int j = 0; j < 4; j++)
{ {
......
...@@ -178,7 +178,7 @@ int main(int argc, char *argv[]) ...@@ -178,7 +178,7 @@ int main(int argc, char *argv[])
vector<Rect> zone; vector<Rect> zone;
vector<vector <Point> > region; vector<vector <Point> > region;
Mat desc, result(img.rows, img.cols, CV_8UC3); Mat desc, result(img.rows, img.cols, CV_8UC3);
if (b.dynamicCast<SimpleBlobDetector>() != NULL) if (b.dynamicCast<SimpleBlobDetector>().get())
{ {
Ptr<SimpleBlobDetector> sbd = b.dynamicCast<SimpleBlobDetector>(); Ptr<SimpleBlobDetector> sbd = b.dynamicCast<SimpleBlobDetector>();
sbd->detect(img, keyImg, Mat()); sbd->detect(img, keyImg, Mat());
......
...@@ -500,7 +500,7 @@ int main(int argc, char *argv[]) ...@@ -500,7 +500,7 @@ int main(int argc, char *argv[])
vector<vector <Point> > region; vector<vector <Point> > region;
Mat desc; Mat desc;
if (b.dynamicCast<MSER>() != NULL) if (b.dynamicCast<MSER>().get())
{ {
Ptr<MSER> sbd = b.dynamicCast<MSER>(); Ptr<MSER> sbd = b.dynamicCast<MSER>();
sbd->detectRegions(img, region, zone); sbd->detectRegions(img, region, zone);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment