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

Error static function 'bool pyopencv_to not defined

$
0
0
Hi. I've tried to compile opencv 3.4.5 for using nonfree (xfeatures2d). but I can't solve this problem. please help me. 1. OS : windows 10 64bit 2. compiler : visual studio 2017 community (set: release x64) 2. compile error a. code : C2129 b. description : static function 'bool pyopencv_to (PyObject *, T& const char*)' declared but not defined

python: how to compute the sharpness features of image

$
0
0
I am extracting the sharpness features of image as shown in the following image mentioned in a paper. ![sharpness](/upfiles/15470017466249903.png) I have done with the following code. Firstly, use the open cv convert the RGB to HSL (luminance is L mentioned in the paper), then get L array. and then used the Laplacian operator to get the LP. Finally, obtain the sharpness value of image based on mathematical form in the paper. img_HLS = cv2.cvtColor(image, cv2.COLOR_BGR2HLS) L = img_HLS[:, :, 1] u = np.mean(L) LP = cv2.Laplacian(L, cv2.CV_16S, ksize = 3) s = np.sum(gray_lap/u) I don't know my solution is right or wrong, if there is problem, please help me correct it. Thank!

python: how to compute the sharpness features of image

$
0
0
I am extracting the sharpness features of image as shown in the following image mentioned in a paper. ![sharpness](/upfiles/15470017466249903.png) I have done with the following code. Firstly, use the open cv convert the RGB to HSL (luminance is L mentioned in the paper), then get L array. and then used the Laplacian operator to get the LP. Finally, obtain the sharpness value of image based on mathematical form in the paper. img_HLS = cv2.cvtColor(image, cv2.COLOR_BGR2HLS) L = img_HLS[:, :, 1] u = np.mean(L) LP = cv2.Laplacian(L, cv2.CV_16S, ksize = 3) s = np.sum(gray_lap/u) I don't know my solution is right or wrong, if there is problem, please help me correct it. Thank!

cuda::DescriptorMatcher::knnMatch runs in differ

$
0
0
I want to use cuda::DescriptorMatcher::knnMatch to speed up my feature match.But the running time of cuda::DescriptorMatcher::knnMatch with different format input is different. First, if I construct a GpuMat which is pointed to a usr-located gpu-memory. //for enquiry descriptors cv::cuda::GpuMat gpuReferClusterDesc(cv::Mat ...); //for train descriptors float *ptrSearchClusterDesc; cudaMalloc((void**)&ptrSearchClusterDesc, 20000*128*sizeof(float)); ... // do something with ptrSearchClusterDesc cv::cuda::GpuMat gpuSearchClusterDesc(featureNum, 128, CV_32F, ptrClusterSearchDesc); /////////////// //this will takes 20ms. cuda::DescriptorMatcher::knnMatch(gpuReferClusterDesc, gpuSearchClusterDesc, matches, 2) /////////////// if I construct a GpuMat from Mat. //for enquiry descriptors cv::cuda::GpuMat gpuReferClusterDesc(cv::Mat ...); //for train descriptors float *ptrSearchClusterDesc; cudaMalloc((void**)&ptrSearchClusterDesc, 20000*128*sizeof(float)); ... // do something with ptrSearchClusterDesc cv::cuda::GpuMat gpuSearchClusterDesc(featureNum, 128, CV_32F, ptrClusterSearchDesc); cv::Mat matSearchClusterDesc(gpuSearchClusterDesc); cv::cuda::GpuMat gpuMatSearchClusterDesc(matSearchClusterDesc); /////////////// //this will only takes 2ms. cuda::DescriptorMatcher::knnMatch(gpuReferClusterDesc, gpuMatSearchClusterDesc, matches, 2) /////////////// I do not know why. is there anyone knows? thanks

OpenCV crashes after playing a video... help.. please!

$
0
0
I am going thru the tutorials to learn OpenCV. And I have a problem. When I run this code:

import cv2
cap = cv2.VideoCapture('C:\\Users\\wg\\174037210.avi')
while(cap.isOpened()):
    ret, frame = cap.read()
    cv2.imshow('Video', frame)
    if cv2.waitKey(75) & 0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()
which is plain vanilla code I get this error after the video finishes: Traceback (most recent call last): File "C:/Users/wg/python/video-test.py", line 15, in cv2.imshow('Video', frame) cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:356: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow' The environment is as follows: Windows 7 Professional Python 3.6.5 OpenCV 3.4.3 Any help is greatly appreciated. Thanks!

Getting c runtime error?

$
0
0
Hello all, During running the program getting error of Microsoft Visual Studio C Runtime Library has detected a fatal error in test.exe. Please suggest how to resolve. Thanks

How can I draw the x,y, and z axis of a aruco marker and know the distance and the rotation relative to the camera?

$
0
0
Hello, I ran the marker_detection.exe and the aruco markers were successfully detected by passing arguments " marker_detection.exe --ci=1 -d=10". But what kind of arguments should I pass to draw the x,y, and z axis? How can I know the distance and the rotation of a marker relative to the camera? Thanks for any help. Basic marker detection Usage: test.exe [params] -c Camera intrinsic parameters. Needed for camera pose --ci (value:0) Camera id if input doesnt come from video (-v) -d dictionary: DICT_4X4_50=0, DICT_4X4_100=1, DICT_4X4_250=2,DICT_4X4_1000=3, DICT_5X5_50=4, DICT_5X5_100=5, DICT_5X5_250=6, DICT_5X5_1000=7, DICT_6X6_50=8, DICT_6X6_100=9, DICT_6X6_250=10, DICT_6X6_1000=11, DICT_7X7_50=12,DICT_7X7_100=13, DICT_7X7_250=14, DICT_7X7_1000=15, DICT_ARUCO_ORIGINAL = 16,DICT_APRILTAG_16h5=17, DICT_APRILTAG_25h9=18, DICT_APRILTAG_36h10=19, DICT_APRILTAG_36h11=20 --dp File of marker detector parameters -l (value:0.1) Marker side lenght (in meters). Needed for correct scale in camera pose -r show rejected candidates too --refine Corner refinement: CORNER_REFINE_NONE=0, CORNER_REFINE_SUBPIX=1,CORNER_REFINE_CONTOUR=2, CORNER_REFINE_APRILTAG=3 -v Input from video file, if ommited, input comes from camera

Install gstreamer support for opencv python package

$
0
0
I am having trouble enabling gstreamer support for the opencv python package (cv2). gstreamer1.0 is running fine as a standalone and I have manually built the cv2 python package from the OpenCV sources. import cv2 print(cv2.getBuildInformation()) prints: Video I/O: ... GStreamer: NO ... I ensured WITH_GSTREAMER was set to ON during ccmake. Not sure whats left for me to try. Can anyone help? [Here](https://stackoverflow.com/questions/54095699/install-gstreamer-support-for-opencv-python-package) is a link to my related stack overlflow post. Thanks!

Black glow when exposure blending

$
0
0
I have used opencv library in iOS to creat exposure blending of 3 images also 11 images If there is a light source like a brightl light or bright light from windows , it will cause a black glow around the light area Is there any way to remove this glow or at least change the glow color to no color or white glow?

LSH matching very slow

$
0
0
Hey guys and girls, I'm testing a recognition pipeline using ORB descriptors. I recently changed the matcher from bruteforce to flann, using the new LSH index. Unfortunately the LSH matching is about 5-6 times slower than bruteforce using about 1000 descriptors as a database. Has anybody experienced similar problems? Is the LSH code still under development? Current git commit hash: 72a4f19. Part of the code: boost::shared_ptr m_matcherPtr; cv::Ptr indexParams = new cv::flann::LshIndexParams(12, 20, 2); m_matcherPtr = boost::shared_ptr(new cv::FlannBasedMatcher(indexParams)); m_matcherPtr->add(m_descriptorsVec); m_matcherPtr->train(); // This step takes very long m_matcherPtr->knnMatch(*query, knnmatches, 1);

Capture Rectangle Image From WebCam In String to Send It To Server

$
0
0
Below is my Code classifier.detectMultiScale(gray, faces, 1.1, 3, 0); // draw faces. for (let i = 0; i < faces.size(); ++i) { let face = faces.get(i); let point1 = new cv.Point(face.x, face.y); let point2 = new cv.Point(face.x + face.width, face.y + face.height); cv.rectangle(dst, point1, point2, [255, 0, 0, 255]); } cv.imshow('canvasOutput', dst); // schedule the next one. let delay = 1000 / FPS - (Date.now() - begin); $.post('image-data', {"imageInRectangle": ??????}, function(res){ }); At the place of ?????? , I need to capture the face image in rectangle as string and send the Image to server .

How to remove text from manga page?

$
0
0
I'm working on a projet of colorization of Black and white manga pages and I'm having some troubles with the text in the different areas of the page. Specifically, i'm interested in removing the text in the boxes like the red boxes in the image bellow (**the images are open source**). ![Desired boxes](/upfiles/15470596081597157.png) **Is there a way to do this quickly for several images? Any suggestions or example codes in OpenCV will be appreciated. Thanks!** I have already consulted [this answer](https://stackoverflow.com/questions/53592055/opencv-remove-text-from-image), but I don't see how to apply the "Inpainting method" since the text is written in black, and the dominant color in a manga page is BLACK! [The image][1] [1]: https://i.stack.imgur.com/bGYHF.png

Does Opencv js has support for connected components. If so how to use it?

$
0
0
Does OpenCV.js has support for connected components. If so how to use it? Also I only have this nightly build link of Opencv js. So does it work in it. https://docs.opencv.org/master/opencv.js

Long Distance object detection

$
0
0
I want to detect objects - any object at long distances. To do so, I would like to use several high-powered lasers, with each beam separated by a degree or two. I would flash the lasers and turn them on ONLY on every other video frame (I would synchronize them with the camera). The camera would recognize that it was MY lasers by seeing the laser "dot" or "dots" only on every other frame. Of course, these dots would move in the video field a bit between frames, but not a large amount. I have no idea how to do this in OpenCV, and wonder if it is possible, and if so - how. Manually using high-powered green and red lasers, I can easily see reflections from trees and houses in broad daylight that are hundreds of feet away. Of course, if the lasers are aimed at open space, there is no reflection. (unless the air is very dirty or foggy). I don't care how far away the object is, only if there is any object at all.

errors on running FAST algorithm on corner detection

$
0
0
Could any one provide a example python script to test FAST algorithm on corner detection? When I run below example python script from opencv-python tutorial, I get a error "TypeError: Required argument 'outImage' (pos 3) not found" import numpy as np import cv2 from matplotlib import pyplot as plt img = cv2.imread('Penguins.jpg',0) # Initiate FAST object with default values fast = cv2.FastFeatureDetector_create() # find and draw the keypoints kp = fast.detect(img,None) img2 = cv2.drawKeypoints(img, kp, color=(255,0,0)) # Print all default params print "Threshold: ", fast.getInt('threshold') print "nonmaxSuppression: ", fast.getBool('nonmaxSuppression') print "neighborhood: ", fast.getInt('type') print "Total Keypoints with nonmaxSuppression: ", len(kp) cv2.imwrite('fast_true.png',img2) # Disable nonmaxSuppression fast.setBool('nonmaxSuppression',0) kp = fast.detect(img,None) print "Total Keypoints without nonmaxSuppression: ", len(kp) img3 = cv2.drawKeypoints(img, kp, color=(255,0,0)) cv2.imwrite('fast_false.png',img3)

Opencv-dnn's erformance declined significantly on Android with JNI

$
0
0
My OpenCV-dnn shared lib program running in an Android APP through JNI is 2x slower than the original standalone executable binary. Its CPU usage is halved. BTW, the aarch is armv8a here. .so lib and binary share same code and compiling options. So I guess some openmp features used by opencv dnn are restricted in Android APP. The code is too long and quite irrelevant here. Just something like this. code in common parts: void detect() { while (true) { Image img = GetImageFromV4l(); /* do opencv dnn forwarding */ } } JNI: std::thread thr; JNICALL Java_blabla_Detect() { // preprocessing, loading models, etc thr = std::thread(std::bind(detect)); } Binary: int main() { // preprocessing, loading models, etc detect(); return 0; } Opencv compiling flags: -isystem /data/build/android-ndk-r16b/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG -DNDEBUG shared libs packaged with APK And I did try to add `-fopenmp` flag, but that didn't help. The following is the shared libs packaged with my APK. Did I miss something important for opencv/openmp? libc++_shared.so libcurl.so libgnustl_shared.so libopencv_core.so libopencv_flann.so libopencv_imgproc.so libprotobuf.so libtensorflow_mobile.so libc++.so libdl.so libopenblas.so libopencv_dnn.so libopencv_highgui.so libopencv_videoio.so libry_profile.so libc.so libface_engine_jni.so libopencv_calib3d.so libopencv_features2d.so libopencv_imgcodecs.so libopencv_video.so libstlport_shared.so

Opencv-dnn's erformance declined significantly on Android with JNI

$
0
0
My OpenCV-dnn shared lib program running in an Android APP through JNI is 2x slower than the original standalone executable binary. Its CPU usage is halved. BTW, the aarch is armv8a here. .so lib and binary share same code and compiling options. So I guess some openmp features used by opencv dnn are restricted in Android APP. The code is too long and quite irrelevant here. Just something like this. code in common parts: void detect() { while (true) { Image img = GetImageFromV4l(); /* do opencv dnn forwarding */ } } JNI: std::thread thr; JNICALL Java_blabla_Detect() { // preprocessing, loading models, etc thr = std::thread(std::bind(detect)); } Binary: int main() { // preprocessing, loading models, etc detect(); return 0; } Opencv compiling flags: -isystem /data/build/android-ndk-r16b/sysroot/usr/include/aarch64-linux-android -D__ANDROID_API__=21 -g -DANDROID -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -Wa,--noexecstack -Wformat -Werror=format-security -std=c++11 -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Winit-self -Winconsistent-missing-override -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-unnamed-type-template-args -Wno-comment -fdiagnostics-show-option -Qunused-arguments -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O2 -DNDEBUG -DNDEBUG shared libs packaged with APK And I did try to add `-fopenmp` flag, but that didn't help. The following is the shared libs packaged with my APK. Did I miss something important for opencv/openmp? libc++_shared.so libcurl.so libgnustl_shared.so libopencv_core.so libopencv_flann.so libopencv_imgproc.so libprotobuf.so libtensorflow_mobile.so libc++.so libdl.so libopenblas.so libopencv_dnn.so libopencv_highgui.so libopencv_videoio.so libry_profile.so libc.so libface_engine_jni.so libopencv_calib3d.so libopencv_features2d.so libopencv_imgcodecs.so libopencv_video.so libstlport_shared.so

How to reduce noise from technical drawings?

$
0
0
I receive some technical drawings from my co-worker. It is scanned. Some lines in that have noise as the following image: ![image description](/upfiles/1547090812410970.png) ![image description](/upfiles/1547090820987686.png) My expected results: ![image description](/upfiles/15470915192310286.png) ![image description](/upfiles/1547091445259485.png) All above image i have applied bilateral blur. (if not apply, received results are not good to do something) Please show me some idea/solution to get my expected result. Thank you so much!

Convert Image Points to Azimuth and Elevation

$
0
0
I'm tracking objects in an image and I want to record each point, but I want to use world coordinates instead of image coordinates specifically azimuth and elevation. The two values need to be represented in degrees and scaled to 32-bit integers. ##Two questions: **What is the proper transform to use and what are the parameters?** I can fake the camera intrinsics just to get something working, but I'm not sure that I have enough information. **Does OpenCV have this capability built in?** This seems like a common problem and I would think OpenCV or Numpy would have methods to solve this problem I'm just unfamiliar with them.

readNetFromTensorflow() errors from Mask_RCNN model

$
0
0
I made my Mask_RCNN model from this github [project](https://github.com/matterport/Mask_RCNN/) it is a project written with tensorflow and keras. Enviroment : win7 x64 visual studio 2015 opencv 4.0.1 tensorflow 1.12 GPU gtx1060 CUDA 9.0 since it saves its weights to .h5 file, I want to turn it to .pb and .pbtxt so that I can read it by readNetFromTensorflow(). I wrote something like def h5_to_pb(h5_model,output_dir,model_name,out_prefix = "output_",log_tensorboard = True): if osp.exists(output_dir) == False: os.mkdir(output_dir) out_nodes = [] for i in range(len(h5_model.outputs)): out_nodes.append(out_prefix + str(i + 1)) tf.identity(h5_model.output[i],out_prefix + str(i + 1)) sess = K.get_session() from tensorflow.python.framework import graph_util,graph_io init_graph = sess.graph.as_graph_def() main_graph = graph_util.convert_variables_to_constants(sess,init_graph,out_nodes) graph_io.write_graph(main_graph,output_dir,name = model_name,as_text = False) if log_tensorboard: from tensorflow.python.tools import import_pb_to_tensorboard import_pb_to_tensorboard.import_to_tensorboard(osp.join(output_dir,model_name),output_dir) output_dir = osp.join(os.getcwd(),"trans_model") output_dir = "D:/" ROOT_DIR = os.path.abspath("C:/Mask_RCNN/") MODEL_DIR = os.path.join(ROOT_DIR, "logs") model = modellib.MaskRCNN(mode="inference", config=config, model_dir=MODEL_DIR) # model.keras_model.summary() # print(model.keras_model.inputs) # print(model.keras_model.outputs) model.load_weights(weight_file_path, by_name=True) h5_model = model.keras_model print(len(h5_model.outputs)) h5_to_pb(h5_model,output_dir = output_dir,model_name = output_graph_name) then I turned pb to pbtxt def convert_pb_to_pbtxt(filename): with gfile.FastGFile(filename,'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) tf.import_graph_def(graph_def, name='') tf.train.write_graph(graph_def, './', 'protobuf.pbtxt', as_text=True) return then I got the error Error parsing text-format opencv_te nsorflow.GraphDef: 41208:5: Unknown enumeration value of "DT_RESOURCE" for field "type". OpenCV(4.0.1) Error: Unspecified error (FAILED: ReadProtoFromTextFile(param_file , param). Failed to parse GraphDef file: D:/model_1.pbtxt) in cv::dnn::ReadTFNet ParamsFromTextFileOrDie, file C:\build\master_winpack-build-win64-vc14\opencv\mo dules\dnn\src\tensorflow\tf_io.cpp, line 54 it seem that the format of the pbtxt is not right, so can anyone tell me how to turn the model I trained to let the opencv read it to do the object detection please?
Viewing all 41027 articles
Browse latest View live


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