Ask Your Question

seidju's profile - activity

2020-11-30 09:16:17 -0600 received badge  Famous Question (source)
2019-12-02 03:52:04 -0600 received badge  Nice Question (source)
2017-06-18 07:38:10 -0600 received badge  Notable Question (source)
2017-04-15 07:33:47 -0600 received badge  Notable Question (source)
2017-01-27 05:58:48 -0600 received badge  Notable Question (source)
2016-11-15 16:08:04 -0600 received badge  Popular Question (source)
2016-08-25 11:48:53 -0600 received badge  Famous Question (source)
2016-06-06 03:15:39 -0600 received badge  Popular Question (source)
2016-03-26 13:34:01 -0600 received badge  Popular Question (source)
2016-02-27 03:10:59 -0600 received badge  Notable Question (source)
2015-11-24 09:58:38 -0600 received badge  Popular Question (source)
2015-03-04 19:44:31 -0600 commented answer Find all peaks for Mat() in OpenCV C++

Thanks a lot!

2015-03-04 19:38:35 -0600 received badge  Scholar (source)
2015-03-04 01:51:13 -0600 asked a question Find all peaks for Mat() in OpenCV C++

I want to find all peaks for my image. I need it to divide my picture such way:

enter image description here

So, i already asked question, how to project all image to one of the axis, and now i need to find all maximums on this one-row image. Here's my part of the code:

void segment_plate (Mat input_image) {
    double minVal; 
    double maxVal; 
    Point minLoc; 
    Point maxLoc;
    Mat work_image = input_image;
    Mat output;
    //binarize image
    adaptiveThreshold(work_image,work_image, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, 10);  
    //project it to one axis
    reduce(work_image,output,0,CV_REDUCE_SUM,CV_32S);

    //find minimum and maximum falue for ALL image
    minMaxLoc(output, &minVal,&maxVal,&minLoc,&maxLoc);
    cout << "min val : " << minVal << endl;
    cout << "max val: " << maxVal << endl;

As you can see, i could find one maximum and one minimum for all picture, but i need to find local maximums. Thanks for any help!

EDIT Ok, so i made a mistake, i need to find peaks for this vector. I've used this code to find first peak:

int findPeakUtil(Mat arr, int low, int high, int n) {
// Find index of middle element
    int mid = low + (high - low)/2;  /* (low + high)/2 */

// Compare middle element with its neighbours (if neighbours exist)
    if ((mid == 0 || arr.at<int>(0,mid-1) <= arr.at<int>(0,mid)) &&
        (mid == n-1 || arr.at<int>(0,mid+1) <= arr.at<int>(0,mid)))
    return mid;

// If middle element is not peak and its left neighbor is greater than it
// then left half must have a peak element
    else if (mid > 0 && arr.at<int>(0,mid-1) > arr.at<int>(0,mid))
    return findPeakUtil(arr, low, (mid - 1), n);

// If middle element is not peak and its right neighbor is greater than it
// then right half must have a peak element
    else return findPeakUtil(arr, (mid + 1), high, n);
}

// A wrapper over recursive function findPeakUtil()
int findPeak(Mat arr, int n) {
   return findPeakUtil(arr, 0, n-1, n);
}

So now my code looks like:

void segment_plate (Mat input_image) {
    Mat work_image = input_image;
    Mat output;
    //binarize image
    adaptiveThreshold(work_image,work_image, 255, ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, 10);  
    //project it to one axis
    reduce(work_image,output,0,CV_REDUCE_SUM,CV_32S);
    int n = output.cols;
    printf("Index of a peak point is %d", findPeak(output, n));

But how can i find another peaks? The algorithm of peak finding i took from here.

2015-02-24 01:03:16 -0600 asked a question Open mp4 with libVLC and OpenCV C++

I want to play video file, that i obtained from IP-camera (H264-codec) using libVLC and OpenCV, so i took the code from this post, then created project in VS 2010, and put my mp4 file into project folder ("5.mp4"). When i started it - i got this errors:

main error: open of `5.mp4' failed

main error: Your input can't be opened

main error: VLC is unable to open the MRL '5.mp4'. Check the log for details.

Here's my code:

#include <vlc/vlc.h>
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <stdio.h>

using namespace cv; 
using namespace std;

struct VideoDataStruct {
  int param;
};

int done = 0;
libvlc_media_player_t *mp;
unsigned int videoBufferSize = 0;
uint8_t *videoBuffer = 0;

 void cbVideoPrerender(void *p_video_data, uint8_t **pp_pixel_buffer, int size) {
// Locking
  if (size > videoBufferSize || !videoBuffer)
  {
    printf("Reallocate raw video buffer\n");
    free(videoBuffer);
    videoBuffer = (uint8_t *) malloc(size);
    videoBufferSize = size;
  }

   *pp_pixel_buffer = videoBuffer;
}  

 void cbVideoPostrender(void *p_video_data, uint8_t *p_pixel_buffer, int width, int height, int pixel_pitch, int size, int64_t pts) {
     // Unlocking
     //CloseHandle(hMutex);
 }

 static void handleEvent(const libvlc_event_t* pEvt, void* pUserData) {
   libvlc_time_t time;
   switch(pEvt->type)
   {
      case libvlc_MediaPlayerTimeChanged:
          time = libvlc_media_player_get_time(mp);
          printf("MediaPlayerTimeChanged %lld ms\n", (long long)time);
          break;
      case libvlc_MediaPlayerEndReached:
          printf ("MediaPlayerEndReached\n");
          done = 1;
        break;
       default:
          printf("%s\n", libvlc_event_type_name(pEvt->type));
    }
}

int main(int argc, char* argv[]) {

// VLC pointers 
libvlc_instance_t *inst;
libvlc_media_t *m;
void *pUserData = 0;
VideoDataStruct dataStruct;

// VLC options
char smem_options[1000];
// RV24
sprintf(smem_options
    , "#transcode{vcodec=RV24}:smem{"
     "video-prerender-callback=%lld,"
     "video-postrender-callback=%lld,"
     "video-data=%lld,"
     "no-time-sync},"
    , (long long int)(intptr_t)(void*)&cbVideoPrerender
    , (long long int)(intptr_t)(void*)&cbVideoPostrender
    , (long long int)(intptr_t)(void*)&dataStruct
);

const char * const vlc_args[] = {
          "-I", "dummy",            // Don't use any interface
          "--ignore-config",        // Don't use VLC's config
          "--extraintf=logger",     // Log anything
          "--verbose=1",            // Be verbose
          "--sout", smem_options    // Stream to memory
           };

// We launch VLC
inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);

/* Create a new item */
m = libvlc_media_new_location(inst, "5.mp4");

/* Create a media player playing environement */
mp = libvlc_media_player_new_from_media (m);

libvlc_event_manager_t* eventManager = libvlc_media_player_event_manager(mp);
libvlc_event_attach(eventManager, libvlc_MediaPlayerTimeChanged, handleEvent, pUserData);
libvlc_event_attach(eventManager, libvlc_MediaPlayerEndReached, handleEvent, pUserData);
libvlc_event_attach(eventManager, libvlc_MediaPlayerPositionChanged, handleEvent, pUserData);

libvlc_video_set_format(mp, "RV24", 1280, 720, 1280* 3 );

/* play the media_player */
libvlc_media_player_play (mp);

 while(1)
 {
     if(videoBuffer)            // Check for invalid input
     {
         // CV_8UC3 = 8 bits, 3 chanels
         Mat img = Mat(Size(1280, 720), CV_8UC3, videoBuffer);
         // cvtColor(img, img, CV_RGB2BGR);
         namedWindow("Display window", WINDOW_AUTOSIZE);    // Create a window for display.
         imshow("Display window", img);     // Show our image inside it.
     }
 }
 libvlc_release (inst);
}

I guess, that is easy to fix, but i could't find any information at the Internet. I also tryied to put it into "C:\5.mp4", but i got the same errors. Thanks for any help.

EDIT: Ok, so i fixed this issue, i need to put file:/// before "5.mp4", now my video is playing, but it looks like this: enter image description here

EDIT02 Ok, with "*.avi" everything looks good, so i guess problem with this file - i recorded it frop IP-camera, using VLC, and saved it into *.mp4

2015-02-11 19:27:59 -0600 received badge  Enthusiast
2015-02-05 21:35:00 -0600 asked a question Find lower border of objest using Brightness Histogram

I found some article about car plates recognition, where author used Brightness histogram to find lower border of a car plate: image description

Could you give me some links to examples, to perform this operation in OpenCV C++? Thank you.

2015-02-05 21:07:01 -0600 asked a question Normalize car plate for OCR Opencv C++

I'm doing some simple OCR car plate recognition system. I'm using HaarCascades to find car plate, and next i need to normalize this plate, to put it into my OCR module. I'm using floodfill to find main contours of a car plate, and then i perform Hough transform, to find upper and lower boarders of a car plate:

floodfill

Hough

Here's a part of code, where i perform Hough transform^

HoughLinesP(canny_img, lines, 1, CV_PI/180, 80, 80, 30 );

    for ( size_t i = 0; i < lines.size(); i++ ) {  
        line (output, Point(lines[i][0], lines[i][3]), Point(lines[i][4], lines[i][5]), Scalar(0,0,255), 1, 8 );
    }

Now i need to cut and rotate this picture along this two lines. How can i do this? i understand that i need to use point Point(lines[i][0])..Point(linesi), but what i should do with them?

So basically, i need to get something like that:

1) Image, that i got using HaarCascades

enter image description here

2) After some transformation i need to get something like this:

enter image description here

So at the first step i need to cut only upper and lower boarders.

2015-02-05 02:52:27 -0600 received badge  Supporter (source)
2015-02-04 03:41:58 -0600 commented answer Train Multiclass SVM for car plate recognition

Wow, thanks for clearing thigs up! But how can do it in syntax of opencv? I have 22 folders with pictures of letters, i go to 1st folder - for example , folder A, so i reshape each picture in folder A and put it in data Mat with label 1, then i go to folder B, do the same steps, but what label i need to use 2, or -1? I'm really confused in that numbers...

2015-02-04 03:05:08 -0600 asked a question Train Multiclass SVM for car plate recognition

I'm trying to create a car plate recognition system, using OpenCV (C++). I've already seen this example on GitHub, but I want to use SVM, instead of K-nearest neighbours or Arificial Neural Networks.

I trained a SVM only for two classes (positive or negative), so how can I train to classify characters on the car plate?

I have 22 symbols (Y is the last one symbol) (i.e. 22 classes), should I create a bunch of binary SVMs? For example SVM(0,1), SVM(0,2)....SVM(Y,0), SVM(Y,1)...

If this is the case how can I merge all this files into one, to use it in recognition? I couldn't find any understandable information about it.

2014-09-10 01:58:27 -0600 commented question Free parking space detection

Thanks a lot!

2014-09-10 01:34:36 -0600 received badge  Student (source)
2014-09-09 19:41:20 -0600 commented question Free parking space detection

When i start to do it, i also thought about this seegmentation, but i couldn't find how to do it - is there some manual regarding this? As i understand i should manualy create "zones" , where car could park, ant then using SVM i will check this "zone" - is it a car, ot a empty space?

2014-09-09 01:29:51 -0600 received badge  Editor (source)
2014-09-09 01:01:03 -0600 asked a question Free parking space detection

Hello everyone!

I wanna start service of available parking spaces in different parking lots. The example of such parking lot is on picture below:

image description

So as you can see there's no parking lines, which could be tracked. So what is the simpliest method to count available parking spaces ?

I read few topics about it on StackOverflow, but it doesn't help. I guess the easiest algorithm could be next:

1) Create a some number of ROI of same size as all parking line ( for ex. line with green car):

image description

2) Make this ROI image grayscale

3)Make it blur and perform canny edge detection, maybe dilate:

image description

4) Find contours and approximate this contours with polylines:

image description

After it i need to approximate free empty space with rectangle to figure out how many cars can park on that parking spot. I found how to approximate contours with recnatgles, but how to do it with empty area, where is now contours at all?

There's other option: i could create a rectangle which is the same size as a car is (from camera point of view), than i move this rectangle from left side of roi to the right side, and count how many intersections this retagle will have with contours of ROI, if it's less than some number, it means, that it is a free parking spot.

I'm very new to OpenCV, and i need to make some progress in shortest time. I would really appreciate any help.

Thank you.