Go to Post Good tooling doesn't cost money, it makes money (and prevents doctor visits). - travis [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
  #1   Spotlight this post!  
Unread 10-01-2014, 19:34
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Using the AXIS camera (M1011) with OpenCV

So, I am using cv::CvCapture to get video. This code works with my internal webcam (cvCaptureFromCAM(0);. However, when I switch to reading from the net-cam (AXIS M1011), my app keeps crashing and OpenCV says that it can't find "../../modules/highgui/src/cap_ffmpeg_impl.hpp(545)"

What am I doing wring and why is it triggering?

the code is below.

PHP Code:
//-----------------------------------------------------------------------------------------------------------
//face-tracking by Dev, 1.0
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <math.h>
#include <string>
#include <sstream>
#include <vector>
#include <WinSock.h>

using namespace std;                                                            //So I don't have to use std:: --don't worry. it's nothing big.
using namespace cv;                                                                //so I don't have to use cv::  --same here :D. Just saves time

void processDisplayMat processedMat unprocessed );                            //Subroutine declaration, processDisplay
//String camIP = "xxx";                                                            //Put your Camera MJPEG stream IP here
int capMode 1;                                                                //capture mode: 1 for internal; 2 for AXIS M1011; 3 for AXIS M1014;
int FaceCount 0;                                                                //variable for the nimber of faces detected
int capFailures 0;                                                            //Failure count in camera frame fetch. CURRENTLY UNUSED
const int maxCapFailures 10;                                                    //Max Failure count in cam frame fetch before exiting, with error code, -1. CURRENTLY UNUSED

CascadeClassifier face;                                                            //dscribes what a face looks like
CascadeClassifier eyes;                                                            //describes what eyes look like

int mainint argc, const char** argv ) {                                        //main function
    
CvCapturecapture;                                                            //creates struct, "capture".*************************************************
    //capture.set( capture, CV_CAP_PROP_FRAME_WIDTH, 640 );                        //Sets the capture size width to 640px. Currently deactivated
    //capture.set( capture, CV_CAP_PROP_FRAME_HEIGHT, 480 );                    //Sets the capture size height to 480px. Currently deactivated
    //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);                //Sets the capture size width to 640px. deactivated
    //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);                //Sets the capture size height to 480px. deactivated
    
CvCapturecapture2;                                                        //Creates struct, "capture2"
    
Mat unprocessed;                                                            //unprocessed image
    
Mat processed;                                                                //processed image
    
if( face.load"D:\\SSDWIN7PRGFILES\\opencv\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt.xml" ) ) {            //loads one face cascade
        
if( eyes.load"D:\\SSDWIN7PRGFILES\\opencv\\opencv\\sources\\data\\haarcascade\\haarcascade_eye_tree_eyeglasses.xml" ) )  {                    //loads another face cascade
            
cout << "I was able to load the cascades!" << endl;                    //message
        
} else {                                                                //if not loaded second cascade
            
cout << "Failed to load cascades!\n\n\tOptions:\n\t[ESC] to exit\n\tAny other key to try again";                            //message|error analysis
            
if( waitKey(0) == 27 ) {                                            //waits and updates screen. Also detects keyboard commands
                
return -1;                                                        //returns error code, -1;
            
} else {                                                            //if no key was pressed
                
cout << "Trying Again" << endl;                                    //message|info
            
}                                                                    //close brace
        
}                                                                        //close brace
    
} else {                                                                    //message|error
        
cout << "Failed to load cascades!\n\n\tOptions:\n\t[ESC] to exit\n\tAny other key to try again";                                //message|error action
        
if( waitKey(0) == 27 ) {                                                //wait for [ESC] key
            
return -1;                                                            //exit program with error code, -1
        
} else {                                                                //if no [ESC] key, try to configure cascade again
            
cout << "Trying Again" << endl;                                        //message|info
        
}                                                                        //closing brace
    
}                                                                            //closing brace
    
