diff --git a/modules/core/include/opencv2/core/opengl_interop.hpp b/modules/core/include/opencv2/core/opengl_interop.hpp index 338466ba97..464c8219c2 100644 --- a/modules/core/include/opencv2/core/opengl_interop.hpp +++ b/modules/core/include/opencv2/core/opengl_interop.hpp @@ -221,7 +221,7 @@ namespace cv static Ptr get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL); - void draw(const char* str, int len) const; + void draw(const char* str, size_t len) const; inline const std::string& family() const { return family_; } inline int height() const { return height_; } diff --git a/modules/core/src/cuda/matrix_operations.cu b/modules/core/src/cuda/matrix_operations.cu index b57dc4964b..608dd4ef7d 100644 --- a/modules/core/src/cuda/matrix_operations.cu +++ b/modules/core/src/cuda/matrix_operations.cu @@ -67,7 +67,7 @@ namespace cv { namespace gpu { namespace device cv::gpu::device::transform((DevMem2D_)src, (DevMem2D_)dst, identity(), SingleMaskChannels(mask, cn), stream); } - void copyToWithMask_gpu(DevMem2Db src, DevMem2Db dst, int elemSize1, int cn, DevMem2Db mask, bool colorMask, cudaStream_t stream) + void copyToWithMask_gpu(DevMem2Db src, DevMem2Db dst, size_t elemSize1, int cn, DevMem2Db mask, bool colorMask, cudaStream_t stream) { typedef void (*func_t)(DevMem2Db src, DevMem2Db dst, int cn, DevMem2Db mask, bool colorMask, cudaStream_t stream); diff --git a/modules/core/src/gpumat.cpp b/modules/core/src/gpumat.cpp index cb58f193ea..9b96d00937 100644 --- a/modules/core/src/gpumat.cpp +++ b/modules/core/src/gpumat.cpp @@ -320,7 +320,8 @@ namespace template void getCudaAttribute(T *attribute, CUdevice_attribute device_attribute, int device) { *attribute = T(); - CUresult error = CUDA_SUCCESS;// = cuDeviceGetAttribute( attribute, device_attribute, device ); why link erros under ubuntu?? + //CUresult error = CUDA_SUCCESS;// = cuDeviceGetAttribute( attribute, device_attribute, device ); why link erros under ubuntu?? + CUresult error = cuDeviceGetAttribute( attribute, device_attribute, device ); if( CUDA_SUCCESS == error ) return; @@ -760,7 +761,7 @@ namespace namespace cv { namespace gpu { namespace device { - void copyToWithMask_gpu(DevMem2Db src, DevMem2Db dst, int elemSize1, int cn, DevMem2Db mask, bool colorMask, cudaStream_t stream); + void copyToWithMask_gpu(DevMem2Db src, DevMem2Db dst, size_t elemSize1, int cn, DevMem2Db mask, bool colorMask, cudaStream_t stream); template void set_to_gpu(DevMem2Db mat, const T* scalar, int channels, cudaStream_t stream); diff --git a/modules/core/src/opengl_interop.cpp b/modules/core/src/opengl_interop.cpp index 4bae3386cf..2de7874925 100644 --- a/modules/core/src/opengl_interop.cpp +++ b/modules/core/src/opengl_interop.cpp @@ -1257,11 +1257,11 @@ cv::GlFont::GlFont(const string& family, int height, Weight weight, Style style) #endif } -void cv::GlFont::draw(const char* str, int len) const +void cv::GlFont::draw(const char* str, size_t len) const { #ifndef HAVE_OPENGL - (void)str; - (void)len; + (void)str; + (void)len; throw_nogl; #else if (base_ && len > 0) @@ -1269,7 +1269,7 @@ void cv::GlFont::draw(const char* str, int len) const glPushAttrib(GL_LIST_BIT); glListBase(base_); - glCallLists(len, GL_UNSIGNED_BYTE, str); + glCallLists(static_cast(len), GL_UNSIGNED_BYTE, str); glPopAttrib(); diff --git a/modules/gpu/include/opencv2/gpu/gpu.hpp b/modules/gpu/include/opencv2/gpu/gpu.hpp index 23fb90cc37..bf20512fb2 100644 --- a/modules/gpu/include/opencv2/gpu/gpu.hpp +++ b/modules/gpu/include/opencv2/gpu/gpu.hpp @@ -1928,7 +1928,7 @@ public: void write(const cv::gpu::GpuMat& image, bool lastFrame = false); - struct EncoderParams + struct CV_EXPORTS EncoderParams { int P_Interval; // NVVE_P_INTERVAL, int IDR_Period; // NVVE_IDR_PERIOD, @@ -1957,7 +1957,9 @@ public: void save(const std::string& configFile) const; }; - class EncoderCallBack + EncoderParams getParams() const; + + class CV_EXPORTS EncoderCallBack { public: enum PicType @@ -2056,7 +2058,7 @@ public: FormatInfo format() const; void dumpFormat(std::ostream& st); - class VideoSource + class CV_EXPORTS VideoSource { public: VideoSource() : frameQueue_(0), videoParser_(0) {} diff --git a/modules/gpu/src/gftt.cpp b/modules/gpu/src/gftt.cpp index b05f4b448e..eca2fbc313 100644 --- a/modules/gpu/src/gftt.cpp +++ b/modules/gpu/src/gftt.cpp @@ -160,7 +160,7 @@ void cv::gpu::GoodFeaturesToTrackDetector_GPU::operator ()(const GpuMat& image, } } - corners.upload(Mat(1, tmp2.size(), CV_32FC2, &tmp2[0])); + corners.upload(Mat(1, static_cast(tmp2.size()), CV_32FC2, &tmp2[0])); } } diff --git a/modules/gpu/src/imgproc.cpp b/modules/gpu/src/imgproc.cpp index 0b6e0b7b9d..badad846e7 100644 --- a/modules/gpu/src/imgproc.cpp +++ b/modules/gpu/src/imgproc.cpp @@ -1300,9 +1300,9 @@ void cv::gpu::ConvolveBuf::create(Size image_size, Size templ_size) // CUFFT has hard-coded kernels for power-of-2 sizes (up to 8192), // see CUDA Toolkit 4.1 CUFFT Library Programming Guide if (dft_size.width > 8192) - dft_size.width = getOptimalDFTSize(block_size.width + templ_size.width - 1.); + dft_size.width = getOptimalDFTSize(block_size.width + templ_size.width - 1); if (dft_size.height > 8192) - dft_size.height = getOptimalDFTSize(block_size.height + templ_size.height - 1.); + dft_size.height = getOptimalDFTSize(block_size.height + templ_size.height - 1); // To avoid wasting time doing small DFTs dft_size.width = std::max(dft_size.width, 512); diff --git a/modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu b/modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu index 44e6fde31c..82b7038965 100644 --- a/modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu +++ b/modules/gpu/src/nvidia/NCVBroxOpticalFlow.cu @@ -692,7 +692,7 @@ namespace w.clear(); h.clear(); - for (int i = img0.size() - 1; i >= 0; --i) + for (int i = static_cast(img0.size()) - 1; i >= 0; --i) { delete img1[i]; delete img0[i]; diff --git a/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp b/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp index eddc3901e0..a877c9d514 100644 --- a/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp +++ b/modules/gpu/src/nvidia/NCVHaarObjectDetection.hpp @@ -83,7 +83,7 @@ struct HaarFeature64 __host__ NCVStatus setRect(Ncv32u rectX, Ncv32u rectY, Ncv32u rectWidth, Ncv32u rectHeight, Ncv32u /*clsWidth*/, Ncv32u /*clsHeight*/) { ncvAssertReturn(rectWidth <= HaarFeature64_CreateCheck_MaxRectField && rectHeight <= HaarFeature64_CreateCheck_MaxRectField, NCV_HAAR_TOO_LARGE_FEATURES); - _rect = NcvRect8u(rectX,rectY,rectWidth,rectHeight); + _rect = NcvRect8u(static_cast(rectX),static_cast(rectY),static_cast(rectWidth),static_cast(rectHeight)); return NCV_SUCCESS; } diff --git a/modules/gpu/src/nvidia/core/NCV.cu b/modules/gpu/src/nvidia/core/NCV.cu index 4ffaebff8b..e24a47b640 100644 --- a/modules/gpu/src/nvidia/core/NCV.cu +++ b/modules/gpu/src/nvidia/core/NCV.cu @@ -295,7 +295,7 @@ NCVMemStackAllocator::NCVMemStackAllocator(NCVMemoryType memT, size_t capacity, break; case NCVMemoryTypeHostPageable: allocBegin = (Ncv8u *)malloc(capacity); - break; + break; default:; } } @@ -336,7 +336,7 @@ NCVMemStackAllocator::~NCVMemStackAllocator() break; case NCVMemoryTypeHostPageable: free(allocBegin); - break; + break; default:; } } @@ -351,7 +351,7 @@ NCVStatus NCVMemStackAllocator::alloc(NCVMemSegment &seg, size_t size) seg.clear(); ncvAssertReturn(isInitialized(), NCV_ALLOCATOR_BAD_ALLOC); - size = alignUp(size, this->_alignment); + size = alignUp(static_cast(size), this->_alignment); this->currentSize += size; this->_maxSize = std::max(this->_maxSize, this->currentSize); @@ -457,11 +457,11 @@ NCVStatus NCVMemNativeAllocator::alloc(NCVMemSegment &seg, size_t size) break; case NCVMemoryTypeHostPageable: seg.begin.ptr = (Ncv8u *)malloc(size); - break; + break; default:; } - this->currentSize += alignUp(size, this->_alignment); + this->currentSize += alignUp(static_cast(size), this->_alignment); this->_maxSize = std::max(this->_maxSize, this->currentSize); seg.begin.memtype = this->_memType; @@ -477,8 +477,8 @@ NCVStatus NCVMemNativeAllocator::dealloc(NCVMemSegment &seg) ncvAssertReturn(seg.begin.memtype == this->_memType, NCV_ALLOCATOR_BAD_DEALLOC); ncvAssertReturn(seg.begin.ptr != NULL, NCV_ALLOCATOR_BAD_DEALLOC); - ncvAssertReturn(currentSize >= alignUp(seg.size, this->_alignment), NCV_ALLOCATOR_BAD_DEALLOC); - currentSize -= alignUp(seg.size, this->_alignment); + ncvAssertReturn(currentSize >= alignUp(static_cast(seg.size), this->_alignment), NCV_ALLOCATOR_BAD_DEALLOC); + currentSize -= alignUp(static_cast(seg.size), this->_alignment); switch (this->_memType) { @@ -490,7 +490,7 @@ NCVStatus NCVMemNativeAllocator::dealloc(NCVMemSegment &seg) break; case NCVMemoryTypeHostPageable: free(seg.begin.ptr); - break; + break; default:; } diff --git a/modules/gpu/src/nvidia/core/NCVPyramid.cu b/modules/gpu/src/nvidia/core/NCVPyramid.cu index 12260f4114..0a95ebb384 100644 --- a/modules/gpu/src/nvidia/core/NCVPyramid.cu +++ b/modules/gpu/src/nvidia/core/NCVPyramid.cu @@ -211,7 +211,8 @@ namespace cv { namespace gpu { namespace device dim3 bDim(16, 8); dim3 gDim(divUp(src.cols, bDim.x), divUp(src.rows, bDim.y)); - kernelDownsampleX2<<>>((T*)src.data, src.step, (T*)dst.data, dst.step, NcvSize32u(dst.cols, dst.rows)); + kernelDownsampleX2<<>>((T*)src.data, static_cast(src.step), + (T*)dst.data, static_cast(dst.step), NcvSize32u(dst.cols, dst.rows)); cudaSafeCall( cudaGetLastError() ); @@ -285,8 +286,8 @@ namespace cv { namespace gpu { namespace device dim3 bDim(16, 8); dim3 gDim(divUp(dst.cols, bDim.x), divUp(dst.rows, bDim.y)); - kernelInterpolateFrom1<<>>((T*) src.data, src.step, NcvSize32u(src.cols, src.rows), - (T*) dst.data, dst.step, NcvSize32u(dst.cols, dst.rows)); + kernelInterpolateFrom1<<>>((T*) src.data, static_cast(src.step), NcvSize32u(src.cols, src.rows), + (T*) dst.data, static_cast(dst.step), NcvSize32u(dst.cols, dst.rows)); cudaSafeCall( cudaGetLastError() ); diff --git a/modules/gpu/src/optical_flow.cpp b/modules/gpu/src/optical_flow.cpp index 0921e00585..1c963fc535 100644 --- a/modules/gpu/src/optical_flow.cpp +++ b/modules/gpu/src/optical_flow.cpp @@ -114,16 +114,16 @@ void cv::gpu::BroxOpticalFlow::operator ()(const GpuMat& frame0, const GpuMat& f vMemSeg.begin.ptr = v.ptr(); vMemSeg.size = v.step * v.rows; - NCVMatrixReuse frame0Mat(frame0MemSeg, devProp.textureAlignment, frame0.cols, frame0.rows, frame0.step); - NCVMatrixReuse frame1Mat(frame1MemSeg, devProp.textureAlignment, frame1.cols, frame1.rows, frame1.step); - NCVMatrixReuse uMat(uMemSeg, devProp.textureAlignment, u.cols, u.rows, u.step); - NCVMatrixReuse vMat(vMemSeg, devProp.textureAlignment, v.cols, v.rows, v.step); + NCVMatrixReuse frame0Mat(frame0MemSeg, static_cast(devProp.textureAlignment), frame0.cols, frame0.rows, static_cast(frame0.step)); + NCVMatrixReuse frame1Mat(frame1MemSeg, static_cast(devProp.textureAlignment), frame1.cols, frame1.rows, static_cast(frame1.step)); + NCVMatrixReuse uMat(uMemSeg, static_cast(devProp.textureAlignment), u.cols, u.rows, static_cast(u.step)); + NCVMatrixReuse vMat(vMemSeg, static_cast(devProp.textureAlignment), v.cols, v.rows, static_cast(v.step)); cudaStream_t stream = StreamAccessor::getStream(s); size_t bufSize = getBufSize(desc, frame0Mat, frame1Mat, uMat, vMat, devProp); - ensureSizeIsEnough(1, bufSize, CV_8UC1, buf); + ensureSizeIsEnough(1, static_cast(bufSize), CV_8UC1, buf); NCVMemStackAllocator gpuAllocator(NCVMemoryTypeDevice, bufSize, static_cast(devProp.textureAlignment), buf.ptr()); diff --git a/modules/gpu/src/orb.cpp b/modules/gpu/src/orb.cpp index a69547a0ec..f290a2c1b0 100644 --- a/modules/gpu/src/orb.cpp +++ b/modules/gpu/src/orb.cpp @@ -406,7 +406,7 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg float n_desired_features_per_scale = nFeatures_ * (1.0f - factor) / (1.0f - std::pow(factor, nLevels_)); n_features_per_level_.resize(nLevels_); - int sum_n_features = 0; + size_t sum_n_features = 0; for (int level = 0; level < nLevels_ - 1; ++level) { n_features_per_level_[level] = cvRound(n_desired_features_per_scale); @@ -430,7 +430,7 @@ cv::gpu::ORB_GPU::ORB_GPU(int nFeatures, float scaleFactor, int nLevels, int edg ++v_0; } CV_Assert(u_max.size() < 32); - cv::gpu::device::orb::loadUMax(&u_max[0], u_max.size()); + cv::gpu::device::orb::loadUMax(&u_max[0], static_cast(u_max.size())); // Calc pattern const int npoints = 512; @@ -573,7 +573,7 @@ void cv::gpu::ORB_GPU::computeKeyPointsPyramid() GpuMat fastKpRange = keyPointsPyr_[level].rowRange(0, 2); keyPointsCount_[level] = fastDetector_.getKeyPoints(fastKpRange); - int n_features = n_features_per_level_[level]; + int n_features = static_cast(n_features_per_level_[level]); if (scoreType_ == ORB::HARRIS_SCORE) { diff --git a/modules/gpu/src/stereocsbp.cpp b/modules/gpu/src/stereocsbp.cpp index 8c18888bff..02af8fdcd7 100644 --- a/modules/gpu/src/stereocsbp.cpp +++ b/modules/gpu/src/stereocsbp.cpp @@ -204,7 +204,7 @@ static void csbp_operator(StereoConstantSpaceBP& rthis, GpuMat& mbuf, GpuMat& te Size temp_size = data_cost.size(); if ((size_t)temp_size.area() < elem_step * rows_pyr[levels - 1] * rthis.ndisp) - temp_size = Size(elem_step, rows_pyr[levels - 1] * rthis.ndisp); + temp_size = Size(static_cast(elem_step), rows_pyr[levels - 1] * rthis.ndisp); temp.create(temp_size, DataType::type); diff --git a/modules/gpu/src/video_parser.cpp b/modules/gpu/src/video_parser.cpp index dabbdbcd40..7571a6388b 100644 --- a/modules/gpu/src/video_parser.cpp +++ b/modules/gpu/src/video_parser.cpp @@ -70,7 +70,7 @@ bool cv::gpu::detail::VideoParser::parseVideoData(const unsigned char* data, siz if (endOfStream) packet.flags |= CUVID_PKT_ENDOFSTREAM; - packet.payload_size = size; + packet.payload_size = static_cast(size); packet.payload = data; if (cuvidParseVideoData(parser_, &packet) != CUDA_SUCCESS) diff --git a/modules/gpu/src/video_writer.cpp b/modules/gpu/src/video_writer.cpp index 451b64fd89..2a71c51b34 100644 --- a/modules/gpu/src/video_writer.cpp +++ b/modules/gpu/src/video_writer.cpp @@ -57,6 +57,7 @@ void cv::gpu::VideoWriter_GPU::open(const cv::Ptr&, cv::Size, d bool cv::gpu::VideoWriter_GPU::isOpened() const { return false; } void cv::gpu::VideoWriter_GPU::close() {} void cv::gpu::VideoWriter_GPU::write(const cv::gpu::GpuMat&, bool) { throw_nogpu(); } +cv::gpu::VideoWriter_GPU::EncoderParams cv::gpu::VideoWriter_GPU::getParams() const { EncoderParams params; throw_nogpu(); return params; } cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams() { throw_nogpu(); } cv::gpu::VideoWriter_GPU::EncoderParams::EncoderParams(const std::string&) { throw_nogpu(); } @@ -129,6 +130,8 @@ public: void write(const cv::gpu::GpuMat& image, bool lastFrame); + EncoderParams getParams() const; + private: Impl(const Impl&); Impl& operator=(const Impl&); @@ -224,8 +227,7 @@ void cv::gpu::VideoWriter_GPU::Impl::initEncoder(double fps) err = NVSetParamValue(encoder_, NVVE_OUT_SIZE, &inputSize); CV_Assert( err == 0 ); - //int aspectRatio[] = { frameSize_.width, frameSize_.height, ASPECT_RATIO_DAR }; - int aspectRatio[] = { 16, 9, ASPECT_RATIO_DAR }; + int aspectRatio[] = { frameSize_.width, frameSize_.height, ASPECT_RATIO_DAR }; err = NVSetParamValue(encoder_, NVVE_ASPECT_RATIO, &aspectRatio); CV_Assert( err == 0 ); @@ -333,6 +335,107 @@ void cv::gpu::VideoWriter_GPU::Impl::setEncodeParams(const EncoderParams& params CV_Assert ( err == 0 ); } +cv::gpu::VideoWriter_GPU::EncoderParams cv::gpu::VideoWriter_GPU::Impl::getParams() const +{ + int err; + + EncoderParams params; + + int P_Interval; + err = NVGetParamValue(encoder_, NVVE_P_INTERVAL, &P_Interval); + CV_Assert( err == 0 ); + params.P_Interval = P_Interval; + + int IDR_Period; + err = NVGetParamValue(encoder_, NVVE_IDR_PERIOD, &IDR_Period); + CV_Assert( err == 0 ); + params.IDR_Period = IDR_Period; + + int DynamicGOP; + err = NVGetParamValue(encoder_, NVVE_DYNAMIC_GOP, &DynamicGOP); + CV_Assert( err == 0 ); + params.DynamicGOP = DynamicGOP; + + NVVE_RateCtrlType RCType; + err = NVGetParamValue(encoder_, NVVE_RC_TYPE, &RCType); + CV_Assert( err == 0 ); + params.RCType = RCType; + + int AvgBitrate; + err = NVGetParamValue(encoder_, NVVE_AVG_BITRATE, &AvgBitrate); + CV_Assert( err == 0 ); + params.AvgBitrate = AvgBitrate; + + int PeakBitrate; + err = NVGetParamValue(encoder_, NVVE_PEAK_BITRATE, &PeakBitrate); + CV_Assert( err == 0 ); + params.PeakBitrate = PeakBitrate; + + int QP_Level_Intra; + err = NVGetParamValue(encoder_, NVVE_QP_LEVEL_INTRA, &QP_Level_Intra); + CV_Assert( err == 0 ); + params.QP_Level_Intra = QP_Level_Intra; + + int QP_Level_InterP; + err = NVGetParamValue(encoder_, NVVE_QP_LEVEL_INTER_P, &QP_Level_InterP); + CV_Assert( err == 0 ); + params.QP_Level_InterP = QP_Level_InterP; + + int QP_Level_InterB; + err = NVGetParamValue(encoder_, NVVE_QP_LEVEL_INTER_B, &QP_Level_InterB); + CV_Assert( err == 0 ); + params.QP_Level_InterB = QP_Level_InterB; + + int DeblockMode; + err = NVGetParamValue(encoder_, NVVE_DEBLOCK_MODE, &DeblockMode); + CV_Assert( err == 0 ); + params.DeblockMode = DeblockMode; + + int ProfileLevel; + err = NVGetParamValue(encoder_, NVVE_PROFILE_LEVEL, &ProfileLevel); + CV_Assert( err == 0 ); + params.ProfileLevel = ProfileLevel; + + int ForceIntra; + err = NVGetParamValue(encoder_, NVVE_FORCE_INTRA, &ForceIntra); + CV_Assert( err == 0 ); + params.ForceIntra = ForceIntra; + + int ForceIDR; + err = NVGetParamValue(encoder_, NVVE_FORCE_IDR, &ForceIDR); + CV_Assert( err == 0 ); + params.ForceIDR = ForceIDR; + + int ClearStat; + err = NVGetParamValue(encoder_, NVVE_CLEAR_STAT, &ClearStat); + CV_Assert( err == 0 ); + params.ClearStat = ClearStat; + + NVVE_DI_MODE DIMode; + err = NVGetParamValue(encoder_, NVVE_SET_DEINTERLACE, &DIMode); + CV_Assert( err == 0 ); + params.DIMode = DIMode; + + params.Presets = -1; + + int DisableCabac; + err = NVGetParamValue(encoder_, NVVE_DISABLE_CABAC, &DisableCabac); + CV_Assert ( err == 0 ); + params.DisableCabac = DisableCabac; + + int NaluFramingType; + err = NVGetParamValue(encoder_, NVVE_CONFIGURE_NALU_FRAMING_TYPE, &NaluFramingType); + CV_Assert ( err == 0 ); + params.NaluFramingType = NaluFramingType; + + int DisableSPSPPS; + err = NVGetParamValue(encoder_, NVVE_DISABLE_SPS_PPS, &DisableSPSPPS); + CV_Assert ( err == 0 ); + params.DisableSPSPPS = DisableSPSPPS; + + return params; +} + void cv::gpu::VideoWriter_GPU::Impl::initGpuMemory() { int err; @@ -807,6 +910,13 @@ void cv::gpu::VideoWriter_GPU::write(const cv::gpu::GpuMat& image, bool lastFram impl_->write(image, lastFrame); } +cv::gpu::VideoWriter_GPU::EncoderParams cv::gpu::VideoWriter_GPU::getParams() const +{ + CV_Assert( isOpened() ); + + return impl_->getParams(); +} + /////////////////////////////////////////////////////////////////////////// // VideoWriter_GPU::EncoderParams diff --git a/modules/gpu/test/test_features2d.cpp b/modules/gpu/test/test_features2d.cpp index 9af8ad91fe..fc5cb30e87 100644 --- a/modules/gpu/test/test_features2d.cpp +++ b/modules/gpu/test/test_features2d.cpp @@ -617,12 +617,18 @@ TEST_P(BruteForceMatcher, MatchAdd) if ((int)i < queryDescCount / 2) { - if ((match.queryIdx != (int)i) || (match.trainIdx != (int)i * countFactor + shift) || (match.imgIdx != 0)) + bool validQueryIdx = (match.queryIdx == (int)i); + bool validTrainIdx = (match.trainIdx == (int)i * countFactor + shift); + bool validImgIdx = (match.imgIdx == 0); + if (!validQueryIdx || !validTrainIdx || !validImgIdx) badCount++; } else { - if ((match.queryIdx != (int)i) || (match.trainIdx != ((int)i - queryDescCount / 2) * countFactor + shift) || (match.imgIdx != 1)) + bool validQueryIdx = (match.queryIdx == (int)i); + bool validTrainIdx = (match.trainIdx == ((int)i - queryDescCount / 2) * countFactor + shift); + bool validImgIdx = (match.imgIdx == 1); + if (!validQueryIdx || !validTrainIdx || !validImgIdx) badCount++; } } diff --git a/samples/gpu/opticalflow_nvidia_api.cpp b/samples/gpu/opticalflow_nvidia_api.cpp index 313ed710b7..c7b55e1b07 100644 --- a/samples/gpu/opticalflow_nvidia_api.cpp +++ b/samples/gpu/opticalflow_nvidia_api.cpp @@ -407,10 +407,10 @@ int main(int argc, char **argv) std::cout << "Using GPU: " << devId << "(" << devProp.name << "), arch=" << devProp.major << "." << devProp.minor << std::endl; - g_pGPUMemAllocator = Ptr (new NCVMemNativeAllocator (NCVMemoryTypeDevice, devProp.textureAlignment)); + g_pGPUMemAllocator = Ptr (new NCVMemNativeAllocator (NCVMemoryTypeDevice, static_cast(devProp.textureAlignment))); ncvAssertPrintReturn (g_pGPUMemAllocator->isInitialized (), "Device memory allocator isn't initialized", -1); - g_pHostMemAllocator = Ptr (new NCVMemNativeAllocator (NCVMemoryTypeHostPageable, devProp.textureAlignment)); + g_pHostMemAllocator = Ptr (new NCVMemNativeAllocator (NCVMemoryTypeHostPageable, static_cast(devProp.textureAlignment))); ncvAssertPrintReturn (g_pHostMemAllocator->isInitialized (), "Host memory allocator isn't initialized", -1); int width, height;