debug openCV with qt creator on ubuntu 14.04 - debugging

I try to debug some openCV code with qt creator on Ubuntu 14.04
But if i step through the lines the debugger don't step into the openCV files.
This is the code want to debug
#include <QCoreApplication>
#include <stdio.h>
#include <opencv2/features2d/features2d.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
int main(int argc, char *argv[]) {
Mat img_1 = imread( argv[1], CV_LOAD_IMAGE_GRAYSCALE );
Mat img_2;
FastFeatureDetector fast = FastFeatureDetector(); <-----
vector<KeyPoint> kp;
fast.detect(img_1,kp); <------
Scalar color = (255,0,0);
drawKeypoints(img_1,kp,img_2,color);
namedWindow( "Display window", WINDOW_AUTOSIZE );
imshow( "Display window", img_2 );
waitKey(0);
return -1;
}
I will step into the openCV files I comment with "<-----"
Thanks for the help

Related

GDI+ methods are missing

So I'm trying to use the method Bitmap::GetHistogram from GDI+ but apparently it doesn't exist. I already made sure to initialize everything with
Gdiplus::GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
at the start of WinMain, here's the problematic snippet:
UINT numEntries;
Gdiplus::Bitmap myBitmap(pszFilePath);
Gdiplus::Image myImage(pszFilePath);
UINT iHeight = myImage.GetHeight(); // works
UINT iWidth = myImage.GetWidth(); // works
myBitmap.GetHistogramSize(HistogramFormatRGB, &numEntries); // not defined
These are all the header files included:
#include <Unknwn.h>
#include <windows.h>
#include <Gdiplus.h>
#include <stdio.h>
#include <iostream>
#include <commdlg.h>
#include <commctrl.h>
#include <winioctl.h>
#include <Objbase.h>
#include <shobjidl.h>
#include <objidl.h>
#include <strsafe.h>
The method simply isn't' there:
What might causing this and how do I fix it?
I'm curious as to why this happened
Because the method needs the GDIPVER >= 0x0110 in gdiplusbitmap.h:
#if (GDIPVER >= 0x0110)
...
inline Status
Bitmap::GetHistogram(
IN HistogramFormat format,
IN UINT NumberOfEntries,
_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel0,
_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel1,
_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel2,
_Out_writes_bytes_(sizeof(UINT)*256) UINT *channel3
)
{
return DllExports::GdipBitmapGetHistogram(
static_cast<GpBitmap *>(nativeImage),
format,
NumberOfEntries,
channel0,
channel1,
channel2,
channel3
);
}
inline Status
Bitmap::GetHistogramSize(
IN HistogramFormat format,
OUT UINT *NumberOfEntries
)
{
return DllExports::GdipBitmapGetHistogramSize(
format,
NumberOfEntries
);
}
#endif // (GDIPVER >= 0x0110)
All recent OS (>= Vista) have GDIPlus 1.1. But if you do not specify GDIPVER to 0x0110 to enable the function of version 1.1, the default version will be specified as 1.0 in gdiplus.h:
// Define the Current GDIPlus Version
#ifndef GDIPVER
#define GDIPVER 0x0100
#endif

How fix my codeblocks compile programm use fstream, cannot open files large 20 mbs?

#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
char fileInputPath[256] = "D:\25mb.file";
ifstream fileInput(fileInputPath, ios::in|ios::binary);
if (fileInput.is_open() != true) cout << "File not opened.\n";
return 0;
}
programm result:
File not opened
tesing system win7 x32

opencv videocapture empty frame

i'm trying to acquire image from an wireless cam with EasyCAP tuner. I can get images with any other video capture programs and matlab but in opencv i get empty frames. This code worked with my laptop webcam and with a logitec webcam. With tuner it sends me in infinite loop here beacuse of empty frame.
while (frame.empty())
cap>>frame;
I'm using visual stuido 2010 , i have tuner on the 2nd slot(first is webcam)and my code is:
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <windows.h>
#include <stdio.h>
using namespace cv;
using namespace std;
VideoCapture cap(1);
Mat frame;
void main()
{
char key;
namedWindow("imag", WINDOW_AUTOSIZE);
Sleep(1000);
cap.set(CV_CAP_PROP_FRAME_WIDTH,160);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,120);
cap.set(CV_CAP_PROP_FPS,15);
cap.set(CV_CAP_PROP_FOURCC,CV_FOURCC('B', 'G', 'R', '3'));
while (1)
{
cap>>frame;
while (frame.empty())
cap>>frame;
imshow("imag",frame);
waitKey(33);
}
}
without set proprieties is the same

OpenCV cannot load image

While I was working on a project, I noticed that I am not able to load images. Here is the simple code that I used to check:
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main( int argc, char** argv )
{
if( argc != 2)
{
cout <<" Usage: display_image ImageToLoadAndDisplay" << endl;
return -1;
}
Mat image;
image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file
if(! image.data ) // Check for invalid input
{
cout << "Could not open or find the image" << std::endl ;
return -1;
}
Mat gray_image;
cv::cvtColor(image, gray_image, CV_RGB2GRAY);
imwrite("Gray_Image.jpg",gray_image);
return 0;
}
Here is its output when I execute it:
root#beaglebone:~# ./tryit lena.jpg
Could not open or find the image
I tried to directly use the address of the image ("/home/root/lena.jpg") instead of argv[1] but nothing changed.
What can be the problem?
ps: I am cross-compiling this OpenCV program and then running it on my BeagleBone which has Angstrom Linux installed on it. Can this problem related to it?
I solved my problem by deleting existing OpenCV libraries on my angstrom image and replacing them with the working ones.
Try saving the image with a png extension and then opening it. For some reason, files with a png extension work better than other extensions like jpg/gif.

Can't Build a simple Cuda Program using Xcode !

I'm using Xcode 3.2 on Mac OS 10.6 to build a very simple HelloWorld program for CUDA
but it fails to build .. any ideas !!!
this is the code :
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <CUDA/CUDA.h>
__device__ char napis_device[14];
__global__ void helloWorldOnDevice(void){
napis_device[0]='H';
napis_device[1]='e';
napis_device[2]='l';
napis_device[3]='l';
napis_device[4]='o';
napis_device[5]=' ';
napis_device[6]='W';
napis_device[7]='o';
napis_device[8]='r';
napis_device[9]='l';
napis_device[10]='d';
napis_device[11]='\n';
}
int main (int argc, char * const argv[]) {
helloWorldOnDevice<<<1,1>>> ();
cudaThreadSynchronize();
char napis_host[14];
const char *symbol="napis device";
cudaMemcpyFromSymbol (napis_host, symbol, sizeof(char)*13, 0, cudaMemcpyDeviceToHost);
return 0;
}
The error appears at this line
helloWorldOnDevice<<<1,1>>> ();
Expected primary-expression before '<' token !!!!!!
You're compiling your program with gcc coming with Xcode. Should use nvcc compiler instead to compile CUDA code. Normally I would use a Makefile to tell that *.cu to be compiled by nvcc and *.cpp by gcc, then link produced objects to an executable.

Resources