Ask Your Question

Lafi's profile - activity

2019-04-06 05:10:21 -0500 received badge  Notable Question (source)
2019-04-04 11:23:25 -0500 received badge  Notable Question (source)
2018-07-04 07:55:29 -0500 received badge  Popular Question (source)
2018-05-18 08:44:55 -0500 received badge  Popular Question (source)
2017-04-08 08:36:45 -0500 commented answer Mirror Image on Android Front Camera

the link is not working, please can someone post some code ??

2017-04-08 08:35:16 -0500 asked a question Opencv android camera issue


i have used the opencv camera simple !! it work without any error but i get a strange behaviour !! i want to get the portrait view but it seems that i get a mirror effect when i get the rgba Mat from the input frame!! please any suggestion to avoid this problem!!. Thank you


2017-03-20 08:16:21 -0500 commented question Opencv Face Detection Assign id for each face

please can you provide an example in python?? it will be very helpfullll!! thank you

2017-03-19 13:59:38 -0500 asked a question Opencv Face Detection Assign id for each face


I'm using Opencv for face detection from video stream but my problem is how to assign an id for each detected face? for example if in the current frame i have detected 3 faces so i have 3 unique id for each faces, now in the next frame if i have 4 detected faces then i need an other id to assign it to the new face!!!

how i can assign a unique id for each faces?

also how i can preserve the same id for each face and assign a new id for the new detected face?

Thank you


2017-03-16 10:12:41 -0500 commented question rtsp stream error video capture

i'm using ubuntu 16 !!! also my pyhton code look like the cide given in the link!!!

2017-03-16 08:33:38 -0500 asked a question rtsp stream error video capture

Hello, i'm using opencv3.1 with python2.7 in ubuntu 16 to stream a video using Videocapture, but i got corrputed frame also i have those message when i run my pyhton script :

Invalid UE golomb code
[h264 @ 0x6087f80] cabac decode of qscale diff failed at 110 37
[h264 @ 0x6087f80] error while decoding MB 110 37, bytestream 1778
[h264 @ 0x4a7aa80] left block unavailable for requested intra4x4 mode -1 at 0 9
[h264 @ 0x4a7aa80] error while decoding MB 0 9, bytestream 8318

what that dos mean!! Thank you Lafi

2017-03-13 13:24:18 -0500 commented question use caffe model for face detection with opencv

no there a prebuild caffe model for face detection here it's the link!!!!!! ( it's have 3 model for face detection, gender estimation and age estimation!!!

2017-03-13 07:13:26 -0500 commented question use caffe model for face detection with opencv

Hello, can use it with the dnn module that come with opencv??

2017-03-12 11:31:37 -0500 asked a question use caffe model for face detection with opencv

Hello , i want to use the a pratrained caffe model for face detection with opencv !!! i know there is dnn for loading caffe model, but how i can draw a rectangle for each detected face!!! how i can get the output !!! i saw the example in opencv tutorial in how to load a model and do a classification!! but i want to do face detection THank you Lafi

2017-03-03 12:55:23 -0500 asked a question Object Extraction from Background

Hello, i'm working on a project for extracting objets from background : the input i have is an image for the background and a second image for those object in the same background

those 2 images are take with the same camera but not with the same position(the positio of the camera could be a little differente)

i have subtract those two images(background_image - second image) , it didnt' give an accurate result due to :

that i need to align those 2 images first(rotation, translatio, scale..) also there is athe shadow problem !!! How i can fix it?? any solution and suggestion please?

here is a simple images :

background image :

image description

second image with objects :

image description

result image(subtraction ) :

image description

Thank you


2016-12-24 07:58:44 -0500 asked a question why my rectified image is like this

Hello, i have run the stereo calib simple and it have detected 80 pairs with an error equal to 0.5 but it give me a rectified image like this : image description

Please can anyone tell me what is the problem?

2016-12-21 15:19:09 -0500 asked a question Runing stereo match simple

Hello, i have problem runing the opencv stereo_match simple i have type in the terminal the following commande

./stereo_match 0000L.png 0000R.png -i intrinsics.yml -e extrinsics.yml -p cloud.asc

and here is the output : Command-line parameter error: The max disparity (--maxdisparity=<...>) must be a positive integer divisible by 16

Demo stereo matching converting L and R images into disparity and point clouds

Usage: stereo_match <left_image> <right_image> [--algorithm=bm|sgbm|hh|sgbm3way] [--blocksize=<block_size>] [--max-disparity=<max_disparity>] [--scale=scale_factor>] [-i=<intrinsic_filename>] [-e=<extrinsic_filename>] [--no-display] [-o=<disparity_image>] [-p=<point_cloud_file>]

How to choose run it with the correct argument? also how to choose the value for blocksize, -max-disparity , scale Thank you

2016-12-21 09:48:28 -0500 received badge  Editor (source)
2016-12-21 09:41:09 -0500 asked a question Stereo Calibration RMS and epipolar error

Hello, i have run the opencv stereo_calib simple for my images , the program found 8 pairs and show me :

...........8 pairs have been successfully detected. Running stereo calibration ... done with RMS error=39.3507 average epipolar err = 67.3832

i want to ask about error value is that good for reconstrcution or not? if not please how i can reduce the error Thank you

2016-12-21 06:15:17 -0500 commented answer 3d reconstrcution from stereo cam

thank you for your suggestion , please can you help me how to run it , it need those arguments [--algorithm=bm|sgbm|hh|sgbm3way] [--blocksize=<block_size>]\n" "[--max-disparity=<max_disparity>] [--scale=scale_factor>] [-i=<intrinsic_filename>] [-e=<extrinsic_filename>]\n" "[--no-display] [-o=<disparity_image>] [-p=<point_cloud_file>]\n"); i have extrinsic, and intrinsic file but what about the other arguments?

2016-12-20 17:00:52 -0500 commented question Face recognition using HuMoments

The bif deescriptor can be used for face recogontion?? if yes please can you give me an example!!

2016-12-20 16:32:11 -0500 asked a question 3d reconstrcution from stereo cam

Hello, i have calibrated my stereo camera, now i have to build the 3d model but i can't find any example in opencv on howto do that . Please can you tell me first is opencv support to build3d and display the 3d model?? if yes can you give me an example , i use opencv 3. Thank you

2016-12-18 20:40:24 -0500 commented answer Face recognition Opencv confidence problem

Thank you, you save may day,

2016-12-18 20:39:57 -0500 received badge  Scholar (source)
2016-12-18 19:58:26 -0500 commented question Face recognition using HuMoments

okay, thank you @LBerger, also i want to know , i'm using face recognition provided by opencv but it give me a negative and a large value confidence , i dont understand why? i have tested the simple and followed it!!

2016-12-18 18:29:58 -0500 asked a question Face recognition Opencv confidence problem

i'm working on face recognition Project and i have followed the tutorial in the opencv website and i have use the same dataset , but when i test my program i have strange result (the confidence value) it gives me a large value((confidence = 621034879.) also it give me negative confidence when testing a sample from the same dataset . why the Confidence have such large value and have a negative value??? here is my code : `

include "opencv2/core/core.hpp"

#include "opencv2/contrib/contrib.hpp"
    #include "opencv2/highgui/highgui.hpp"
    #include <iostream>
#include <fstream>
#include <sstream>
using namespace cv;
using namespace std;
static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
std::ifstream file(filename.c_str(), ifstream::in);
if (!file) {
    string error_message = "No valid input file was given, please check the given filename.";
    CV_Error(CV_StsBadArg, error_message);
string line, path, classlabel;
while (getline(file, line)) {
    stringstream liness(line);
    getline(liness, path, separator);
    getline(liness, classlabel);
    if (!path.empty() && !classlabel.empty()) {
        images.push_back(imread(path, 0));

int main(int argc, const char *argv[]) {
// Check for valid command line arguments, print usage
// if no arguments were given.

// Get the path to your CSV.
string fn_csv = "C:/Users/ASUS/Documents/Visual Studio 2013/Projects/Car_Detection/a.txt";
// These vectors hold the images and corresponding labels.
vector<Mat> images;
vector<int> labels;
// Read in the data. This can fail if no valid
// input filename is given.
try {
    read_csv(fn_csv, images, labels);
catch (cv::Exception& e) {
    cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
    // nothing more we can do
// Quit if there are not enough images for this demo.
if (images.size() <= 1) {
    string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
    CV_Error(CV_StsError, error_message);
// Get the height from the first image. We'll need this
// later in code to reshape the images to their original
// size:
int height = images[0].rows;

Mat testSample = images[images.size() - 1];
int testLabel = labels[labels.size() - 10];


Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
model->train(images, labels);
// The following line predicts the label of a given
// test image:
int predictedLabel = model->predict(testSample);

double confidence = 0.0;
model->predict(testSample, predictedLabel, confidence);
string result_message = format("Label = %d / confidence = %d.", predictedLabel, confidence);
cout << result_message << endl;

return 0;
2016-12-18 12:59:41 -0500 asked a question Face recognition using HuMoments

Hello, i'm asking if i can use HuMoment for face recongition , i know there''s an api for face recogntion but i want to know about huMoments. Thanks in advance. Lafi

2016-07-04 18:11:06 -0500 commented question Leg Detection

okay i want to make an app similar to this so that's why i'm asking for leg detection

2016-07-03 23:06:32 -0500 asked a question Leg Detection

Hi i want to detect Human Leg.

what is the best method for detecting Human Leg.

Thank you

2016-07-02 16:12:30 -0500 commented question track a ball moving in hight speed

Yes i have checked the docupentation and don't find excellent solution, please could give an example

2016-07-01 22:35:33 -0500 received badge  Supporter (source)
2016-07-01 18:20:18 -0500 commented question OpenCV3 Assertion failed on accumulateWeighted

how i can correct it since i have to initialize the accumulator ??

2016-06-30 23:16:39 -0500 asked a question OpenCV3 Assertion failed on accumulateWeighted

I try to make average background but something wrong because it way to crash app


include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;

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

VideoCapture video(0);

cv::Mat Frame,Gray, Avg;

Avg = Mat::zeros(Frame.size(),CV_8UC1);

    video >> Frame;
    int c = Avg.channels();
    std::cout << c << std::endl;
    std::cout << GetMatType(Gray) << std::endl;


return 0;

} `

This is the crash logs :::

OpenCV Error: Assertion failed (_src.sameSize(_dst) && dcn == scn) in accumulateWeighted, file /home/lafi/Documents/opencv-master/modules/imgproc/src/accum.cpp, line 1201
terminate called after throwing an instance of 'cv::Exception'

what():  /home/lafi/Documents/opencv-master/modules/imgproc/src/accum.cpp:1201: error: (-215) _src.sameSize(_dst) && dcn == scn in function accumulateWeighted
2016-06-30 18:59:24 -0500 asked a question I want to detect a fast moving ball in a video using opencv

I want to detect a fast moving ball in a video; I have tried using background subtraction. I can see the ball motion but I can't detect it as I have some other object moving (the spinning part on the middle) and they are so close!!

How I can ignore those objects, and focus just in the ball while moving.

here is the original video for the moving ball

And a screen-shot for the output video after background subtraction


Thank you

2016-06-30 18:52:03 -0500 received badge  Enthusiast
2016-06-25 23:49:57 -0500 commented question track a ball moving in hight speed

Hi, using background subtraction i'm able to extract the ball motion then i can track it, but the problem is i have other motion from the moving background !! any idea to remove it?? here is a link for a frame using background subtraction , the ball motion and the spinning part in the middle please how i can ignore it??

2016-06-23 22:29:26 -0500 commented question track a ball moving in hight speed

yes the camera is fixed, okay, can the bakcground subtraction give goos result while the ball is moving ? and please how i can ignore the spinning part in the middle as it's moving? and as for the n first frame the ball is in the middle!!

2016-06-23 20:51:37 -0500 commented question track a ball moving in hight speed

the problem is that i need to detect it when it's moving, i have tried template matching but didn't get the result i need !! is there any other solution for this problem? can i use descriptor ? if yes how ?

2016-06-23 19:36:05 -0500 commented question track a ball moving in hight speed
2016-06-23 11:28:40 -0500 commented question track a ball moving in hight speed

it didn't give good result since the ball have high velocity

2016-06-22 23:49:35 -0500 asked a question track a ball moving in hight speed

Hi, i want to track a ball moving in hight speed what could be the best method to track, it's a roulette play ball.