Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Installing OpenCV (http://www.chiefdelphi.com/forums/showthread.php?t=122522)

Greg McKaskle 08-12-2013 07:15

Re: Installing OpenCV
 
That's one possibility, but another is that the corruption is based on memory locations. It is transient and may not happen every time you run. Memory corruptions can be difficult to understand and track down, especially when they deal with heap allocations. Images are big enough that they are almost never stack based.

I could be totally wrong, and you do not need to prove to me that the libraries were corrupted. I was just wanting to put a suggestion out there based on my experience.

Greg McKaskle

yash101 08-12-2013 12:14

Re: Installing OpenCV
 
Yes. I agree. You most likely have more experience with this stuff (programming/electrical/build/etc.).
I am interested in Linux because there it is much more efficient than Windows. It is also a lot easier to get packages, like using Apt. I like a command interface more than a window system, the reason why I have terminal in my Ubuntu startup. Linux doesn't come with all the crapware that Windows typically comes with, meaning that I do not have to spend hours fishing out and cleaning my install. Also, as of what I have experienced, Windows is a resource hog. On my Laptop, I have an SSD. It takes Windows 10 seconds at least to boot, while Ubuntu can boot in two seconds! That isn't the big thing. I got my laptop because 6GB of RAM seemed like a lot. I was quite wrong with that because Windows takes 1GB of RAM, by itself. My Pi takes 128MB of RAM, running hundreds of processes in idle. Also, since my SSD is small (32GB), I have nothing installed, except 7-zip, FileZila and Notepad++.
My laptop has a very crappy processor (i3 2367 [1.4GHz]). With Windows, I can get a max of 8FPS running software like RoboRealm. I can get 32-60FPS on Linux. That is a big difference and when you are doing vision processing on a fast-moving thing, like a robot, you can expect decent lag, using Windows!

This is just what I have noticed and seen. You may have seen something different.

yash101 08-12-2013 17:54

Re: Installing OpenCV
 
Does anyone have a link to some good source code to test OpenCV? I got OpenCV in QT Creator running, and I would like some code to test many functions of it!

Thanks, Hunter! I've finally gotten a working OpenCV install, I think. This is the reason why I use CD and not some other random forum out there!

yash101 08-12-2013 18:12

Re: Installing OpenCV
 
Sorry for the triple post. I think it was kinda needed cause the posts are different from each other.

I was testing example code for OpenCV in QT Creator. It doesn't work for some reason. Here's the code. Can someone help me find out what happened? BTW, if someone wants to help me in real time, I can set up RDP!

Code: (typing without looking made me type Doec :D)
PHP Code:

#include <stdlib.h>
#include <stdio.h>
#include <math.h>
#include "opencv/cv.h"
#include "opencv/highgui.h"

int main(int argcchar *argv[]) {
  
cvNamedWindow("MainWin"CV_WINDOW_AUTOSIZE);
  
cvMoveWindow("mainWin"100,100);
  
cvWaitKey(0);
  return 
0;


Thanks for all of your help!

yash101 21-12-2013 12:52

Re: Installing OpenCV
 
So I was able to compile an opencv program with g++, finally. However, using the command line like this can be a little painful. I followed Hunter's directions, and then used the directions here to compile the code. How do I set up Netbeans to code on?

faust1706 22-12-2013 03:10

Re: Installing OpenCV
 
Yash: on another note: Can you compile OpenNI and freenect now?

yash101 22-12-2013 15:21

Re: Installing OpenCV
 
I haven't tested that yet, though I had noticed that the directions you gave me installed libfreenect. Libfreenect shouldn't be too much of a problem for me because I have even successfully compiled it before! How do I test libfreenect? I don't have and video-game controllers like the kinect or the PS Eye.

billbo911 26-01-2014 19:40

Re: Installing OpenCV
 
I'm trying to use OpenCV on Ubuntu and program, in Python, circle detection for this years game, for obvious reasons ;).

I followed jfausts1706's install directions for installing OpenCV and it worked perfectly. I now have OpenCV 2.3.1 working! I can program in Python and have good success.

When using the HoughCircles function in OpenCV 2.3.1, I have discovered a HUGE PROBLEM. It works fine as long as a circle is detected. Once zero circles are detected, the program crashes. This is a known bug.

I am trying to find a really good example of Python code that detects circles with OpenCV, and uses an alternate method that HoughCircles, but they are REALLY SCARCE.

Can someone either point me to a good resource for this code, or...... I may need to find a way to install a newer version of OpenCV. I am NOT a Linux wizard, but I can use the Synaptic Package Manager or a command line with apt-get if I know what steps to follow. Can anyone either walk me through the process or point me to a clearly and accurately written resource to guide me through the process?

otherguy 26-01-2014 20:00

Re: Installing OpenCV
 
http://askubuntu.com/questions/334158/installing-opencv

Quote:

sudo apt-get install libopencv-dev
should get you the latest

billbo911 26-01-2014 20:17

Re: Installing OpenCV
 
Quote:

Originally Posted by otherguy (Post 1332879)

Yeah, that's exactly what I'm talking about. It installs OpenCV 2.3.1. As I mentioned, I already have OpenCV 2.3.1.
OpenCV 2.3.1 Is not the latest version.

It is starting to look like I'm going to go the "cmake" route, something I am utterly unfamiliar with. That's why I asked for guidance.

faust1706 26-01-2014 20:23

Re: Installing OpenCV
 
Bill,

Have you tried a memory test for the storage device of houghcircles? My python knowledge is really weak, but I believe

if circles is not None:

would be a test to make sure that there are circles.

Or you could findcontours of the image, then check to see if there are contours, and if there are, apply houghcircles. Just some ideas.

billbo911 26-01-2014 21:07

Re: Installing OpenCV
 
Quote:

Originally Posted by faust1706 (Post 1332892)
Bill,

Have you tried a memory test for the storage device of houghcircles? My python knowledge is really weak, but I believe

if circles is not None:

would be a test to make sure that there are circles.

Or you could findcontours of the image, then check to see if there are contours, and if there are, apply houghcircles. Just some ideas.

Now there's a thought! I'll try that next.
One problem so see in that is contours don't always indicate circles. So, the issue would still be there.

Either way, I'll give it a try.

faust1706 26-01-2014 21:58

Re: Installing OpenCV
 
No, contours will not tell you whether there are circles or not, but it will tell you that there is readable data in your input image. Another route would be findcontours then approxpoly and if approxpoly outputs that it has 5 or more sides, call it a circle, or call fitelipse or minboundcircle on the output of contours.

I do not know anyone who has had success with houghcirlces. The math is clever, but it just does not seem to work.

yash101 26-01-2014 22:13

Re: Installing OpenCV
 
I downloaded OpenCV and used ccmake to find out everything that OpenCV supports. I used apt-get to get each and every one of those (that I could find). That OpenCV build/install was beast because the feature set was past you expectations.

I found the problem that OpenCV requires you to manually play with pkg-config to work. I actually memorized the entire build process/apt-get process of installing OpenCV in both Linux and Windows, and now that I look at it, it is quite siimple.

I reinstalled the Operating System, Windows, and now OpenCV works like a charm. However, I get twice the performance in Ubuntu, with Nautilus/Unity. I get even a greater performance with Lubuntu.

I think now I need to get a Lubuntu install and hack it so the CPU governer is set at performance, basically "overclocking" my laptop. Before I do this, does anyone know if I can change the CPU governor on demand? It'd be nice to make the program to automatically set up performance while running, and set the FSB/Governor back to ondemand/power-saver on program exit.

So, finally, I have the install completed in Win7|8|8.1, Ubuntu 12.04/10|13.04/10 and Lubuntu 12.10, both running under Wubi.

The install under Linux:
apt-get install qtcreator libopencv-dev git pkg-config python-opencv

TO compile under linux:
apt-get install cmake-curses-gui build-essential cmake git
git clone <opencv git>
mkdir release&&cd release
ccmake ..
press configure (i think it is c)
note all the things it says possible to build and get what you want. enable those features and press g to generate
cmake ..
make -j <number of cores in system>
use the -j argument if you don't want the compile to use just ~30% processor and take a couple hours. That will multithread the compile
make install:deadhorse:
set up the ldconfig stuff. I can't recall how to do it, but google is nice. ldconfig -v should get it into pkg-config
enjoy
btw, fix any errors you get. they are easy to understand and you have google and CD
apt-get install qtcreator
^^don't do the compile unless you are a guru with linux/compiling large things!!!!!!!!!!!:deadhorse: :deadhorse:


I think I'll put more complete tutorials on my website when i have time. For now, this should be a start for most people who have a moderate experience with compiling stuff. For rookies/newbies, use apt-get because that is just 100x easier! if you want, i can use QEMU to generate RPi images with OpenCV, maybe even compiled!

Don't compile unless you need the latest software. You'll still get 2.4.2 via apt-get so most of the feature will be similar!

By the way, I am thinking about trying hough transforms to find the balls. The ball's location will be found and then go through BGR2RGB => BGR2HSV, or BGR2HSV, depending on the bll color you are looking for. BGR2RGB switches the color channels so red becomes blue and blue becomes red! That should work like a beast if hough transforms are any good.

billbo911 27-01-2014 01:56

Re: Installing OpenCV
 
Quote:

Originally Posted by faust1706 (Post 1332933)
No, contours will not tell you whether there are circles or not, but it will tell you that there is readable data in your input image. Another route would be findcontours then approxpoly and if approxpoly outputs that it has 5 or more sides, call it a circle, or call fitelipse or minboundcircle on the output of contours....

OK, that is starting to work. I actually have something that is starting to work, or so it appears.

Part of the revelation that got me over the hump was that any function that starts with "cv2." just doesn't work well on my system, if at all. It must be the version of OpenCV I have, but as long as I stick to "cv." functions I should be fine. Now, if someone can explain that, and how to rectify it, I would be ALL EARS!


All times are GMT -5. The time now is 22:45.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi