

I have a car park model image and wish to test the capture of an irregular cropped portion to detail how many edges exist. The idea being to advise if a space contains a vehicle in it.
Everytime I try this, I just get various errors relating to the image not having the right attributes. The code is below,
im = Image.open('0.png')
bay1 = image.edge(10,300)
image_matrix = bay1.getNumpy().flatten()
image_pixel_count = cv2.countNonZero(image_matrix)
canny_count[iCol] += image_pixel_count
Any help would be appreciated on how to get an edge count of 0.png
↧
How to count the edges in a cropped image
↧
Where should I include ueye libraries?
Hi guys,
I am going to use ueye camera for image processing and am totally new in this field. I have already installed Visual community and opencv following this tutorial: https://www.youtube.com/watch?v=7SM5OD2pZKY
I have runned one sample program included also in this tutorial and included the opencv folders in the project settings.
However, I don't understand yet, *where should I include the ueye libraries* (including e.g. ueye.h and uEye_api.lib etc.) and why do we use openCV? I just have been told that we should use opencv with visual studio for image processing!
Thanks you!
↧
↧
Orientation of two contours
I try to calculate the orientation of 2 contours. At the end i want to rotate one contour, so it is in cover with the other one. With my code I get a result, but it isn't that accurate. Also I get the same orientations although the contours is rotated around 90 degrees.
Here is my code:
Moments moments_dxf;
Moments moments_img;
moments_dxf = moments( mcontours_dxf[ alargest_contour_index_dxf ], true );
double theta_dxf_outer = 0.5 * atan( ( 2 * moments_dxf_outer.mu11 ) / ( moments_dxf_outer.mu20 - moments_dxf_outer.mu02 ) );
moments_img = moments( mcontours_image[ alargest_contour_index_img ], true );
double theta_img_outer = 0.5 * atan( ( 2 * moments_img_outer.mu11 ) / ( moments_img_outer.mu20 - moments_img_outer.mu02 ) );
has anyone an idea?
↧
SVM predicting '1' for every test image.
I am using SVM for facial expression recognition through opencv. I have trained my svm model with 50 images for each expression(happy, sad, angry) assigning labels 0,1,2 for each expression respectively, however while testing it predicts only '1' as label (that is label for sad). What should I do??
↧
Video composition by selecting videos randomly
I have multiple videos that I want to compose to get a single video. Currently I am using the following code to compose a video .
video_index=0
cap=cv2.VideoCapture(video[srt_time[video_index]])
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = cap.get(cv2.CAP_PROP_FPS)
count=cap.get(cv2.CAP_PROP_FRAME_COUNT)
fourcc = cv2.VideoWriter_fourcc(*'DIVX')
out = cv2.VideoWriter("Output.avi", fourcc, fps, (width, height), True)
while(cap.isOpened()):
ret,frame=cap.read()
if frame is None:
print "end of video " + str(video_index) + " .. next one now"
video_index += 1
if video_index >= len(videoList):
break
cap = cv2.VideoCapture(video[srt_time[video_index]])
ret, frame = cap.read()
out.write(frame).
This code gives me a video remix which contains a video one after another. But now I want a video remix which switches views between the videos randomly. Like for example video starts with video 1 and after some time it randomly switches to any of the other two videos . After reading that selected video it again randomly switches to another video. basically, there should be a random switch between videos in the composed videos.
↧
↧
Is it possible to port CascadeClassifier from v 2.4.11 to 3.1.0
In what way can I port cv CascadeClassifier from v 2.4.11 to cuda CascadeClassifier v 3.1.0 ?
↧
connecting two closest line after perform Houghline operation
After using probabilistic houghline operation in an image, i have the information of line's two co-ordinate points. Anyhow, my line is broken, show as a two line, so now i have to connect those line which are broken. Now, how can i do it? I am attaching the image after houghline operation looks like:
↧
which version is suitable for Visual Studio 2008/2012 64bit.
Hi,
I have both VS 2008 and 2012 version. I need to use 64 bit compile. so which is the best Opencv for 64 bit compilation.
Advance Thanks for your support.
↧
Which are the most important segmentation algorithms?
Hello everybody,
For my studies, I need to learn about the most important segmentation algorithms in OpenCV.
Today I don’t know much about OpenCV at all (total noob). So, first I need to find out which algorithms exist. After that how they work, where their limits are, to understand how to choose the right one for a specific task and at least how to use them plus to teach their use to my fellow students.
I must use c# openCVSharp OpenCV2.4.10 All-in-one package from github.com
Maybe this reduces a bit the number of algorithms.?.
Thanks for every help!
↧
↧
installation when wrong on ubuntu 16.10
Hello guys I'm trying to install opencv- 2.4-13 on ubuntu 16.10(x64)
/opencv-2.4.13/release$ make -j2
[ 0%] Built target opencv_core_pch_dephelp
[ 2%] Built target opencv_perf_core_pch_dephelp
[ 5%] Built target IlmImf
[ 5%] Built target opencv_test_core_pch_dephelp
[ 5%] Built target opencv_ts_pch_dephelp
[ 5%] Automatic moc for target opencv_highgui
[ 5%] Automatic moc for target opencv_highgui_pch_dephelp
[ 5%] Built target opencv_highgui_pch_dephelp_automoc
[ 5%] Built target opencv_highgui_automoc
[ 5%] Built target opencv_imgproc_pch_dephelp
[ 6%] Built target opencv_flann_pch_dephelp
[ 6%] Built target opencv_features2d_pch_dephelp
[ 6%] Built target opencv_calib3d_pch_dephelp
[ 6%] Built target opencv_video_pch_dephelp
[ 6%] Generating test_precomp.hpp.gch/opencv_test_core_RELEASE.gch
[ 6%] Generating perf_precomp.hpp.gch/opencv_perf_core_RELEASE.gch
In file included from /usr/include/c++/6/ext/string_conversions.h:41:0,
from /usr/include/c++/6/bits/basic_string.h:5402,
from /usr/include/c++/6/string:52,
from /usr/include/c++/6/bits/locale_classes.h:40,
from /usr/include/c++/6/bits/ios_base.h:41,
from /usr/include/c++/6/ios:42,
from /usr/include/c++/6/ostream:38,
from /home/q_p/opencv-2.4.13/modules/ts/include/opencv2/ts/ts_gtest.h:55,
from /home/q_p/opencv-2.4.13/modules/ts/include/opencv2/ts/ts.hpp:66,
from /home/q_p/opencv-2.4.13/release/modules/core/test_precomp.hpp:12:
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next
^
In file included from /usr/include/c++/6/ext/string_conversions.h:41:0,
from /usr/include/c++/6/bits/basic_string.h:5402,
from /usr/include/c++/6/string:52,
from /usr/include/c++/6/bits/locale_classes.h:40,
from /usr/include/c++/6/bits/ios_base.h:41,
from /usr/include/c++/6/ios:42,
from /usr/include/c++/6/ostream:38,
from /home/q_p/opencv-2.4.13/modules/ts/include/opencv2/ts/ts_gtest.h:55,
from /home/q_p/opencv-2.4.13/modules/ts/include/opencv2/ts/ts.hpp:66,
from /home/q_p/opencv-2.4.13/release/modules/core/perf_precomp.hpp:12:
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
#include_next
^
compilation terminated.
compilation terminated.
modules/core/CMakeFiles/pch_Generate_opencv_perf_core.dir/build.make:62: recipe for target 'modules/core/perf_precomp.hpp.gch/opencv_perf_core_RELEASE.gch' failed
make[2]: *** [modules/core/perf_precomp.hpp.gch/opencv_perf_core_RELEASE.gch] Error 1
CMakeFiles/Makefile2:1250: recipe for target 'modules/core/CMakeFiles/pch_Generate_opencv_perf_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_perf_core.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
modules/core/CMakeFiles/pch_Generate_opencv_test_core.dir/build.make:62: recipe for target 'modules/core/test_precomp.hpp.gch/opencv_test_core_RELEASE.gch' failed
make[2]: *** [modules/core/test_precomp.hpp.gch/opencv_test_core_RELEASE.gch] Error 1
CMakeFiles/Makefile2:1128: recipe for target 'modules/core/CMakeFiles/pch_Generate_opencv_test_core.dir/all' failed
make[1]: *** [modules/core/CMakeFiles/pch_Generate_opencv_test_core.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2
Thx for your time
↧
OpenCV version 3 basic info ? Python only ?
It looks as OpenCV version 3 has some major differences in files etc.
Running CMake using supplied file creates /usr/local/lib/pkgconfig which appears to be Python wrapper for "pkg-config" thus unusable in "plain " C++ , right?
So - is there some info on how OpenCV 3 works ?
Is it the latest to be used on Linux/ Ubuntu ?
Is it some undocumented "fork" of real OpenCV?
↧
Which are the most important segmentation algorithms?
**Hello everybody,**
For my studies, I need to learn about the most important segmentation algorithms in OpenCV.
Today I don’t know much about OpenCV at all (total noob). So, first I need to find out which algorithms exist. After that how they work, where their limits are, to understand how to choose the right one for a specific task and at least how to use them plus to teach their use to my fellow students.
**Thanks for every help!**
↧
undefined reference to `cv::imread
Hi, I'm using CLion as IDE and trying to link OpenCV. But I'm having problem even with a very simple app.
I prepared OpenCV binaries with these steps.
1. Extract OpenCV files (from official website)
2. Generate a build folder with CMake
3. In the directory generated by CMake, execute "mingw32-make" command
4. Add "OPENCV_DIR" to system variables. ("C:\OpenCV\mingw-build" in my case)
5. Add "%OPENCV_DIR%\bin" to system path
My CPP Code:
#include
#include
#include
using namespace std;
using namespace cv;
int main() {
string file = "image.jpg";
Mat img = imread(file.c_str(), 1);
namedWindow("image", WINDOW_AUTOSIZE);
imshow("image", img);
waitKey(0);
return 0;
}
My CMakeLists.txt
cmake_minimum_required(VERSION 3.6)
project(OpenCVFirstDemo)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
find_package(OpenCV REQUIRED)
set(SOURCE_FILES main.cpp)
add_executable(OpenCVFirstDemo ${SOURCE_FILES})
target_link_libraries(OpenCVFirstDemo ${OpenCV_LIBS})
And when I try to build, I'm getting the following messages.
"C:\Program Files (x86)\JetBrains\CLion 2016.2.3\bin\cmake\bin\cmake.exe" --build C:\Users\CagdasX\.CLion2016.2\system\cmake\generated\OpenCVFirstDemo-f9ecc709\f9ecc709\Debug --target OpenCVFirstDemo -- -j 8
Scanning dependencies of target OpenCVFirstDemo
[ 50%] Building CXX object CMakeFiles/OpenCVFirstDemo.dir/main.cpp.obj
[100%] Linking CXX executable OpenCVFirstDemo.exe
CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `main':
C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:9: undefined reference to `cv::imread(cv::String const&, int)'
C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:10: undefined reference to `cv::namedWindow(cv::String const&, int)'
C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:11: undefined reference to `cv::imshow(cv::String const&, cv::_InputArray const&)'
C:/Users/CagdasX/ClionProjects/OpenCVFirstDemo/main.cpp:12: undefined reference to `cv::waitKey(int)'
CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv6StringC1EPKc':
C:/OpenCV/sources/modules/core/include/opencv2/core/cvstd.hpp:625: undefined reference to `cv::String::allocate(unsigned int)'
CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv6StringD1Ev':
C:/OpenCV/sources/modules/core/include/opencv2/core/cvstd.hpp:667: undefined reference to `cv::String::deallocate()'
CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv3MatD1Ev':
C:/OpenCV/sources/modules/core/include/opencv2/core/mat.inl.hpp:571: undefined reference to `cv::fastFree(void*)'
CMakeFiles\OpenCVFirstDemo.dir/objects.a(main.cpp.obj): In function `ZN2cv3Mat7releaseEv':
C:/OpenCV/sources/modules/core/include/opencv2/core/mat.inl.hpp:682: undefined reference to `cv::Mat::deallocate()'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\OpenCVFirstDemo.dir\build.make:112: recipe for target 'OpenCVFirstDemo.exe' failed
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/OpenCVFirstDemo.dir/all' failed
mingw32-make.exe[3]: *** [OpenCVFirstDemo.exe] Error 1
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/OpenCVFirstDemo.dir/rule' failed
mingw32-make.exe[2]: *** [CMakeFiles/OpenCVFirstDemo.dir/all] Error 2
mingw32-make.exe[1]: *** [CMakeFiles/OpenCVFirstDemo.dir/rule] Error 2
Makefile:117: recipe for target 'OpenCVFirstDemo' failed
mingw32-make.exe: *** [OpenCVFirstDemo] Error 2
↧
↧
Hough Transform after removal of color
I have a hough transform object detection code which detects the target objects. But a few lines are detected from the green background (trees). I wish to eliminate all the green background. I tried a code based on [this](http://opencv-srf.blogspot.com/2010/09/object-detection-using-color-seperation.html) and it worked fine. But the problem is that the resulting image is black and white. I want the green part to go black, but I want the rest to remain as the original image.
I also tried the second solution from [this](http://answers.opencv.org/question/31592/subtract-color-from-mat/), with the image given there. The problem was whenever I accessed the result image and displayed it with `imshow`, it would display like the original.
So, are there any better solutions? Is there a way that I can see all pixels that fall in an hsv range, using `inRange` and then, instead of turning the whole image black and white, just turn those pixels in the range to black?
↧
creating mp4 file in linux
I can read and play the file but when I write a mp4 or even avi video its not playable . I have confirmed that ffmpeg can create the video fine so why from openCV its not working?
iam using openCV 3.1.0 and python 3.3
ffmpeg -i /tmp/kyak.mp4 -vcodec libx264 -f mp4 /tmp/a.mp4
the code below produces the file but it contains zero frame as shown by ffmpeg command .
import numpy as np
import cv2
cap = cv2.VideoCapture('/tmp/kyak.mp4')
fourcc = cv2.VideoWriter_fourcc('X','2','6','4')
out = cv2.VideoWriter('/tmp/output.mp4',fourcc, 20.0, (640,480))
while (cap.isOpened()):
ret,frame=cap.read()
if ret == True:
gray = cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY)
#write the gray frame
out.write(gray)
cv2.imshow('frame',gray)
if cv2.waitKey(30) & 0xFF == ord('q'):
break
else:
break
cap.release()
out.release()
cv2.destroyAllWindows()
The video plays but I get this error from the code above :
OpenCV: FFMPEG: tag 0x34363258/'X264' is not supported with codec id 28 and format 'mp4 / MP4 (MPEG-4 Part 14)'
OpenCV: FFMPEG: fallback to use tag 0x00000021/'!???'
if I replace the "fourcc" with "0x00000021" then the error goes away but still the produced file has zero frame .
[root@hadoop1 scripts]# ffmpeg -i /tmp/output.mp4
ffmpeg version N-82533-gae514b1 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-17)
configuration: --enable-libx264 --enable-gpl --enable-shared
libavutil 55. 40.100 / 55. 40.100
libavcodec 57. 66.105 / 57. 66.105
libavformat 57. 57.100 / 57. 57.100
libavdevice 57. 2.100 / 57. 2.100
libavfilter 6. 67.100 / 6. 67.100
libswscale 4. 3.101 / 4. 3.101
libswresample 2. 4.100 / 2. 4.100
libpostproc 54. 2.100 / 54. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/tmp/output.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf57.57.100
Duration: 00:00:00.00, bitrate: N/A
↧
Questions on camera matrices
I am getting very confused on camera matrices.
1) Does the extrinsic matrix describe the transformation from object to camera or camera to object ?
2) Does the extrinsic matrix apply the rotation before the translation or vice versa ? In either case, does it transform the points with respect to the original origin ? Like translate(p with respect to origin) then rotate(p with respect to origin) or is it like translate(p with respect to origin) then rotate(p with respect to new origin after the translation) ?
3) I read that the extrinsic matrix transforms points in world coordinates to camera coordinates. When do I use this ? Aren't my camera always the origin ?
4) Does the extrinsic matrix bring my camera to the world origin or does it bring the world origin to my camera ?
5) Does anyone know of any link or any simple example with images that show the above numerically ? I think being able to watch a correct simple example with numerical would greatly help my understanding. I am getting extremely confused by this extrinsic matrix. What happens before and after applying the matrix and where my objects and cameras are before and after.
↧
cmake failing with hash mismatch
I am trying to build opencv but cmake is failing with the following error , i have had this before and i could find the files and manually put them on the server but this time this file "bootdesc_bgm.i" is no where to be found , please help.
I even upgraded my cmake to 3.0 .
-- Check contents of boostdesc_bgm.i ...
-- Downloading boostdesc_bgm.i...
CMake Error at /root/opencv/cmake/OpenCVUtils.cmake:895 (file):
file DOWNLOAD HASH mismatch
for file: [/root/opencv_contrib/modules/xfeatures2d/cmake/.download/0ea90e7a8f3f7876d450e4149c97c74f/boostdesc_bgm.i]
expected hash: [0ea90e7a8f3f7876d450e4149c97c74f]
actual hash: [d41d8cd98f00b204e9800998ecf8427e]
status: [1;"unsupported protocol"]
here is the cmake command i am using
cmake -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_NEW_PYTHON_SUPPORT=ON -DWITH_TBB=ON -DBUILD_TBB=ON -DWITH_OPENGL=ON -DWITH_EIGEN=ON -DFFMPEG_INCLUDE_DIR=/usr/local/include -DOPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib/modules -DBUILD_opencv_legacy=OFF ..
↧
↧
How to recognize the blue or red soft saucers?
How to recognize the blue or red soft saucers ?
Additional,how to recognize their motion trail when they are flying?
Please tell me a way to use opencv library to get the solution about this .
↧
install opencv on mac
I am trying to install opencv on my mac
cd ~/opencv
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
make
I get the following error,
ld: framework not found CoreImage
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/libopencv_videoio.3.1.0.dylib] Error 1
make[1]: *** [modules/videoio/CMakeFiles/opencv_videoio.dir/all] Error 2
make: *** [all] Error 2
↧
boundingRect assertion error
cv::Rect rect = cv::boundingRect(opencv_crd_mat);
OpenCV Error: Assertion failed (npoints >= 0 && (depth == CV_32F || depth == CV_32S)) in cv::pointSetBoundingRect, file C:\Bin\opencv-master\source\modules\imgproc\src\shapedescr.cpp, line 458
This is my opencv_crd_mat 8 cols 2 rows.
[-4281.8457, -4315.7046, -7327.6001, -7293.7407, -2615.3616, -2649.2207, -5661.1162, -5627.2568;
-995.60034, -20469.369, -21360.467, -1886.6984, -1013.2598, -20487.029, -21378.127, -1904.3578]
↧