Showing posts with label tutorial. Show all posts
Saturday, 6 September 2014
Open CV setup
For all of us less fluent Visual Studio users, here are step by step of how I setup Visual Studio, Cmake, and OpenCV to running a working “hello world” type project. Please let me know if I’m doing something unconventional or that is bad practice. We’re all here to learn!
- install Visual Studio 2012 (or any other versions but do know which versions you are installing)
→ note: VC11 is Visual Studio 2012, VC12 is VIsual Studio 2013…
I installed it with all the standard settings, yes to everything
- install OpenCV latest version (I stay away from Alpha versions because they might have bugs and might not be supported by the latest OpenCVSharp which is my end goal.
http://sourceforge.net/projects/opencvlibrary/files/opencv-win/3.0.0-alpha/ → here I downloaded the OpenCV 2.4.9 version http://sourceforge.net/projects/opencvlibrary/files/latest/download?source=files
I went with all the default values and put it in the default directory “C:\opencv249”
- install cmake
go to this address
get the cmake-3.0.1-win32-x86.exe binaries, it makes your life way simpler because it just extracts itself. I went with default locations.
“C:\Program Files (x86)\CMake”
- write a .cpp file with enough to call some OpenCV functions (got this from the openCV site tutorials) http://docs.opencv.org/doc/tutorials/introduction/linux_gcc_cmake/linux_gcc_cmake.html#linux-gcc-usage
Put this file in this directory for example
.\Documents\Visual Studio 2012\Projects\DisplayImage
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv )
{
if ( argc != 2 )
{
printf("usage: DisplayImage.out <Image_Path>\n");
return -1;
}
Mat image;
image = imread( argv[1], 1 );
if ( !image.data )
{
printf("No image data \n");
return -1;
}
namedWindow("Display Image", CV_WINDOW_AUTOSIZE );
imshow("Display Image", image);
waitKey(0);
return 0;
}
- write a cmakelists.txt file that has this inside
cmake_minimum_required(VERSION 2.8)
project( DisplayImage )
find_package( OpenCV REQUIRED )
add_executable( DisplayImage DisplayImage.cpp )
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
- run cmake.exe and browse to the location of the source file and cmakelists.txt
C:/Users/NAME/Documents/Visual Studio 2012/Projects/DisplayImage
point the build to where you want the solution and project files need to be.
C:/Users/NAME/Documents/Visual Studio 2012/Projects/DisplayImage/Build
- when prompted for which compiler, choose Visual Studio 2012 (I am using the 32bit version, you can tell it’s 32bits by the fact that the Visual Studio 2012 folder is under “c:/program files x86” folder.)
→ note: I had the error “error in configuration process” because I had selected Visual Studio 2013, selecting the right version should go through quite nicely
What’s happening here is that you are creating solution and project files that Visual Studio will be able to open, compile and build the project.
it will configure...
Then press Generate, it will generate
- Now go to “C:\Users\NAME\Documents\Visual Studio 2012\Projects\DisplayImage\build” where you just created the solution and project files.
Open the DisplayImage solution file
- Press F6 to build all.
- Now everything is built but this is a command line project so you need to run it from command line
- navigate to the build directory
C:\Users\NAME\Documents\Visual Studio 2012\Projects\DisplayImage\build\Debug
Bring in the needed dlls
→ opencv_highgui249d.dll
→ opencv_imgproc249d.dll
→ opencv_core249d.dll
Bring in an image of your choice (here I brought in an image I called lena.jpg)
(you can right-click and save this one as lena.jpg, to that build directory)
- Now navigate to the right directory in command prompt
type in DisplayImage lena.jpg and you will see the image you put in that directory!
Tuesday, 1 May 2012
How to display Hello World with C#
22:24
C#
,
easy
,
express
,
Hello World
,
Microsoft Visual Studio
,
simple
,
tutorial
,
ultimate
,
video
,
Windows Console Application
,
windows form
No comments
:
Well, this is where it begins, C#, a HelloWorld console and Windows form application.
Microsoft has made it super easy for anybody to start programming, but this is really just the beginning. You'll find tons of sweet additions in C#, my favorite is Intellisense, which accurately predicts what I'm going to be typing simply based on a few letters and history of what I've typed. Intellisense was present in Microsoft Visual C++ but really not to this extent, it was pretty much only useful when you had a class with functions or members.
Here's a video that should guide you through how to get started in C#. It gets more interesting later on but let's start by getting our feet wet.
I like to have a recipe for everything, that way its easier to tell where it went downhill. Watch the video to guide you through.
1- Start Microsoft Visual Studio (whichever version, it'll be the same for now). I'm using the Ultimate edition.
2- Click on New Project
3- Select Windows Console Application
4- Type in a name in the application name: I will type HelloWorldConsole
5- Type Console.WriteLine("Hello World!!!") in the main function
6- Press F5 to start debugging or Ctrl-F5 for start without debugging which will keep the screen on after the application exits.
And there you have it. Your own first program. Play around with what you can type in there as well as format just to confirm to yourself that you are in control of C#... for now.
Console applications are fun for beginners but if you want to do something commercial, it's just not awesome enough. I'd go to at least Windows form for something acceptable and make money or make someone happy. Here's a tutorial on how to do Hello World using Windows Form with C#. As you can see, its very simple and that's thanks to Microsoft (i'm a big fan).
And what's hot now are phone apps. Windows also has its own phone and the beauty of it is that the language used to program it is C#!!! Which means that all the stuff you learn from Windows Forms is reusable here, plus more. I've programmed iPhone-iPad apps before and I'll tell you, the submission procedure is so much simpler with Windows phone that I was considering switching over to Windows phone only.
Here's a hello world video on windows phone, hope you enjoy how simple it is and go from there!
Microsoft has made it super easy for anybody to start programming, but this is really just the beginning. You'll find tons of sweet additions in C#, my favorite is Intellisense, which accurately predicts what I'm going to be typing simply based on a few letters and history of what I've typed. Intellisense was present in Microsoft Visual C++ but really not to this extent, it was pretty much only useful when you had a class with functions or members.
Here's a video that should guide you through how to get started in C#. It gets more interesting later on but let's start by getting our feet wet.
I like to have a recipe for everything, that way its easier to tell where it went downhill. Watch the video to guide you through.
1- Start Microsoft Visual Studio (whichever version, it'll be the same for now). I'm using the Ultimate edition.
2- Click on New Project
3- Select Windows Console Application
4- Type in a name in the application name: I will type HelloWorldConsole
5- Type Console.WriteLine("Hello World!!!") in the main function
6- Press F5 to start debugging or Ctrl-F5 for start without debugging which will keep the screen on after the application exits.
And there you have it. Your own first program. Play around with what you can type in there as well as format just to confirm to yourself that you are in control of C#... for now.
Console applications are fun for beginners but if you want to do something commercial, it's just not awesome enough. I'd go to at least Windows form for something acceptable and make money or make someone happy. Here's a tutorial on how to do Hello World using Windows Form with C#. As you can see, its very simple and that's thanks to Microsoft (i'm a big fan).
And what's hot now are phone apps. Windows also has its own phone and the beauty of it is that the language used to program it is C#!!! Which means that all the stuff you learn from Windows Forms is reusable here, plus more. I've programmed iPhone-iPad apps before and I'll tell you, the submission procedure is so much simpler with Windows phone that I was considering switching over to Windows phone only.
Here's a hello world video on windows phone, hope you enjoy how simple it is and go from there!
Subscribe to:
Posts
(
Atom
)