Ask Your Question

skipi4's profile - activity

2015-03-25 20:03:34 -0600 answered a question OPEN CV in a pure c compiler

it is possible to compile using only C, but you will run into problems when you start using functions that weren't available in OpenCV v.1 due to not being able to compile some of the libraries in C. If you look at the online reference manual it gives the code for both C and C++, conversion between the two can be tricky but it is possible. Also if you look at the header files for some there is a just a .hpp version but some have a _c.h version which you need to include instead.

If you're struggling to convert the code then upload it and I can provide some help

2015-03-25 19:47:25 -0600 commented question How to recognize elips like a circle

Not quite sure what you mean by this question, are you wanting to detect that black shape in the middle? And do you mean detecting shapes that aren't quite circular?

2015-03-25 17:25:26 -0600 asked a question Beaglebone Compiler Error

When i try to compile my program it is giving me some strange errors that I cannot fix:

root@beaglebone:~# g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` RedDetect.cpp -o RedDetect -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_videoio
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: warning: libopencv_core.so.3.0, needed by //usr/local/lib/libopencv_videoio.so, may conflict with libopencv_core.so.2.4
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: warning: libopencv_core.so.3.0, needed by //usr/local/lib/libopencv_videoio.so, may conflict with libopencv_core.so.2.4
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: /tmp/ccOydwPR.o: undefined reference to symbol '_ZNK2cv11_InputArray12getOGlBufferEv'
/usr/lib/gcc/arm-angstrom-linux-gnueabi/4.7.3/../../../../arm-angstrom-linux-gnueabi/bin/ld: note: '_ZNK2cv11_InputArray12getOGlBufferEv' is defined in DSO //usr/local/lib/libopencv_core.so.3.0 so try adding it to the linker command line
//usr/local/lib/libopencv_core.so.3.0: could not read symbols: Invalid operation
collect2: error: ld returned 1 exit status

I've tried a lot of trouble shooting on the internet but still can't get anywhere, any help would really be appreciated! Thanks in advance

2015-03-25 09:23:47 -0600 commented question Beaglebone: background_segm.hpp error: unknown type name 'namespace'

Shame, thanks anyway, seems odd that nearly every header file has namespace in it somewhere but this is the only one causing an error

2015-03-24 22:30:52 -0600 asked a question Beaglebone: background_segm.hpp error: unknown type name 'namespace'

I'm trying to compile a program which detects and tracks a coloured object, it all works fine in Visual Studio but it won't compile on my Beaglebone Black (running Angstrom), it gives this error:

root@beaglebone:~# gcc OpenCvTest.c -o OpenCvTest
In file included from /usr/include/opencv2/video/video.hpp:47:0,
from /usr/include/opencv2/opencv.hpp:52,
from OpenCvTest.c:3:
/usr/include/opencv2/video/background_segm.hpp:49:1: error: unknown type name 'n
/usr/include/opencv2/video/background_segm.hpp:50:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token

I have a feeling this is because I'm being stubborn and programming in C rather than C++, but is there a way I can edit the background_segm.hpp file to let me compile with C? Or am I missing something and is it acually really easy to compile this C program?

All the open cv header files are in /usr/include and I have tried to make it so that there is no reference to video.hpp or background_segm.hpp but that gives even worse compiler errors.

Thanks in advance

Source Code:

/* Image Processing Program
Will detect and track Red LED */

#include <opencv2/opencv.hpp>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>

#include <stdlib.h> 
#include <stdio.h>  

/* function main */ 
int main(int argc, char** argv) { 

CvCapture* capfromcam;
capfromcam = cvCaptureFromCAM(0);

CvMoments *moments = (CvMoments*)malloc(sizeof(CvMoments));

IplImage* imgRaw;
IplImage* imgHSV;
IplImage* imgFiltered;

int minH = 145;
int maxH = 179;

int minS = 89;
int maxS = 210;

int minV = 68;
int maxV = 255;

CvScalar minHSV = CV_RGB(minH, minS, minV);
CvScalar maxHSV = CV_RGB(maxH, maxS, maxV);

int posX;
int posY;

double m00;
double m01;
double m10;

char EscKeyCheck;

while (1)
{

    /* Capture Image */

    imgRaw = cvQueryFrame(capfromcam);
    cvWaitKey(10);

    if (imgRaw == NULL)
        {
        printf("Null \n");
        return(-1);
        }

    imgHSV = cvCreateImage(cvGetSize(imgRaw), IPL_DEPTH_8U, 3);
    imgFiltered = cvCreateImage(cvGetSize(imgRaw), IPL_DEPTH_8U, 1);

    /* Filter Image */

    cvCvtColor(imgRaw, imgHSV, CV_BGR2HSV);
    cvInRangeS(imgHSV, minHSV, maxHSV, imgFiltered);

    cvErode(imgFiltered, imgFiltered, cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_ELLIPSE, 0), 1);
    cvDilate(imgFiltered, imgFiltered, cvCreateStructuringElementEx(5, 5, 1, 1, CV_SHAPE_ELLIPSE, 0), 2);

    cvDilate(imgFiltered, imgFiltered, cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_ELLIPSE, 0), 2);
    cvErode(imgFiltered, imgFiltered, cvCreateStructuringElementEx(3, 3, 1, 1, CV_SHAPE_ELLIPSE, 0), 1);

    /* Track Image */

    cvMoments(imgFiltered, moments, 0);

    m00 = cvGetSpatialMoment(moments, 0, 0);
    m01 = cvGetSpatialMoment(moments, 0, 1);
    m10 = cvGetSpatialMoment(moments, 1, 0);

    if (m00 > 500)   //if area > 500
    {
        posX = m10 / m00;
        posY = m01 / m00;

        cvCircle(imgRaw, cvPoint(cvRound(posX), cvRound(posY)), 3, CV_RGB(0, 0, 255), CV_FILLED, 8, 0);   /*draw circle on centre*/
        printf("Position x = %3.0d, y = %3.0d\r", posX, posY);   /*print co'ordinates of centre*/
    }

    cvReleaseImage(&imgHSV);   /*release images from memory*/
    cvReleaseImage(&imgFiltered);

    EscKeyCheck = cvWaitKey(10);
    if (EscKeyCheck == 27) break;
}

return 0; 
}