@ -1,38 +0,0 @@ |
||||
--- a/3rdparty/libpng/pngpriv.h
|
||||
+++ b/3rdparty/libpng/pngpriv.h
|
||||
@@ -214,7 +214,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
-#if PNG_INTEL_SSE_OPT > 0
|
||||
+#if defined(PNG_INTEL_SSE_OPT) && PNG_INTEL_SSE_OPT > 0
|
||||
# ifndef PNG_INTEL_SSE_IMPLEMENTATION
|
||||
# if defined(__SSE4_1__) || defined(__AVX__)
|
||||
/* We are not actually using AVX, but checking for AVX is the best
|
||||
@@ -547,7 +547,7 @@
|
||||
|
||||
/* Memory model/platform independent fns */
|
||||
#ifndef PNG_ABORT
|
||||
-# ifdef _WINDOWS_
|
||||
+# if defined(_WINDOWS_) && !defined(WINRT)
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
@@ -1340,7 +1340,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
-#if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||
+#if defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop
|
||||
@@ -2099,7 +2099,7 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
-# if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||
+# if defined(PNG_INTEL_SSE_IMPLEMENTATION) && PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
# endif
|
@ -0,0 +1,44 @@ |
||||
# ---------------------------------------------------------------------------- |
||||
# Detect frameworks that may be used by 3rd-party libraries as well as OpenCV |
||||
# ---------------------------------------------------------------------------- |
||||
|
||||
# --- HPX --- |
||||
if(WITH_HPX) |
||||
find_package(HPX REQUIRED) |
||||
ocv_include_directories(${HPX_INCLUDE_DIRS}) |
||||
set(HAVE_HPX TRUE) |
||||
endif(WITH_HPX) |
||||
|
||||
# --- GCD --- |
||||
if(APPLE AND NOT HAVE_TBB) |
||||
set(HAVE_GCD 1) |
||||
else() |
||||
set(HAVE_GCD 0) |
||||
endif() |
||||
|
||||
# --- Concurrency --- |
||||
if(MSVC AND NOT HAVE_TBB) |
||||
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/concurrencytest.cpp") |
||||
file(WRITE "${_fname}" "#if _MSC_VER < 1600\n#error\n#endif\nint main() { return 0; }\n") |
||||
try_compile(HAVE_CONCURRENCY "${CMAKE_BINARY_DIR}" "${_fname}") |
||||
file(REMOVE "${_fname}") |
||||
else() |
||||
set(HAVE_CONCURRENCY 0) |
||||
endif() |
||||
|
||||
# --- OpenMP --- |
||||
if(WITH_OPENMP) |
||||
find_package(OpenMP) |
||||
if(OPENMP_FOUND) |
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") |
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") |
||||
endif() |
||||
set(HAVE_OPENMP "${OPENMP_FOUND}") |
||||
endif() |
||||
|
||||
ocv_clear_vars(HAVE_PTHREADS_PF) |
||||
if(WITH_PTHREADS_PF AND HAVE_PTHREAD) |
||||
set(HAVE_PTHREADS_PF 1) |
||||
else() |
||||
set(HAVE_PTHREADS_PF 0) |
||||
endif() |
Before Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 94 KiB |
After Width: | Height: | Size: 91 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 16 KiB |
@ -0,0 +1,79 @@ |
||||
import org.opencv.core.Core; |
||||
import org.opencv.core.Mat; |
||||
import org.opencv.core.Point; |
||||
import org.opencv.core.Scalar; |
||||
import org.opencv.highgui.HighGui; |
||||
import org.opencv.imgproc.Imgproc; |
||||
import org.opencv.video.BackgroundSubtractor; |
||||
import org.opencv.video.Video; |
||||
import org.opencv.videoio.VideoCapture; |
||||
import org.opencv.videoio.Videoio; |
||||
|
||||
class BackgroundSubtraction { |
||||
public void run(String[] args) { |
||||
String input = args.length > 0 ? args[0] : "../data/vtest.avi"; |
||||
boolean useMOG2 = args.length > 1 ? args[1] == "MOG2" : true; |
||||
|
||||
//! [create]
|
||||
BackgroundSubtractor backSub; |
||||
if (useMOG2) { |
||||
backSub = Video.createBackgroundSubtractorMOG2(); |
||||
} else { |
||||
backSub = Video.createBackgroundSubtractorKNN(); |
||||
} |
||||
//! [create]
|
||||
|
||||
//! [capture]
|
||||
VideoCapture capture = new VideoCapture(input); |
||||
if (!capture.isOpened()) { |
||||
System.err.println("Unable to open: " + input); |
||||
System.exit(0); |
||||
} |
||||
//! [capture]
|
||||
|
||||
Mat frame = new Mat(), fgMask = new Mat(); |
||||
while (true) { |
||||
capture.read(frame); |
||||
if (frame.empty()) { |
||||
break; |
||||
} |
||||
|
||||
//! [apply]
|
||||
// update the background model
|
||||
backSub.apply(frame, fgMask); |
||||
//! [apply]
|
||||
|
||||
//! [display_frame_number]
|
||||
// get the frame number and write it on the current frame
|
||||
Imgproc.rectangle(frame, new Point(10, 2), new Point(100, 20), new Scalar(255, 255, 255), -1); |
||||
String frameNumberString = String.format("%d", (int)capture.get(Videoio.CAP_PROP_POS_FRAMES)); |
||||
Imgproc.putText(frame, frameNumberString, new Point(15, 15), Core.FONT_HERSHEY_SIMPLEX, 0.5, |
||||
new Scalar(0, 0, 0)); |
||||
//! [display_frame_number]
|
||||
|
||||
//! [show]
|
||||
// show the current frame and the fg masks
|
||||
HighGui.imshow("Frame", frame); |
||||
HighGui.imshow("FG Mask", fgMask); |
||||
//! [show]
|
||||
|
||||
// get the input from the keyboard
|
||||
int keyboard = HighGui.waitKey(30); |
||||
if (keyboard == 'q' || keyboard == 27) { |
||||
break; |
||||
} |
||||
} |
||||
|
||||
HighGui.waitKey(); |
||||
System.exit(0); |
||||
} |
||||
} |
||||
|
||||
public class BackgroundSubtractionDemo { |
||||
public static void main(String[] args) { |
||||
// Load the native OpenCV library
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME); |
||||
|
||||
new BackgroundSubtraction().run(args); |
||||
} |
||||
} |
@ -0,0 +1,51 @@ |
||||
from __future__ import print_function |
||||
import cv2 as cv |
||||
import argparse |
||||
|
||||
parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \ |
||||
OpenCV. You can process both videos and images.') |
||||
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='../data/vtest.avi') |
||||
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2') |
||||
args = parser.parse_args() |
||||
|
||||
## [create] |
||||
#create Background Subtractor objects |
||||
if args.algo == 'MOG2': |
||||
backSub = cv.createBackgroundSubtractorMOG2() |
||||
else: |
||||
backSub = cv.createBackgroundSubtractorKNN() |
||||
## [create] |
||||
|
||||
## [capture] |
||||
capture = cv.VideoCapture(args.input) |
||||
if not capture.isOpened: |
||||
print('Unable to open: ' + args.input) |
||||
exit(0) |
||||
## [capture] |
||||
|
||||
while True: |
||||
ret, frame = capture.read() |
||||
if frame is None: |
||||
break |
||||
|
||||
## [apply] |
||||
#update the background model |
||||
fgMask = backSub.apply(frame) |
||||
## [apply] |
||||
|
||||
## [display_frame_number] |
||||
#get the frame number and write it on the current frame |
||||
cv.rectangle(frame, (10, 2), (100,20), (255,255,255), -1) |
||||
cv.putText(frame, str(capture.get(cv.CAP_PROP_POS_FRAMES)), (15, 15), |
||||
cv.FONT_HERSHEY_SIMPLEX, 0.5 , (0,0,0)) |
||||
## [display_frame_number] |
||||
|
||||
## [show] |
||||
#show the current frame and the fg masks |
||||
cv.imshow('Frame', frame) |
||||
cv.imshow('FG Mask', fgMask) |
||||
## [show] |
||||
|
||||
keyboard = cv.waitKey(30) |
||||
if keyboard == 'q' or keyboard == 27: |
||||
break |