if( capMode == ) {                                                        //check capture mode, descibed above at variable creation
        
capture cvCaptureFromCAM(0);                                            //set camera of "capture" to cam 0
        
capture2 cvCaptureFromCAM(0);                                        //set camera of "capture2" to cam 0
        //capture2 = cvCaptureFromFile("root:paradise@http://10.11.65.10/jpg/image.jpg?size=3");
        
cout << "I'm going to use the internal camera." << endl;                //message|info
    
} else if( capMode == || capMode == ) {                                    //if different cam mode
        //if( camIP.empty() ) {
        //    cout << "IP not set" << endl;
        //} else {
            
capture cvCaptureFromFile("http://10.11.65.10/axis-cgi/mjpeg/video.cgi?camera=1&resolution=640x480");    //hook to network camera
            
capture2 cvCaptureFromFile("http://10.11.65.10/axis-cgi/mjpeg/video.cgi?camera=1&resolution=640x480");    //hook to network camera
            
cout << "MJPEG stream opened" << endl;                                //message|info
        //}
    
}                                                                            //closing brace

    
if( capture ) {                                                                //check to see if capture was true
        
bool msgq 0;                                                            //to prevent message from repeating
        
while( true ) {                                                            //infinite loop
            
unprocessed cvQueryFramecapture );                            //gather image from cam
            
processed cvQueryFramecapture2 );                                //gather image from cam
            //unprocessed = imread("http://10.11.65.10/jpg/image.jpg?size=3");
            //processed = imread("http://10.11.65.10/jpg/image.jpg?size=3");
            
if( !unprocessed.empty() ) {                                        //check to see if camera is outputing footage
                
if( msgq false ) {                                            //make sure message doesn't repeat
                    
cout << "The Webcam Stream has been opened properly!" << endl;                                                    //message|info
                
}                                                                //closing brace
                
processDisplayprocessedunprocessed );                        //run the processing algorithm
                
msgq true;                                                    //set flag to true
            
} else {                                                            //if cam frame was not present
                
cout << "Could not access the camera. Please maake sure nothing is already using the camera. Retrying" << endl;        //message|error
            
}                                                                    //closing brace
            
int c waitKey(1);                                                    //+check to see if the [ESC] key was pressed
            
if( (char)== 'c' ) {                                                //|
                
break;                                                            //|
            
}                                                                    //+closing brace
        
}                                                                        //closing brace
    
}                                                                            //closing brace
    
waitKey(0);
    return 
0;                                                                    //closes program with safe exit code, 0!
    
}                                                                            //closing brace

void processDisplayMat processedMat unprocessed ) {                            //processing algorithm
    
Mat gray;                                                                    //New matrix for the grayscale image
    
vector<Rectfaces;                                                            //new vector to store the faces, where they are and how big they are
    
vector<Recteye;                                                            //New vector to store info about the eyes

    
cvtColorprocessedgrayCV_BGR2GRAY );                                    //converts color image to grayscale
    
equalizeHistgraygray );                                                    //cleans the image

    
face.detectMultiScalegrayfaces1.120|CV_HAAR_SCALE_IMAGESize(30,30) );                                    //detects faces using a cascade
    
eyes.detectMultiScalegrayeye1.120|CV_HAAR_SCALE_IMAGESize(30,30) );                                        //dtects eyes using a cascade

    
Point2i p1(0,240);                                                            //point
    
Point2i p2(640,240);                                                        //point
    
Point2i p3(3200);                                                            //point
    
Point2i p4(320480);                                                        //point
    
Point2i p5(00);                                                            //point
    
Point2i p6(640480);                                                        //point
    
Point2i p7(6400);                                                            //point
    
Point2i p8(0480);                                                            //point
    
lineprocessedp1p2Scalar(11337105), 1CV_AA);                    //line
    
lineprocessedp3p4Scalar(11337105), 1CV_AA);                    //line
    
lineprocessedp5p6Scalar(1.0), 1CV_AA);                            //line
    
lineprocessedp7p8Scalar(1.0), 1CV_AA);                            //line
    
    
cout << "I detected " << faces.size() << " face(s)! \n\t";                    //message|output

    
int count 0;                                                                //counter integer

    
for( count 0count faces.size(); count++ ) {                            
        
//Point center( faces[i].x + faces[i].width * 0.5, faces[i].y + faces[i].width * 0.5 );
        
Point centerfaces[count].faces[count].width 0.5faces[count].faces[count].height 0.5 );
        
ellipseprocessedcenterSizefaces[count].width 0.5faces[count].height 0.5 ), 00360Scalar(22127255 ), 280);
        
cout << "Face Number:" << count+<< ";\tPosition: X: " << faces[count].<< " Y: " << faces[count].<< endl;
        
Point2i p9(320240);
        
Point2i p10(faces[count].faces[count].width*0.5faces[count].faces[count].height*0.5);
        
lineprocessedp9p10Scalar(33191152), 1CV_AA );
    }

    
count 0;

    for( 
count 0count eye.size(); count++ ) {
        
Point centerEyeeye[count].eye[count].width 0.5eye[count].eye[count].height 0.5 );
        
ellipseprocessedcenterEyeSizeeye[count].width 0.5eye[count].height 0.5 ), 00360Scalar5764192 ), 28);
    }

    
imshow"Processed Image"processed );
    
imshow"GrayScale Image (Processing)"gray );
    
imshow"Original Image"unprocessed );
    
FaceCount FaceCount faces.size();
    
cout << endl << "I have detected " << FaceCount << "Face(s) so far!" << endl;
}

//-------------------------------------------------------------------------------------------------------------- 
Thank goodness that CD shrinks the CODE box! Otherwise this post would be a couple pages long

Thanks!

Last edited by yash101 : 10-01-2014 at 21:46.
  #2   Spotlight this post!  
Unread 10-01-2014, 20:34
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Using the AXIS camera (M1011) with OpenCV

My guess is that you either didn't compile OpenCV with ffmpeg support, or perhaps it can't find the ffmpeg library. Check the OpenCV file to see what the code is doing at that point. You could post the entirety of the error message and context (like where it is being issued) too.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #3   Spotlight this post!  
Unread 10-01-2014, 21:40
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Using the AXIS camera (M1011) with OpenCV

Quote:
Originally Posted by virtuald View Post
My guess is that you either didn't compile OpenCV with ffmpeg support, or perhaps it can't find the ffmpeg library. Check the OpenCV file to see what the code is doing at that point. You could post the entirety of the error message and context (like where it is being issued) too.
That is the entire error message. It was during the runtime. I have a screen recording of it. If you want, I can drop it into my CDN so you can watch it.

The funny thing is that the code compiles correctly. The code also works perfectly when I use cvCaptureFromCAM(0); instead of reading it from a file, with a URL.

If you change, int capMode to 2, modify the IP URLs on:
PHP Code:
capture cvCaptureFromFile("http://10.11.65.10/axis-cgi/mjpeg/video.cgi?camera=1&resolution=640x480");    //hook to network camera

capture2 cvCaptureFromFile("http://10.11.65.10/axis-cgi/mjpeg/video.cgi?camera=1&resolution=640x480");    //hook to network camera 
,
the AXIS camera on the bot will do cascade-based vision tracking.

How do I fix this issue about FFMPEG not being correctly detected? I spent over two hours trying to modify code, find a better stream URL, etc., but couldn't find out anything, so now it is time that I ask the experts


Also, what is the URL that I should use to gather the MJPEG stream to the AXIS (I think it is M1011)?

Also, should I use another drop-in command like capture = cvCaptureFromFIle("URL"); ?

Thanks for your time and effort and good luck this year
  #4   Spotlight this post!  
Unread 10-01-2014, 23:13
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Using the AXIS camera (M1011) with OpenCV

Are you sure it didn't say "Could not find codec parameters"? There's a similar looking message on line 556 of the file in their github repo. Line 545 says 'error opening file', which implies that it cannot open the stream you've passed to it.

The uri that worked for me last year was 'http://%s/mjpg/video.mjpg'.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #5   Spotlight this post!  
Unread 11-01-2014, 00:23
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Using the AXIS camera (M1011) with OpenCV

I had a feeling that that was a problem. I'll try that URL. If that doesn't work, where would I look to find the camera stream address? Also, how do I authenticate to the camera?
  #6   Spotlight this post!  
Unread 11-01-2014, 01:46
virtuald's Avatar
virtuald virtuald is offline
RobotPy Guy
AKA: Dustin Spicuzza
FRC #1418 (), FRC #1973, FRC #4796, FRC #6367 ()
Team Role: Mentor
 
Join Date: Dec 2008
Rookie Year: 2003
Location: Boston, MA
Posts: 1,058
virtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant futurevirtuald has a brilliant future
Re: Using the AXIS camera (M1011) with OpenCV

I'd recommend disabling the authentication on the camera, then you don't have to deal with it. I'm pretty sure there's a way to enable anonymous stream viewing somewhere.
__________________
Maintainer of RobotPy - Python for FRC
Creator of pyfrc (Robot Simulator + utilities for Python) and pynetworktables/pynetworktables2js (NetworkTables for Python & Javascript)

2017 Season: Teams #1973, #4796, #6369
Team #1418 (remote mentor): Newton Quarterfinalists, 2016 Chesapeake District Champion, 2x Innovation in Control award, 2x district event winner
Team #1418: 2015 DC Regional Innovation In Control Award, #2 seed; 2014 VA Industrial Design Award; 2014 Finalists in DC & VA
Team #2423: 2012 & 2013 Boston Regional Innovation in Control Award


Resources: FIRSTWiki (relaunched!) | My Software Stuff
  #7   Spotlight this post!  
Unread 11-01-2014, 07:09
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,751
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Using the AXIS camera (M1011) with OpenCV

If you are only acquiring images, you can turn on anonymous viewing on the camera settings and the URL will work without authentication. If you want to set other parameters, you can mimic what the web page does. And by that I mean to capture using wireshark and spoof it. It is what WPILib does. I can give the codes for FRC/FRC.

Greg McKaskle
  #8   Spotlight this post!  
Unread 11-01-2014, 07:59
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Using the AXIS camera (M1011) with OpenCV

I'll have to look into anonymous viewing. If anyone knows how to do it, letting me know would be great!

Thanks
  #9   Spotlight this post!  
Unread 11-01-2014, 09:44
RufflesRidge RufflesRidge is offline
Registered User
no team
 
Join Date: Jan 2012
Location: USA
Posts: 989
RufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant futureRufflesRidge has a brilliant future
Re: Using the AXIS camera (M1011) with OpenCV

Quote:
Originally Posted by yash101 View Post
I'll have to look into anonymous viewing. If anyone knows how to do it, letting me know would be great!

Thanks
http://wpilib.screenstepslive.com/s/...an-axis-camera

The image under Configure Users
  #10   Spotlight this post!  
Unread 11-01-2014, 12:52
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Using the AXIS camera (M1011) with OpenCV

I got the anonymous viewing set up, and not the steaming works like a charm. I think I get less lag than my laptop's internal camera!

Here's my current code. I am currently working on it, but it displays three windows, grayscale, and two instances of the original image, to be processed.

PHP Code:
//-----------------------------------------------------------------------------------------------------------
//face-tracking by Dev, 1.0
//Copyright 2014 Devyash Lodha
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <math.h>
#include <string>
#include <sstream>
#include <vector>
#include <WinSock.h>

using namespace std;                                                            //So I don't have to use std:: --don't worry. it's nothing big.
using namespace cv;                                                                //so I don't have to use cv::  --same here :D. Just saves time

void processDisplayMat processedMat unprocessed );                            //Subroutine declaration, processDisplay
//String camIP = "xxx";                                                            //Put your Camera MJPEG stream IP here
int capMode 1;                                                                //capture mode: 1 for internal; 2 for AXIS M1011; 3 for AXIS M1014;
int FaceCount 0;                                                                //variable for the nimber of faces detected
int capFailures 0;                                                            //Failure count in camera frame fetch. CURRENTLY UNUSED
const int maxCapFailures 10;                                                    //Max Failure count in cam frame fetch before exiting, with error code, -1. CURRENTLY UNUSED

