opencv3.0

OutOfMemoryError generated due to camera preview

限于喜欢 提交于 2021-02-04 20:47:30
问题 I managed to open the Android camera using opencv. but when i use the code that fixes the camera orientation -"see the code mentioned below in the onCameraFrame(..) method"- the App crashes after few seconds and the logcat generates the belwo posted messages in the "logcat section". To solve this issue: i tried to use SystemClock.sleep to force the App to dely for a while but this was not a good solution because it delays the camera preview i tried to minimize the frame size as much as i can,

Creating rectangle within a blob using OpenCV

爱⌒轻易说出口 提交于 2021-02-04 13:52:14
问题 Input Image: Output Image: I have several colored blobs in an image and I'm trying to create rectangles (or squares--which seems to be much easier) inside the largest blob of each color. I've found the answer to how to create a rectangle that bounds a single largest blob, but am unsure as to how to find a square that simply fits inside a blob. It doesn't have to be the largest, it just has to be larger than a certain area otherwise I just won't include it. I've also seen some work done on

OpenCV Transparent API UMat is missing

回眸只為那壹抹淺笑 提交于 2021-01-29 09:57:51
问题 I tried to use OpenCV Transparent API UMat class for hardware acceleration in my desktop java application but I couldn't find the UMat class implementation. I'm using OpenCV version 4.1 , where T-API java bindings are said to be available up from version 3.0 as said here: T-API (transparent API) has been introduced, this is transparent GPU acceleration layer using OpenCL. It does not add any compile-time or runtime dependency of OpenCL. When OpenCL is available, it’s detected and used, but it

try to implement cv2.findContours for person detection

假装没事ソ 提交于 2021-01-29 07:32:49
问题 I'm new to opencv and I'm trying to detect person through cv2.findContours with morphological transformation of the video. Here is the code snippet.. import numpy as np import imutils import cv2 as cv import time cap = cv.VideoCapture(0) while(cap.isOpened()): ret, frame = cap.read() #frame = imutils.resize(frame, width=700,height=100) gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) gray = cv.GaussianBlur(gray, (21, 21), 0) cv.accumulateWeighted(gray, avg, 0.5) mask2 = cv.absdiff(gray, cv

It is taking too much time to process frames while doing pixel by pixel operation of video frames

爱⌒轻易说出口 提交于 2021-01-28 20:13:07
问题 import cv2 import numpy as np cap = cv2.VideoCapture(0) def threshold_slow(image): h = image.shape[0] w = image.shape[1] for x in range(0, w): for y in range(0, h): k = np.array(image[x, y]) print(k) def video(): while True: ret,frame = cap.read() frame = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) threshold_slow(frame) cv2.imshow('frame',frame) key = cv2.waitKey(25) if key == ord('q'): break if __name__ == '__main__': video() cap.release() cv2.destroyAllWindows() I have done almost everything I

record and save video stream use opencv in java

狂风中的少年 提交于 2021-01-28 18:26:36
问题 my question is about : how to record and save with the time specified like after two hours this app must done record and save in one folder. public class per1 { public static void main(String[] args) { System.loadLibrary(Core.NATIVE_LIBRARY_NAME); Scanner scan = new Scanner(System.in); VideoCapture camera = new VideoCapture(0); String cc = String.valueOf(camera.get(Videoio.CAP_PROP_FOURCC)); int fps = (int) camera.get(Videoio.CAP_PROP_FPS); int width = (int) camera.get(Videoio.CAP_PROP_FRAME

How to load OpenCV Matrices saved with FileStorage in Java?

旧街凉风 提交于 2021-01-28 04:42:06
问题 In C++, OpenCV has a nice FileStorage class that makes saving and loading Mat a breeze. It's as easy as //To save FileStorage fs(outputFile, FileStorage::WRITE); fs << "variable_name" << variable; //To load FileStorage fs(outputFile, FileStorage::READ); fs["variable_name"] >> variable; The file format is YAML. I want to use a Mat that I create with a C++ program in Java, ideally, loading it from the saved YAML file. However, I cannot find an equivalent class to FileStorage in the Java

How to compile OpenCV with extra modules on OS X?

泪湿孤枕 提交于 2021-01-28 02:57:29
问题 I've previously compiled OpenCV 3.0 successfully following this guide, which essentially consists of the following steps: Download all the prerequisites (XCode, Command Line Tools, CMake and OpenCV source) Build static libs by configuring CMake (via gui) with: Uncheck BUILD_SHARED_LIBS Uncheck BUILD_TESTS Add an SDK path to CMAKE_OSX_SYSROOT (if it matters, I used /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk ). Add x86_64 to CMAKE_OSX

How to compile OpenCV with extra modules on OS X?

为君一笑 提交于 2021-01-28 00:14:00
问题 I've previously compiled OpenCV 3.0 successfully following this guide, which essentially consists of the following steps: Download all the prerequisites (XCode, Command Line Tools, CMake and OpenCV source) Build static libs by configuring CMake (via gui) with: Uncheck BUILD_SHARED_LIBS Uncheck BUILD_TESTS Add an SDK path to CMAKE_OSX_SYSROOT (if it matters, I used /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk ). Add x86_64 to CMAKE_OSX

Finding object boundaries which are close to each other

时光总嘲笑我的痴心妄想 提交于 2021-01-27 18:01:06
问题 I am working on a computer vision problem, in which one step in the problem is find the locations where the objects are close to each other. Example, in the image below I am interesting in finding the regions marked in gray. Input : Output : My current approach is to first invert the image, followed by morphological gradient follower by erosion, then removing some non-interesting contours. Script is as follows: img = cv2.imread('mask.jpg', 0) img = (255 - img) kernel = np.ones((11,11), np