CascadeClassifier face;                                                            //dscribes what a face looks like
CascadeClassifier eyes;                                                            //describes what eyes look like

int mainint argc, const char** argv ) {                                        //main function
    
CvCapturecapture;                                                            //creates struct, "capture".*************************************************
    //capture.set( capture, CV_CAP_PROP_FRAME_WIDTH, 640 );                        //Sets the capture size width to 640px. Currently deactivated
    //capture.set( capture, CV_CAP_PROP_FRAME_HEIGHT, 480 );                    //Sets the capture size height to 480px. Currently deactivated
    //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_WIDTH, 640);                //Sets the capture size width to 640px. deactivated
    //cvSetCaptureProperty(capture, CV_CAP_PROP_FRAME_HEIGHT, 480);                //Sets the capture size height to 480px. deactivated
    
CvCapturecapture2;                                                        //Creates struct, "capture2"
    
Mat unprocessed;                                                            //unprocessed image
    
Mat processed;                                                                //processed image
    
if( face.load"D:\\SSDWIN7PRGFILES\\opencv\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt.xml" ) ) {            //loads one face cascade
        
if( eyes.load"D:\\SSDWIN7PRGFILES\\opencv\\opencv\\sources\\data\\haarcascade\\haarcascade_eye_tree_eyeglasses.xml" ) )  {                    //loads another face cascade
            
cout << "I was able to load the cascades!" << endl;                    //message
        
} else {                                                                //if not loaded second cascade
            
cout << "Failed to load cascades!\n\n\tOptions:\n\t[ESC] to exit\n\tAny other key to try again";                            //message|error analysis
            
if( waitKey(0) == 27 ) {                                            //waits and updates screen. Also detects keyboard commands
                
return -1;                                                        //returns error code, -1;
            
} else {                                                            //if no key was pressed
                
cout << "Trying Again" << endl;                                    //message|info
            
}                                                                    //close brace
        
}                                                                        //close brace
    
} else {                                                                    //message|error
        
cout << "Failed to load cascades!\n\n\tOptions:\n\t[ESC] to exit\n\tAny other key to try again";                                //message|error action
        
if( waitKey(0) == 27 ) {                                                //wait for [ESC] key
            
return -1;                                                            //exit program with error code, -1
        
} else {                                                                //if no [ESC] key, try to configure cascade again
            
cout << "Trying Again" << endl;                                        //message|info
        
}                                                                        //closing brace
    
}                                                                            //closing brace
    
if( capMode == ) {                                                        //check capture mode, descibed above at variable creation
        //capture = cvCaptureFromCAM(0);                                            //set camera of "capture" to cam 0
        
capture cvCaptureFromFile("http://10.11.65.10/mjpg/video.mjpg");
        
//capture2 = cvCaptureFromCAM(0);                                        //set camera of "capture2" to cam 0
        //root:paradise
        
capture2 cvCaptureFromFile("http://10.11.65.10/mjpg/video.mjpg");
        
cout << "I'm going to use the internal camera." << endl;                //message|info
    
} else if( capMode == || capMode == ) {                                    //if different cam mode
        //if( camIP.empty() ) {
        //    cout << "IP not set" << endl;
        //} else {
            
capture cvCaptureFromFile("http://10.11.65.10/axis-cgi/mjpeg/video.cgi?camera=1&resolution=640x480");    //hook to network camera
            
capture2 cvCaptureFromFile("http://10.11.65.10/axis-cgi/mjpeg/video.cgi?camera=1&resolution=640x480");    //hook to network camera
            
cout << "MJPEG stream opened" << endl;                                //message|info
        //}
    
}                                                                            //closing brace

    
if( capture ) {                                                                //check to see if capture was true
        
bool msgq 0;                                                            //to prevent message from repeating
        
while( true ) {                                                            //infinite loop
            
unprocessed cvQueryFramecapture );                            //gather image from cam
            
processed cvQueryFramecapture2 );                                //gather image from cam
            //unprocessed = imread("http://10.11.65.10/jpg/image.jpg?size=3");
            //processed = imread("http://10.11.65.10/jpg/image.jpg?size=3");
            
if( !unprocessed.empty() ) {                                        //check to see if camera is outputing footage
                
if( msgq false ) {                                            //make sure message doesn't repeat
                    
cout << "The Webcam Stream has been opened properly!" << endl;                                                    //message|info
                
}                                                                //closing brace
                
processDisplayprocessedunprocessed );                        //run the processing algorithm
                
msgq true;                                                    //set flag to true
            
} else {                                                            //if cam frame was not present
                
cout << "Could not access the camera. Please maake sure nothing is already using the camera. Retrying" << endl;        //message|error
            
}                                                                    //closing brace
            
int c waitKey(1);                                                    //+check to see if the [ESC] key was pressed
            
if( (char)== 'c' ) {                                                //|
                
break;                                                            //|
            
}                                                                    //+closing brace
        
}                                                                        //closing brace
    
}                                                                            //closing brace
    
waitKey(0);
    return 
0;                                                                    //closes program with safe exit code, 0!
    
}                                                                            //closing brace

void processDisplayMat processedMat unprocessed ) {                            //processing algorithm
    
Mat gray;                                                                    //New matrix for the grayscale image
    
Mat threshold;                                                                //New matrix for the thresholded image

    
cvtColorprocessedgrayCV_BGR2GRAY );                                    //converts color image to grayscale
    
equalizeHistgraygray );                                                    //cleans the image

    
imshow"Processed Image"processed );
    
imshow"GrayScale Image (Processing)"gray );
    
imshow"Original Image"unprocessed );
}

//--------------------------------------------------------------------------------------------------------------- 

Last edited by yash101 : 11-01-2014 at 12:54.
  #11   Spotlight this post!  
Unread 11-01-2014, 20:45
yash101 yash101 is offline
Curiosity | I have too much of it!
AKA: null
no team
 
Join Date: Oct 2012
Rookie Year: 2012
Location: devnull
Posts: 1,191
yash101 is an unknown quantity at this point
Re: Using the AXIS camera (M1011) with OpenCV

So now that I have a working stream address, and I am able to do basic processing, How do I separate the goals from everything else? The camera is saturated from the reflected green, so I just need to create an algorithm to separate that from the rest of the stuff. Whee should I start? If anyone has some sample code, that would be appreciate, even if you want to PM me to not let anyone else see!

So currently, I am able to process the colors as CV_BRG2HSV and CV_BGR2GRAY. I am also able to imshow the images throughout the entire process!


----Different topic----
So many of us have claimed how wifi interference can cause a ton of lag in robot communication. To see what would happen, I will try this wacky test:

step 1: Ask everyone to turn off their phones and electronics, and isolate the appliances from as much interferance as possible. I'll try to get a rough estimate of the lag (with no bandwidth restrictions enabled (similar to what you'd get if you were doing onboard processing without any network usage (except feedback).

step 2: Ask everyone to turn on their phones, bluetooth, wifi and any other communications possible. I will also be running aircrack-ng on another computer to just send a ton of packets and try to cause as much disturbance as possible. This will run on the same channel as the robot communications. To manage consistency, no bandwidth restrictions would be enabled, again. I'd then check the lag times and see whether vision will be a possibility. I'll most likely publish this data to show what my experimentation came up with.

step 3: analyze and publish the results. Also, choose the pathway you wish to follow, there-on. It could be to go by onboard or offboard processing!


---Tell me if I should add another step to this. I will try to use BackTrack Linux off a pendrive iso image.

Also, this is quite overkill. You'll probably never get as much interference competition, so this will be more-of-a worst-case scenario!

What do you guys think?
  #12   Spotlight this post!  
Unread 12-01-2014, 00:06
XaoS XaoS is offline
Registered User
FRC #4590
 
Join Date: Jan 2014
Location: Israel
Posts: 3
XaoS is an unknown quantity at this point
You might wanna take a look at thresholding techniques, specifically OpenCV's inRange() function.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 03:11.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi