mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
adding waitChar key to remove issues with waitKey char comparisons
done for cpp/markdown/python filters on search function also added wrapped functionality for Python then checked all python samples, removed ord() and 0xFF anding - no longer needed -
This commit is contained in:
parent
01d2e7af71
commit
a5f19f7dd6
@ -1270,7 +1270,7 @@ void cvCreateTrainingSamples( const char* filename,
|
|||||||
if( showsamples )
|
if( showsamples )
|
||||||
{
|
{
|
||||||
cvShowImage( "Sample", &sample );
|
cvShowImage( "Sample", &sample );
|
||||||
if( cvWaitKey( 0 ) == 27 )
|
if( (cvWaitKey( 0 ) & 0xFF) == 27 )
|
||||||
{
|
{
|
||||||
showsamples = 0;
|
showsamples = 0;
|
||||||
}
|
}
|
||||||
@ -1402,7 +1402,7 @@ void cvCreateTestSamples( const char* infoname,
|
|||||||
if( showsamples )
|
if( showsamples )
|
||||||
{
|
{
|
||||||
cvShowImage( "Image", &cvbgreader->src );
|
cvShowImage( "Image", &cvbgreader->src );
|
||||||
if( cvWaitKey( 0 ) == 27 )
|
if( (cvWaitKey( 0 ) & 0xFF) == 27 )
|
||||||
{
|
{
|
||||||
showsamples = 0;
|
showsamples = 0;
|
||||||
}
|
}
|
||||||
@ -1525,7 +1525,7 @@ int cvCreateTrainingSamplesFromInfo( const char* infoname, const char* vecfilena
|
|||||||
if( showsamples )
|
if( showsamples )
|
||||||
{
|
{
|
||||||
cvShowImage( "Sample", sample );
|
cvShowImage( "Sample", sample );
|
||||||
if( cvWaitKey( 0 ) == 27 )
|
if( (cvWaitKey( 0 ) & 0xFF) == 27 )
|
||||||
{
|
{
|
||||||
showsamples = 0;
|
showsamples = 0;
|
||||||
}
|
}
|
||||||
@ -1672,7 +1672,7 @@ void cvShowVecSamples( const char* filename, int winwidth, int winheight,
|
|||||||
icvGetTraininDataFromVec( sample, &file );
|
icvGetTraininDataFromVec( sample, &file );
|
||||||
if( scale != 1.0 ) cvResize( sample, scaled_sample, CV_INTER_LINEAR);
|
if( scale != 1.0 ) cvResize( sample, scaled_sample, CV_INTER_LINEAR);
|
||||||
cvShowImage( "Sample", scaled_sample );
|
cvShowImage( "Sample", scaled_sample );
|
||||||
if( cvWaitKey( 0 ) == 27 ) break;
|
if( (cvWaitKey( 0 ) & 0xFF) == 27 ) break;
|
||||||
}
|
}
|
||||||
if( scaled_sample && scaled_sample != sample ) cvReleaseMat( &scaled_sample );
|
if( scaled_sample && scaled_sample != sample ) cvReleaseMat( &scaled_sample );
|
||||||
cvReleaseMat( &sample );
|
cvReleaseMat( &sample );
|
||||||
@ -1680,4 +1680,4 @@ void cvShowVecSamples( const char* filename, int winwidth, int winheight,
|
|||||||
}
|
}
|
||||||
fclose( file.input );
|
fclose( file.input );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ PipelineExitStatus CalibPipeline::start(std::vector<cv::Ptr<FrameProcessor> > pr
|
|||||||
for (std::vector<cv::Ptr<FrameProcessor> >::iterator it = processors.begin(); it != processors.end(); ++it)
|
for (std::vector<cv::Ptr<FrameProcessor> >::iterator it = processors.begin(); it != processors.end(); ++it)
|
||||||
processedFrame = (*it)->processFrame(processedFrame);
|
processedFrame = (*it)->processFrame(processedFrame);
|
||||||
cv::imshow(mainWindowName, processedFrame);
|
cv::imshow(mainWindowName, processedFrame);
|
||||||
int key = cv::waitKey(CAP_DELAY);
|
char key = cv::waitChar(CAP_DELAY);
|
||||||
|
|
||||||
if(key == 27) // esc
|
if(key == 27) // esc
|
||||||
return Finished;
|
return Finished;
|
||||||
|
@ -85,9 +85,9 @@ Explanation
|
|||||||
while( true )
|
while( true )
|
||||||
{
|
{
|
||||||
/// Each 1 sec. Press ESC to exit the program
|
/// Each 1 sec. Press ESC to exit the program
|
||||||
int c = waitKey( 1000 );
|
char c = waitChar( 1000 );
|
||||||
|
|
||||||
if( (char)c == 27 )
|
if( c == 27 )
|
||||||
{ break; }
|
{ break; }
|
||||||
|
|
||||||
/// Update map_x & map_y. Then apply remap
|
/// Update map_x & map_y. Then apply remap
|
||||||
|
@ -93,6 +93,7 @@ Let's check the general structure of the program:
|
|||||||
|
|
||||||
- Perform an infinite loop waiting for user input.
|
- Perform an infinite loop waiting for user input.
|
||||||
@snippet cpp/tutorial_code/ImgProc/Pyramids.cpp infinite_loop
|
@snippet cpp/tutorial_code/ImgProc/Pyramids.cpp infinite_loop
|
||||||
|
|
||||||
Our program exits if the user presses *ESC*. Besides, it has two options:
|
Our program exits if the user presses *ESC*. Besides, it has two options:
|
||||||
|
|
||||||
- **Perform upsampling (after pressing 'u')**
|
- **Perform upsampling (after pressing 'u')**
|
||||||
|
@ -109,7 +109,7 @@ It provides easy interface to:
|
|||||||
|
|
||||||
Mat img2,img3;
|
Mat img2,img3;
|
||||||
|
|
||||||
while( waitKey(33) != 27 )
|
while( waitChar(33) != 27 )
|
||||||
{
|
{
|
||||||
img1.convertTo(img2,-1,1,value);
|
img1.convertTo(img2,-1,1,value);
|
||||||
video >> img3;
|
video >> img3;
|
||||||
@ -338,6 +338,26 @@ If there are several HighGUI windows, any of them can be active.
|
|||||||
*/
|
*/
|
||||||
CV_EXPORTS_W int waitKey(int delay = 0);
|
CV_EXPORTS_W int waitKey(int delay = 0);
|
||||||
|
|
||||||
|
/** @brief Waits for a pressed key and returns the corresponding char value (ASCII) assigned.
|
||||||
|
|
||||||
|
The function waitChar waits for a key event infinitely (when \f$\texttt{delay}\leq 0\f$ ) or for delay
|
||||||
|
milliseconds, when it is positive. It returns the ASCII code of the pressed key as a char value. If no key was pressed before
|
||||||
|
the specified time has elapsed, -1 (most systems) or 255 (if char == unsigned char) is returned depending on the system available.
|
||||||
|
|
||||||
|
@note
|
||||||
|
|
||||||
|
There is a minor issue for `char == unsigned char systems`. Return value or timeout could be mixed up with value of valid `'\0xFF'` symbol.
|
||||||
|
However this is an extremely rare usecase, and is thus ignored for the moment.
|
||||||
|
|
||||||
|
@note
|
||||||
|
|
||||||
|
The function only works if there is at least one HighGUI window created and the window is active.
|
||||||
|
If there are several HighGUI windows, any of them can be active.
|
||||||
|
|
||||||
|
@param delay Delay in milliseconds. 0 is the special value that means "forever".
|
||||||
|
*/
|
||||||
|
CV_EXPORTS_W char waitChar(int delay = 0);
|
||||||
|
|
||||||
/** @brief Displays an image in the specified window.
|
/** @brief Displays an image in the specified window.
|
||||||
|
|
||||||
The function imshow displays an image in the specified window. If the window was created with the
|
The function imshow displays an image in the specified window. If the window was created with the
|
||||||
|
@ -198,6 +198,15 @@ int cv::waitKey(int delay)
|
|||||||
return cvWaitKey(delay);
|
return cvWaitKey(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char cv::waitChar(int delay){
|
||||||
|
#if CHAR_MIN==SCHAR_MIN
|
||||||
|
int intKey = cv::waitKey(delay) & 0xFF;
|
||||||
|
return (char)(intKey & 0x80 ? intKey - 0x100 : intKey);
|
||||||
|
#else
|
||||||
|
return (char)(cv::waitKey(delay) & 0xff);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int cv::createTrackbar(const String& trackbarName, const String& winName,
|
int cv::createTrackbar(const String& trackbarName, const String& winName,
|
||||||
int* value, int count, TrackbarCallback callback,
|
int* value, int count, TrackbarCallback callback,
|
||||||
void* userdata)
|
void* userdata)
|
||||||
|
@ -542,6 +542,12 @@ bool pyopencv_to(PyObject* obj, double& value, const char* name)
|
|||||||
return !PyErr_Occurred();
|
return !PyErr_Occurred();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<>
|
||||||
|
PyObject* pyopencv_from(const char& value)
|
||||||
|
{
|
||||||
|
return PyInt_FromLong(value);
|
||||||
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
PyObject* pyopencv_from(const float& value)
|
PyObject* pyopencv_from(const float& value)
|
||||||
{
|
{
|
||||||
|
@ -113,7 +113,7 @@ if __name__ == '__main__':
|
|||||||
img = render.getNextFrame()
|
img = render.getNextFrame()
|
||||||
cv2.imshow('img', img)
|
cv2.imshow('img', img)
|
||||||
|
|
||||||
ch = 0xFF & cv2.waitKey(3)
|
ch = cv2.waitChar(3)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -351,7 +351,7 @@ int main( int argc, char** argv )
|
|||||||
for( k = 0; k < small_canvas.rows; k += 16 )
|
for( k = 0; k < small_canvas.rows; k += 16 )
|
||||||
line(small_canvas, Point(0, k), Point(small_canvas.cols, k), Scalar(0,255,0), 1);
|
line(small_canvas, Point(0, k), Point(small_canvas.cols, k), Scalar(0,255,0), 1);
|
||||||
imshow("rectified", small_canvas);
|
imshow("rectified", small_canvas);
|
||||||
int c = waitKey(0);
|
char c = waitChar(0);
|
||||||
if( c == 27 || c == 'q' || c == 'Q' )
|
if( c == 27 || c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -400,7 +400,7 @@ int main(int argc, char ** argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
imshow(windowOriginal, frame);
|
imshow(windowOriginal, frame);
|
||||||
switch (key = static_cast<char>(waitKey(30)))
|
switch (key = waitChar(30))
|
||||||
{
|
{
|
||||||
case 'k': // focus out
|
case 'k': // focus out
|
||||||
cap.set(CAP_PROP_ZOOM, 100);
|
cap.set(CAP_PROP_ZOOM, 100);
|
||||||
|
@ -95,7 +95,7 @@ int main(int argc, const char** argv)
|
|||||||
if(!bgimg.empty())
|
if(!bgimg.empty())
|
||||||
imshow("mean background image", bgimg );
|
imshow("mean background image", bgimg );
|
||||||
|
|
||||||
char k = (char)waitKey(30);
|
char k = waitChar(30);
|
||||||
if( k == 27 ) break;
|
if( k == 27 ) break;
|
||||||
if( k == ' ' )
|
if( k == ' ' )
|
||||||
{
|
{
|
||||||
|
@ -493,9 +493,9 @@ int main( int argc, char** argv )
|
|||||||
}
|
}
|
||||||
|
|
||||||
imshow("Image View", view);
|
imshow("Image View", view);
|
||||||
int key = 0xff & waitKey(capture.isOpened() ? 50 : 500);
|
char key = waitChar(capture.isOpened() ? 50 : 500);
|
||||||
|
|
||||||
if( (key & 255) == 27 )
|
if( key == 27 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( key == 'u' && mode == CALIBRATED )
|
if( key == 'u' && mode == CALIBRATED )
|
||||||
@ -536,8 +536,8 @@ int main( int argc, char** argv )
|
|||||||
//undistort( view, rview, cameraMatrix, distCoeffs, cameraMatrix );
|
//undistort( view, rview, cameraMatrix, distCoeffs, cameraMatrix );
|
||||||
remap(view, rview, map1, map2, INTER_LINEAR);
|
remap(view, rview, map1, map2, INTER_LINEAR);
|
||||||
imshow("Image View", rview);
|
imshow("Image View", rview);
|
||||||
int c = 0xff & waitKey();
|
char c = waitChar();
|
||||||
if( (c & 255) == 27 || c == 'q' || c == 'Q' )
|
if( c == 27 || c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ int main( int argc, const char** argv )
|
|||||||
imshow( "CamShift Demo", image );
|
imshow( "CamShift Demo", image );
|
||||||
imshow( "Histogram", histimg );
|
imshow( "Histogram", histimg );
|
||||||
|
|
||||||
char c = (char)waitKey(10);
|
char c = waitChar(10);
|
||||||
if( c == 27 )
|
if( c == 27 )
|
||||||
break;
|
break;
|
||||||
switch(c)
|
switch(c)
|
||||||
|
@ -453,7 +453,7 @@ int main()
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
char key = (char) waitKey(0);
|
char key = waitChar(0);
|
||||||
|
|
||||||
if(key == 'd' && flag3 == 0)
|
if(key == 'd' && flag3 == 0)
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,6 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
char key;
|
|
||||||
int i, count = (unsigned)rng%100 + 1;
|
int i, count = (unsigned)rng%100 + 1;
|
||||||
|
|
||||||
vector<Point> points;
|
vector<Point> points;
|
||||||
@ -58,7 +57,7 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
imshow("hull", img);
|
imshow("hull", img);
|
||||||
|
|
||||||
key = (char)waitKey();
|
char key = waitChar();
|
||||||
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
|
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -277,8 +277,8 @@ static void DrawOpenGLMSER(Mat img, Mat result)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
updateWindow("OpenGL");
|
updateWindow("OpenGL");
|
||||||
int key = waitKey(40);
|
char key = waitChar(40);
|
||||||
if ((key & 0xff) == 27)
|
if (key == 27)
|
||||||
break;
|
break;
|
||||||
if (key == 0x20)
|
if (key == 0x20)
|
||||||
rotateEnable = !rotateEnable;
|
rotateEnable = !rotateEnable;
|
||||||
|
@ -133,7 +133,7 @@ int main( int argc, const char** argv )
|
|||||||
// Call to update the view
|
// Call to update the view
|
||||||
onTrackbar(0, 0);
|
onTrackbar(0, 0);
|
||||||
|
|
||||||
int c = waitKey(0) & 255;
|
char c = waitChar(0);
|
||||||
|
|
||||||
if( c == 27 )
|
if( c == 27 )
|
||||||
break;
|
break;
|
||||||
|
@ -72,9 +72,9 @@ int main( int argc, const char** argv )
|
|||||||
}
|
}
|
||||||
if( inputName.empty() || (isdigit(inputName[0]) && inputName.size() == 1) )
|
if( inputName.empty() || (isdigit(inputName[0]) && inputName.size() == 1) )
|
||||||
{
|
{
|
||||||
int c = inputName.empty() ? 0 : inputName[0] - '0';
|
int camera = inputName.empty() ? 0 : inputName[0] - '0';
|
||||||
if(!capture.open(c))
|
if(!capture.open(camera))
|
||||||
cout << "Capture from camera #" << c << " didn't work" << endl;
|
cout << "Capture from camera #" << camera << " didn't work" << endl;
|
||||||
}
|
}
|
||||||
else if( inputName.size() )
|
else if( inputName.size() )
|
||||||
{
|
{
|
||||||
@ -104,7 +104,7 @@ int main( int argc, const char** argv )
|
|||||||
Mat frame1 = frame.clone();
|
Mat frame1 = frame.clone();
|
||||||
detectAndDraw( frame1, cascade, nestedCascade, scale, tryflip );
|
detectAndDraw( frame1, cascade, nestedCascade, scale, tryflip );
|
||||||
|
|
||||||
int c = waitKey(10);
|
char c = waitChar(10);
|
||||||
if( c == 27 || c == 'q' || c == 'Q' )
|
if( c == 27 || c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ int main( int argc, const char** argv )
|
|||||||
char buf[1000+1];
|
char buf[1000+1];
|
||||||
while( fgets( buf, 1000, f ) )
|
while( fgets( buf, 1000, f ) )
|
||||||
{
|
{
|
||||||
int len = (int)strlen(buf), c;
|
int len = (int)strlen(buf);
|
||||||
while( len > 0 && isspace(buf[len-1]) )
|
while( len > 0 && isspace(buf[len-1]) )
|
||||||
len--;
|
len--;
|
||||||
buf[len] = '\0';
|
buf[len] = '\0';
|
||||||
@ -136,7 +136,7 @@ int main( int argc, const char** argv )
|
|||||||
if( !image.empty() )
|
if( !image.empty() )
|
||||||
{
|
{
|
||||||
detectAndDraw( image, cascade, nestedCascade, scale, tryflip );
|
detectAndDraw( image, cascade, nestedCascade, scale, tryflip );
|
||||||
c = waitKey(0);
|
char c = waitChar(0);
|
||||||
if( c == 27 || c == 'q' || c == 'Q' )
|
if( c == 27 || c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -105,13 +105,13 @@ int main( int argc, char** argv )
|
|||||||
{
|
{
|
||||||
imshow("image", isColor ? image : gray);
|
imshow("image", isColor ? image : gray);
|
||||||
|
|
||||||
int c = waitKey(0);
|
char c = waitChar(0);
|
||||||
if( (c & 255) == 27 )
|
if( c == 27 )
|
||||||
{
|
{
|
||||||
cout << "Exiting ...\n";
|
cout << "Exiting ...\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch( (char)c )
|
switch( c )
|
||||||
{
|
{
|
||||||
case 'c':
|
case 'c':
|
||||||
if( isColor )
|
if( isColor )
|
||||||
|
@ -306,8 +306,8 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
int c = waitKey(0);
|
char c = waitChar(0);
|
||||||
switch( (char) c )
|
switch( c )
|
||||||
{
|
{
|
||||||
case '\x1b':
|
case '\x1b':
|
||||||
cout << "Exiting ..." << endl;
|
cout << "Exiting ..." << endl;
|
||||||
|
@ -57,7 +57,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
imshow("Image sequence | press ESC to close", image);
|
imshow("Image sequence | press ESC to close", image);
|
||||||
|
|
||||||
if(waitKey(500) == 27)
|
if( waitChar(500) == 27)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
char c = (char)waitKey();
|
char c = waitChar();
|
||||||
|
|
||||||
if( c == 27 )
|
if( c == 27 )
|
||||||
break;
|
break;
|
||||||
|
@ -35,7 +35,7 @@ int main(int, char**)
|
|||||||
Mat state(2, 1, CV_32F); /* (phi, delta_phi) */
|
Mat state(2, 1, CV_32F); /* (phi, delta_phi) */
|
||||||
Mat processNoise(2, 1, CV_32F);
|
Mat processNoise(2, 1, CV_32F);
|
||||||
Mat measurement = Mat::zeros(1, 1, CV_32F);
|
Mat measurement = Mat::zeros(1, 1, CV_32F);
|
||||||
char code = (char)-1;
|
char code = 0;
|
||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
@ -89,7 +89,7 @@ int main(int, char**)
|
|||||||
state = KF.transitionMatrix*state + processNoise;
|
state = KF.transitionMatrix*state + processNoise;
|
||||||
|
|
||||||
imshow( "Kalman", img );
|
imshow( "Kalman", img );
|
||||||
code = (char)waitKey(100);
|
code = waitChar(100);
|
||||||
|
|
||||||
if( code > 0 )
|
if( code > 0 )
|
||||||
break;
|
break;
|
||||||
|
@ -68,7 +68,7 @@ int main( int /*argc*/, char** /*argv*/ )
|
|||||||
|
|
||||||
imshow("clusters", img);
|
imshow("clusters", img);
|
||||||
|
|
||||||
char key = (char)waitKey();
|
char key = waitChar();
|
||||||
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
|
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -83,10 +83,10 @@ int main( int argc, char** argv )
|
|||||||
convertScaleAbs(laplace, result, (sigma+1)*0.25);
|
convertScaleAbs(laplace, result, (sigma+1)*0.25);
|
||||||
imshow("Laplacian", result);
|
imshow("Laplacian", result);
|
||||||
|
|
||||||
int c = waitKey(30);
|
char c = waitChar(30);
|
||||||
if( c == ' ' )
|
if( c == ' ' )
|
||||||
smoothType = smoothType == GAUSSIAN ? BLUR : smoothType == BLUR ? MEDIAN : GAUSSIAN;
|
smoothType = smoothType == GAUSSIAN ? BLUR : smoothType == BLUR ? MEDIAN : GAUSSIAN;
|
||||||
if( c == 'q' || c == 'Q' || (c & 255) == 27 )
|
if( c == 'q' || c == 'Q' || c == 27 )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ int main( int argc, char** argv )
|
|||||||
needToInit = false;
|
needToInit = false;
|
||||||
imshow("LK Demo", image);
|
imshow("LK Demo", image);
|
||||||
|
|
||||||
char c = (char)waitKey(10);
|
char c = waitChar(10);
|
||||||
if( c == 27 )
|
if( c == 27 )
|
||||||
break;
|
break;
|
||||||
switch( c )
|
switch( c )
|
||||||
|
@ -72,7 +72,7 @@ int main( int /*argc*/, char** /*argv*/ )
|
|||||||
|
|
||||||
imshow( "Rectangle, triangle & circle", img );
|
imshow( "Rectangle, triangle & circle", img );
|
||||||
|
|
||||||
char key = (char)waitKey();
|
char key = waitChar();
|
||||||
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
|
if( key == 27 || key == 'q' || key == 'Q' ) // 'ESC'
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -82,21 +82,19 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
|
|
||||||
OpenClose(open_close_pos, 0);
|
OpenClose(open_close_pos, 0);
|
||||||
ErodeDilate(erode_dilate_pos, 0);
|
ErodeDilate(erode_dilate_pos, 0);
|
||||||
c = waitKey(0);
|
char c = waitChar(0);
|
||||||
|
|
||||||
if( (char)c == 27 )
|
if( c == 27 )
|
||||||
break;
|
break;
|
||||||
if( (char)c == 'e' )
|
if( c == 'e' )
|
||||||
element_shape = MORPH_ELLIPSE;
|
element_shape = MORPH_ELLIPSE;
|
||||||
else if( (char)c == 'r' )
|
else if( c == 'r' )
|
||||||
element_shape = MORPH_RECT;
|
element_shape = MORPH_RECT;
|
||||||
else if( (char)c == 'c' )
|
else if( c == 'c' )
|
||||||
element_shape = MORPH_CROSS;
|
element_shape = MORPH_CROSS;
|
||||||
else if( (char)c == ' ' )
|
else if( c == ' ' )
|
||||||
element_shape = (element_shape + 1) % 3;
|
element_shape = (element_shape + 1) % 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +183,9 @@ int main(int argc, char** argv)
|
|||||||
// display until user presses q
|
// display until user presses q
|
||||||
imshow(winName, reconstruction);
|
imshow(winName, reconstruction);
|
||||||
|
|
||||||
int key = 0;
|
char key = 0;
|
||||||
while(key != 'q')
|
while(key != 'q')
|
||||||
key = waitKey();
|
key = waitChar();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ int main(int, char* [])
|
|||||||
{
|
{
|
||||||
VideoCapture video(0);
|
VideoCapture video(0);
|
||||||
Mat frame, curr, prev, curr64f, prev64f, hann;
|
Mat frame, curr, prev, curr64f, prev64f, hann;
|
||||||
int key = 0;
|
char key;
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
@ -37,10 +37,10 @@ int main(int, char* [])
|
|||||||
}
|
}
|
||||||
|
|
||||||
imshow("phase shift", frame);
|
imshow("phase shift", frame);
|
||||||
key = waitKey(2);
|
key = waitChar(2);
|
||||||
|
|
||||||
prev = curr.clone();
|
prev = curr.clone();
|
||||||
} while((char)key != 27); // Esc to exit...
|
} while(key != 27); // Esc to exit...
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -312,7 +312,7 @@ int main()
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
uchar key = (uchar)waitKey();
|
char key = waitChar();
|
||||||
|
|
||||||
if( key == 27 ) break;
|
if( key == 27 ) break;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ int main(int argc, char** argv)
|
|||||||
refineSegments(tmp_frame, bgmask, out_frame);
|
refineSegments(tmp_frame, bgmask, out_frame);
|
||||||
imshow("video", tmp_frame);
|
imshow("video", tmp_frame);
|
||||||
imshow("segmented", out_frame);
|
imshow("segmented", out_frame);
|
||||||
int keycode = waitKey(30);
|
char keycode = waitChar(30);
|
||||||
if( keycode == 27 )
|
if( keycode == 27 )
|
||||||
break;
|
break;
|
||||||
if( keycode == ' ' )
|
if( keycode == ' ' )
|
||||||
|
@ -285,8 +285,8 @@ static int select3DBox(const string& windowname, const string& selWinName, const
|
|||||||
imshow(windowname, shownFrame);
|
imshow(windowname, shownFrame);
|
||||||
imshow(selWinName, selectedObjFrame);
|
imshow(selWinName, selectedObjFrame);
|
||||||
|
|
||||||
int c = waitKey(30);
|
char c = waitChar(30);
|
||||||
if( (c & 255) == 27 )
|
if( c == 27 )
|
||||||
{
|
{
|
||||||
nobjpt = 0;
|
nobjpt = 0;
|
||||||
}
|
}
|
||||||
@ -593,7 +593,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
imshow("View", shownFrame);
|
imshow("View", shownFrame);
|
||||||
imshow("Selected Object", selectedObjFrame);
|
imshow("Selected Object", selectedObjFrame);
|
||||||
int c = waitKey(imageList.empty() && !box.empty() ? 30 : 300);
|
char c = waitChar(imageList.empty() && !box.empty() ? 30 : 300);
|
||||||
if( c == 'q' || c == 'Q' )
|
if( c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
if( c == '\r' || c == '\n' )
|
if( c == '\r' || c == '\n' )
|
||||||
|
@ -99,7 +99,7 @@ int main( int argc, const char** argv )
|
|||||||
Mat frame1 = frame.clone();
|
Mat frame1 = frame.clone();
|
||||||
detectAndDraw( frame1, cascade, nestedCascade, scale, tryflip );
|
detectAndDraw( frame1, cascade, nestedCascade, scale, tryflip );
|
||||||
|
|
||||||
int c = waitKey(10);
|
char c = waitChar(10);
|
||||||
if( c == 27 || c == 'q' || c == 'Q' )
|
if( c == 27 || c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,8 @@ int main(int argc, char** argv)
|
|||||||
findSquares(image, squares);
|
findSquares(image, squares);
|
||||||
drawSquares(image, squares);
|
drawSquares(image, squares);
|
||||||
|
|
||||||
int c = waitKey();
|
char c = waitChar();
|
||||||
if( (char)c == 27 )
|
if( c == 27 )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
imshow(window_name, frame);
|
imshow(window_name, frame);
|
||||||
char key = (char)waitKey(30); //delay N millis, usually long enough to display and capture input
|
char key = waitChar(30); //delay N millis, usually long enough to display and capture input
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'q':
|
case 'q':
|
||||||
|
@ -122,7 +122,7 @@ StereoCalib(const vector<string>& imagelist, Size boardSize, float squareSize, b
|
|||||||
double sf = 640./MAX(img.rows, img.cols);
|
double sf = 640./MAX(img.rows, img.cols);
|
||||||
resize(cimg, cimg1, Size(), sf, sf);
|
resize(cimg, cimg1, Size(), sf, sf);
|
||||||
imshow("corners", cimg1);
|
imshow("corners", cimg1);
|
||||||
char c = (char)waitKey(500);
|
char c = waitChar(500);
|
||||||
if( c == 27 || c == 'q' || c == 'Q' ) //Allow ESC to quit
|
if( c == 27 || c == 'q' || c == 'Q' ) //Allow ESC to quit
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
@ -320,7 +320,7 @@ StereoCalib(const vector<string>& imagelist, Size boardSize, float squareSize, b
|
|||||||
for( j = 0; j < canvas.cols; j += 16 )
|
for( j = 0; j < canvas.cols; j += 16 )
|
||||||
line(canvas, Point(j, 0), Point(j, canvas.rows), Scalar(0, 255, 0), 1, 8);
|
line(canvas, Point(j, 0), Point(j, canvas.rows), Scalar(0, 255, 0), 1, 8);
|
||||||
imshow("rectified", canvas);
|
imshow("rectified", canvas);
|
||||||
char c = (char)waitKey();
|
char c = waitChar();
|
||||||
if( c == 27 || c == 'q' || c == 'Q' )
|
if( c == 27 || c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -395,7 +395,7 @@ void test_it( const Size & size )
|
|||||||
draw_locations( draw, locations, trained );
|
draw_locations( draw, locations, trained );
|
||||||
|
|
||||||
imshow( "Video", draw );
|
imshow( "Video", draw );
|
||||||
key = (char)waitKey( 10 );
|
key = waitChar( 10 );
|
||||||
if( 27 == key )
|
if( 27 == key )
|
||||||
end_of_process = true;
|
end_of_process = true;
|
||||||
}
|
}
|
||||||
|
@ -45,26 +45,22 @@ int main( void )
|
|||||||
//![infinite_loop]
|
//![infinite_loop]
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
int c;
|
char c = waitChar(0);
|
||||||
c = waitKey(0);
|
|
||||||
|
|
||||||
if( (char)c == 27 )
|
if( c == 27 )
|
||||||
{ break; }
|
{ break; }
|
||||||
if( (char)c == 'u' )
|
//![pyrup]
|
||||||
{
|
if( c == 'u' )
|
||||||
//![pyrup]
|
{ pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
||||||
pyrUp( tmp, dst, Size( tmp.cols*2, tmp.rows*2 ) );
|
|
||||||
//![pyrup]
|
|
||||||
printf( "** Zoom In: Image x 2 \n" );
|
printf( "** Zoom In: Image x 2 \n" );
|
||||||
}
|
}
|
||||||
else if( (char)c == 'd' )
|
//![pyrup]
|
||||||
{
|
//![pyrdown]
|
||||||
//![pyrdown]
|
else if( c == 'd' )
|
||||||
pyrDown( tmp, dst, Size( tmp.cols/2, tmp.rows/2 ) );
|
{ pyrDown( tmp, dst, Size( tmp.cols/2, tmp.rows/2 ) );
|
||||||
//![pyrdown]
|
|
||||||
printf( "** Zoom Out: Image / 2 \n" );
|
printf( "** Zoom Out: Image / 2 \n" );
|
||||||
}
|
}
|
||||||
|
//![pyrdown]
|
||||||
imshow( window_name, dst );
|
imshow( window_name, dst );
|
||||||
|
|
||||||
//![update_tmp]
|
//![update_tmp]
|
||||||
|
@ -95,7 +95,7 @@ int display_caption( const char* caption )
|
|||||||
FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255) );
|
FONT_HERSHEY_COMPLEX, 1, Scalar(255, 255, 255) );
|
||||||
|
|
||||||
imshow( window_name, dst );
|
imshow( window_name, dst );
|
||||||
int c = waitKey( DELAY_CAPTION );
|
char c = waitChar( DELAY_CAPTION );
|
||||||
if( c >= 0 ) { return -1; }
|
if( c >= 0 ) { return -1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ int display_caption( const char* caption )
|
|||||||
int display_dst( int delay )
|
int display_dst( int delay )
|
||||||
{
|
{
|
||||||
imshow( window_name, dst );
|
imshow( window_name, dst );
|
||||||
int c = waitKey ( delay );
|
char c = waitChar( delay );
|
||||||
if( c >= 0 ) { return -1; }
|
if( c >= 0 ) { return -1; }
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,8 @@ int main( int, char** argv )
|
|||||||
/// Wait until user finishes program
|
/// Wait until user finishes program
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
int c;
|
char c = waitChar( 20 );
|
||||||
c = waitKey( 20 );
|
if( c == 27 )
|
||||||
if( (char)c == 27 )
|
|
||||||
{ break; }
|
{ break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ int main()
|
|||||||
createTrackbar("Low B","Object Detection", &low_b, 255, on_low_b_thresh_trackbar);
|
createTrackbar("Low B","Object Detection", &low_b, 255, on_low_b_thresh_trackbar);
|
||||||
createTrackbar("High B","Object Detection", &high_b, 255, on_high_b_thresh_trackbar);
|
createTrackbar("High B","Object Detection", &high_b, 255, on_high_b_thresh_trackbar);
|
||||||
//! [trackbar]
|
//! [trackbar]
|
||||||
while(char(waitKey(1))!='q'){
|
while(waitChar(1)!='q'){
|
||||||
//! [while]
|
//! [while]
|
||||||
cap>>frame;
|
cap>>frame;
|
||||||
if(frame.empty())
|
if(frame.empty())
|
||||||
|
@ -90,7 +90,7 @@ int main(int argc, char** argv)
|
|||||||
// infinite loop to display
|
// infinite loop to display
|
||||||
// and refresh the content of the output image
|
// and refresh the content of the output image
|
||||||
// until the user presses q or Q
|
// until the user presses q or Q
|
||||||
int key = 0;
|
char key = 0;
|
||||||
while(key != 'q' && key != 'Q')
|
while(key != 'q' && key != 'Q')
|
||||||
{
|
{
|
||||||
// those paramaters cannot be =0
|
// those paramaters cannot be =0
|
||||||
@ -102,7 +102,7 @@ int main(int argc, char** argv)
|
|||||||
HoughDetection(src_gray, src, cannyThreshold, accumulatorThreshold);
|
HoughDetection(src_gray, src, cannyThreshold, accumulatorThreshold);
|
||||||
|
|
||||||
// get user key
|
// get user key
|
||||||
key = waitKey(10);
|
key = waitChar(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -40,9 +40,9 @@ int main( int, char** argv )
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
/// Each 1 sec. Press ESC to exit the program
|
/// Each 1 sec. Press ESC to exit the program
|
||||||
int c = waitKey( 1000 );
|
char c = waitChar( 1000 );
|
||||||
|
|
||||||
if( (char)c == 27 )
|
if( c == 27 )
|
||||||
{ break; }
|
{ break; }
|
||||||
|
|
||||||
/// Update map_x & map_y. Then apply remap
|
/// Update map_x & map_y. Then apply remap
|
||||||
|
@ -23,9 +23,6 @@ RNG rng(12345);
|
|||||||
*/
|
*/
|
||||||
int main( int, char** argv )
|
int main( int, char** argv )
|
||||||
{
|
{
|
||||||
|
|
||||||
int c;
|
|
||||||
|
|
||||||
//![load]
|
//![load]
|
||||||
src = imread( argv[1], IMREAD_COLOR ); // Load an image
|
src = imread( argv[1], IMREAD_COLOR ); // Load an image
|
||||||
|
|
||||||
@ -59,13 +56,12 @@ int main( int, char** argv )
|
|||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
//![check_keypress]
|
//![check_keypress]
|
||||||
c = waitKey(500);
|
char c = waitChar(500);
|
||||||
|
if( c == 27 )
|
||||||
if( (char)c == 27 )
|
|
||||||
{ break; }
|
{ break; }
|
||||||
else if( (char)c == 'c' )
|
else if( c == 'c' )
|
||||||
{ borderType = BORDER_CONSTANT; }
|
{ borderType = BORDER_CONSTANT; }
|
||||||
else if( (char)c == 'r' )
|
else if( c == 'r' )
|
||||||
{ borderType = BORDER_REPLICATE; }
|
{ borderType = BORDER_REPLICATE; }
|
||||||
//![check_keypress]
|
//![check_keypress]
|
||||||
|
|
||||||
|
@ -25,8 +25,6 @@ int main ( int, char** argv )
|
|||||||
int kernel_size;
|
int kernel_size;
|
||||||
const char* window_name = "filter2D Demo";
|
const char* window_name = "filter2D Demo";
|
||||||
|
|
||||||
int c;
|
|
||||||
|
|
||||||
//![load]
|
//![load]
|
||||||
src = imread( argv[1], IMREAD_COLOR ); // Load an image
|
src = imread( argv[1], IMREAD_COLOR ); // Load an image
|
||||||
|
|
||||||
@ -45,9 +43,9 @@ int main ( int, char** argv )
|
|||||||
int ind = 0;
|
int ind = 0;
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
c = waitKey(500);
|
char c = waitChar(500);
|
||||||
/// Press 'ESC' to exit the program
|
/// Press 'ESC' to exit the program
|
||||||
if( (char)c == 27 )
|
if( c == 27 )
|
||||||
{ break; }
|
{ break; }
|
||||||
|
|
||||||
//![update_kernel]
|
//![update_kernel]
|
||||||
|
@ -393,7 +393,7 @@ int main(int argc, char* argv[])
|
|||||||
//------------------------------ Show image and check for input commands -------------------
|
//------------------------------ Show image and check for input commands -------------------
|
||||||
//! [await_input]
|
//! [await_input]
|
||||||
imshow("Image View", view);
|
imshow("Image View", view);
|
||||||
char key = (char)waitKey(s.inputCapture.isOpened() ? 50 : s.delay);
|
char key = waitChar(s.inputCapture.isOpened() ? 50 : s.delay);
|
||||||
|
|
||||||
if( key == ESC_KEY )
|
if( key == ESC_KEY )
|
||||||
break;
|
break;
|
||||||
@ -438,7 +438,7 @@ int main(int argc, char* argv[])
|
|||||||
continue;
|
continue;
|
||||||
remap(view, rview, map1, map2, INTER_LINEAR);
|
remap(view, rview, map1, map2, INTER_LINEAR);
|
||||||
imshow("Image View", rview);
|
imshow("Image View", rview);
|
||||||
char c = (char)waitKey();
|
char c = waitChar();
|
||||||
if( c == ESC_KEY || c == 'q' || c == 'Q' )
|
if( c == ESC_KEY || c == 'q' || c == 'Q' )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -180,7 +180,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
Mat frame, frame_vis;
|
Mat frame, frame_vis;
|
||||||
|
|
||||||
while(cap.read(frame) && waitKey(30) != 27) // capture frame until ESC is pressed
|
while(cap.read(frame) && waitChar(30) != 27) // capture frame until ESC is pressed
|
||||||
{
|
{
|
||||||
|
|
||||||
frame_vis = frame.clone(); // refresh visualisation frame
|
frame_vis = frame.clone(); // refresh visualisation frame
|
||||||
|
@ -195,7 +195,7 @@ int main(int argc, char **argv)
|
|||||||
drawStatistics(orb_res, orb_draw_stats);
|
drawStatistics(orb_res, orb_draw_stats);
|
||||||
vconcat(akaze_res, orb_res, res_frame);
|
vconcat(akaze_res, orb_res, res_frame);
|
||||||
cv::imshow(video_name, res_frame);
|
cv::imshow(video_name, res_frame);
|
||||||
if(cv::waitKey(1)==27) break; //quit on ESC button
|
if(cv::waitChar(1)==27) break; //quit on ESC button
|
||||||
}
|
}
|
||||||
akaze_stats /= i - 1;
|
akaze_stats /= i - 1;
|
||||||
orb_stats /= i - 1;
|
orb_stats /= i - 1;
|
||||||
|
@ -44,8 +44,8 @@ int main( void )
|
|||||||
//-- 3. Apply the classifier to the frame
|
//-- 3. Apply the classifier to the frame
|
||||||
detectAndDisplay( frame );
|
detectAndDisplay( frame );
|
||||||
|
|
||||||
int c = waitKey(10);
|
char c = waitChar(10);
|
||||||
if( (char)c == 27 ) { break; } // escape
|
if( c == 27 ) { break; } // escape
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -51,8 +51,8 @@ int main( void )
|
|||||||
detectAndDisplay( frame );
|
detectAndDisplay( frame );
|
||||||
|
|
||||||
//-- bail out if escape was pressed
|
//-- bail out if escape was pressed
|
||||||
int c = waitKey(10);
|
char c = waitChar(10);
|
||||||
if( (char)c == 27 ) { break; }
|
if( c == 27 ) { break; }
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -452,7 +452,7 @@ int main()
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
char key = (char) waitKey(0);
|
char key = waitChar(0);
|
||||||
|
|
||||||
if(key == 'd' && flag3 == 0)
|
if(key == 'd' && flag3 == 0)
|
||||||
{
|
{
|
||||||
|
@ -23,7 +23,7 @@ using namespace std;
|
|||||||
Mat frame; //current frame
|
Mat frame; //current frame
|
||||||
Mat fgMaskMOG2; //fg mask fg mask generated by MOG2 method
|
Mat fgMaskMOG2; //fg mask fg mask generated by MOG2 method
|
||||||
Ptr<BackgroundSubtractor> pMOG2; //MOG2 Background subtractor
|
Ptr<BackgroundSubtractor> pMOG2; //MOG2 Background subtractor
|
||||||
int keyboard; //input from keyboard
|
char keyboard; //input from keyboard
|
||||||
|
|
||||||
/** Function Headers */
|
/** Function Headers */
|
||||||
void help();
|
void help();
|
||||||
@ -98,7 +98,8 @@ void processVideo(char* videoFilename) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
//read input data. ESC or 'q' for quitting
|
//read input data. ESC or 'q' for quitting
|
||||||
while( (char)keyboard != 'q' && (char)keyboard != 27 ){
|
keyboard = 0;
|
||||||
|
while( keyboard != 'q' && keyboard != 27 ){
|
||||||
//read the current frame
|
//read the current frame
|
||||||
if(!capture.read(frame)) {
|
if(!capture.read(frame)) {
|
||||||
cerr << "Unable to read next frame." << endl;
|
cerr << "Unable to read next frame." << endl;
|
||||||
@ -119,7 +120,7 @@ void processVideo(char* videoFilename) {
|
|||||||
imshow("Frame", frame);
|
imshow("Frame", frame);
|
||||||
imshow("FG Mask MOG 2", fgMaskMOG2);
|
imshow("FG Mask MOG 2", fgMaskMOG2);
|
||||||
//get the input from the keyboard
|
//get the input from the keyboard
|
||||||
keyboard = waitKey( 30 );
|
keyboard = waitChar( 30 );
|
||||||
}
|
}
|
||||||
//delete capture object
|
//delete capture object
|
||||||
capture.release();
|
capture.release();
|
||||||
@ -139,7 +140,8 @@ void processImages(char* fistFrameFilename) {
|
|||||||
//current image filename
|
//current image filename
|
||||||
string fn(fistFrameFilename);
|
string fn(fistFrameFilename);
|
||||||
//read input data. ESC or 'q' for quitting
|
//read input data. ESC or 'q' for quitting
|
||||||
while( (char)keyboard != 'q' && (char)keyboard != 27 ){
|
keyboard = 0;
|
||||||
|
while( keyboard != 'q' && keyboard != 27 ){
|
||||||
//update the background model
|
//update the background model
|
||||||
pMOG2->apply(frame, fgMaskMOG2);
|
pMOG2->apply(frame, fgMaskMOG2);
|
||||||
//get the frame number and write it on the current frame
|
//get the frame number and write it on the current frame
|
||||||
@ -162,7 +164,7 @@ void processImages(char* fistFrameFilename) {
|
|||||||
imshow("Frame", frame);
|
imshow("Frame", frame);
|
||||||
imshow("FG Mask MOG 2", fgMaskMOG2);
|
imshow("FG Mask MOG 2", fgMaskMOG2);
|
||||||
//get the input from the keyboard
|
//get the input from the keyboard
|
||||||
keyboard = waitKey( 30 );
|
keyboard = waitChar( 30 );
|
||||||
//search for the next image in the sequence
|
//search for the next image in the sequence
|
||||||
ostringstream oss;
|
ostringstream oss;
|
||||||
oss << (frameNumber + 1);
|
oss << (frameNumber + 1);
|
||||||
|
@ -44,7 +44,6 @@ int main(int argc, char *argv[])
|
|||||||
conv << argv[3] << endl << argv[4]; // put in the strings
|
conv << argv[3] << endl << argv[4]; // put in the strings
|
||||||
conv >> psnrTriggerValue >> delay; // take out the numbers
|
conv >> psnrTriggerValue >> delay; // take out the numbers
|
||||||
|
|
||||||
char c;
|
|
||||||
int frameNum = -1; // Frame counter
|
int frameNum = -1; // Frame counter
|
||||||
|
|
||||||
VideoCapture captRefrnc(sourceReference), captUndTst(sourceCompareWith);
|
VideoCapture captRefrnc(sourceReference), captUndTst(sourceCompareWith);
|
||||||
@ -126,7 +125,7 @@ int main(int argc, char *argv[])
|
|||||||
imshow(WIN_RF, frameReference);
|
imshow(WIN_RF, frameReference);
|
||||||
imshow(WIN_UT, frameUnderTest);
|
imshow(WIN_UT, frameUnderTest);
|
||||||
|
|
||||||
c = (char)waitKey(delay);
|
char c = waitChar(delay);
|
||||||
if (c == 27) break;
|
if (c == 27) break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void run()
|
|||||||
if (!quietMode)
|
if (!quietMode)
|
||||||
{
|
{
|
||||||
imshow("stabilizedFrame", stabilizedFrame);
|
imshow("stabilizedFrame", stabilizedFrame);
|
||||||
char key = static_cast<char>(waitKey(3));
|
char key = waitChar(3);
|
||||||
if (key == 27) { cout << endl; break; }
|
if (key == 27) { cout << endl; break; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -74,19 +74,19 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
int c = waitKey(0);
|
char c = waitChar(0);
|
||||||
|
|
||||||
if( (char)c == 27 )
|
if( c == 27 )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if( (char)c == 'r' )
|
if( c == 'r' )
|
||||||
{
|
{
|
||||||
markerMask = Scalar::all(0);
|
markerMask = Scalar::all(0);
|
||||||
img0.copyTo(img);
|
img0.copyTo(img);
|
||||||
imshow( "image", img );
|
imshow( "image", img );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( (char)c == 'w' || (char)c == ' ' )
|
if( c == 'w' || c == ' ' )
|
||||||
{
|
{
|
||||||
int i, j, compCount = 0;
|
int i, j, compCount = 0;
|
||||||
vector<vector<Point> > contours;
|
vector<vector<Point> > contours;
|
||||||
|
@ -50,7 +50,7 @@ int main()
|
|||||||
|
|
||||||
imshow("Result", d_res);
|
imshow("Result", d_res);
|
||||||
|
|
||||||
char key = static_cast<char>(waitKey());
|
char key = waitChar();
|
||||||
|
|
||||||
if (key == 27)
|
if (key == 27)
|
||||||
break;
|
break;
|
||||||
|
@ -161,7 +161,7 @@ int main(int argc, const char** argv)
|
|||||||
if (!bgimg.empty())
|
if (!bgimg.empty())
|
||||||
imshow("mean background image", bgimg);
|
imshow("mean background image", bgimg);
|
||||||
|
|
||||||
int key = waitKey(30);
|
char key = waitChar(30);
|
||||||
if (key == 27)
|
if (key == 27)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ int main(int argc, const char *argv[])
|
|||||||
displayState(frameDisp, helpScreen, useGPU, findLargestObject, filterRects, fps);
|
displayState(frameDisp, helpScreen, useGPU, findLargestObject, filterRects, fps);
|
||||||
imshow("result", frameDisp);
|
imshow("result", frameDisp);
|
||||||
|
|
||||||
char key = (char)waitKey(5);
|
char key = waitChar(5);
|
||||||
if (key == 27)
|
if (key == 27)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
|
@ -348,7 +348,7 @@ int main(int argc, const char** argv)
|
|||||||
imshow(wndTitle, frameDisp);
|
imshow(wndTitle, frameDisp);
|
||||||
|
|
||||||
//handle input
|
//handle input
|
||||||
switch (cv::waitKey(3))
|
switch (cv::waitChar(3))
|
||||||
{
|
{
|
||||||
case ' ':
|
case ' ':
|
||||||
bUseGPU = !bUseGPU;
|
bUseGPU = !bUseGPU;
|
||||||
|
@ -125,7 +125,7 @@ int main(int argc, char **argv)
|
|||||||
|
|
||||||
imshow("flow", image);
|
imshow("flow", image);
|
||||||
|
|
||||||
char ch = (char)waitKey(3);
|
char ch = waitChar(3);
|
||||||
if (ch == 27)
|
if (ch == 27)
|
||||||
running = false;
|
running = false;
|
||||||
else if (ch == 'm' || ch == 'M')
|
else if (ch == 'm' || ch == 'M')
|
||||||
|
@ -81,7 +81,7 @@ int App::run()
|
|||||||
OpenClose();
|
OpenClose();
|
||||||
ErodeDilate();
|
ErodeDilate();
|
||||||
|
|
||||||
char c = (char) waitKey();
|
char c = waitChar();
|
||||||
|
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
@ -105,8 +105,8 @@ int main(int argc, char* argv[])
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
updateWindow("OpenGL");
|
updateWindow("OpenGL");
|
||||||
int key = waitKey(40);
|
char key = waitChar(40);
|
||||||
if ((key & 0xff) == 27)
|
if (key == 27)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,10 +110,10 @@ class App(object):
|
|||||||
|
|
||||||
cv2.imshow('camshift', vis)
|
cv2.imshow('camshift', vis)
|
||||||
|
|
||||||
ch = 0xFF & cv2.waitKey(5)
|
ch = cv2.waitChar(5)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord('b'):
|
if ch == 'b':
|
||||||
self.show_backproj = not self.show_backproj
|
self.show_backproj = not self.show_backproj
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
|
||||||
|
@ -77,8 +77,8 @@ if __name__ == '__main__':
|
|||||||
cv2.imshow('src', src)
|
cv2.imshow('src', src)
|
||||||
update()
|
update()
|
||||||
while True:
|
while True:
|
||||||
ch = 0xFF & cv2.waitKey()
|
ch = cv2.waitChar()
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
update()
|
update()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
|
@ -56,7 +56,7 @@ if __name__ == '__main__':
|
|||||||
vis = hsv_map*h[:,:,np.newaxis] / 255.0
|
vis = hsv_map*h[:,:,np.newaxis] / 255.0
|
||||||
cv2.imshow('hist', vis)
|
cv2.imshow('hist', vis)
|
||||||
|
|
||||||
ch = 0xFF & cv2.waitKey(1)
|
ch = cv2.waitChar(1)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -66,5 +66,5 @@ if __name__ == '__main__':
|
|||||||
update(3)
|
update(3)
|
||||||
cv2.createTrackbar( "levels+3", "contours", 3, 7, update )
|
cv2.createTrackbar( "levels+3", "contours", 3, 7, update )
|
||||||
cv2.imshow('image', img)
|
cv2.imshow('image', img)
|
||||||
0xFF & cv2.waitKey()
|
cv2.waitKey()
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -122,9 +122,9 @@ if __name__ == '__main__':
|
|||||||
update(None)
|
update(None)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
ch = cv2.waitKey() & 0xFF
|
ch = cv2.waitChar()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
defocus = not defocus
|
defocus = not defocus
|
||||||
update(None)
|
update(None)
|
||||||
|
@ -92,7 +92,7 @@ def main():
|
|||||||
|
|
||||||
cv2.imshow('frame', frame)
|
cv2.imshow('frame', frame)
|
||||||
cv2.imshow('bin', bin)
|
cv2.imshow('bin', bin)
|
||||||
ch = cv2.waitKey(1) & 0xFF
|
ch = cv2.waitChar(1)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
ch = 0xFF & cv2.waitKey(50)
|
ch = cv2.waitChar(50)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord('v'):
|
if ch == 'v':
|
||||||
voronoi = not voronoi
|
voronoi = not voronoi
|
||||||
print('showing', ['distance', 'voronoi'][voronoi])
|
print('showing', ['distance', 'voronoi'][voronoi])
|
||||||
update()
|
update()
|
||||||
|
@ -49,7 +49,7 @@ if __name__ == '__main__':
|
|||||||
vis = np.uint8(vis/2.)
|
vis = np.uint8(vis/2.)
|
||||||
vis[edge != 0] = (0, 255, 0)
|
vis[edge != 0] = (0, 255, 0)
|
||||||
cv2.imshow('edge', vis)
|
cv2.imshow('edge', vis)
|
||||||
ch = cv2.waitKey(5) & 0xFF
|
ch = cv2.waitChar(5)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -68,6 +68,6 @@ if __name__ == '__main__':
|
|||||||
draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000))
|
draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000))
|
||||||
cv2.imshow('facedetect', vis)
|
cv2.imshow('facedetect', vis)
|
||||||
|
|
||||||
if 0xFF & cv2.waitKey(5) == 27:
|
if cv2.waitChar(5) == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -80,8 +80,8 @@ class App:
|
|||||||
|
|
||||||
self.rect_sel.draw(vis)
|
self.rect_sel.draw(vis)
|
||||||
cv2.imshow('plane', vis)
|
cv2.imshow('plane', vis)
|
||||||
ch = cv2.waitKey(1)
|
ch = cv2.waitChar(1)
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
self.paused = not self.paused
|
self.paused = not self.paused
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
|
@ -88,8 +88,8 @@ if __name__ == '__main__':
|
|||||||
cv2.createTrackbar('outlier %', 'fit line', 30, 100, update)
|
cv2.createTrackbar('outlier %', 'fit line', 30, 100, update)
|
||||||
while True:
|
while True:
|
||||||
update()
|
update()
|
||||||
ch = cv2.waitKey(0) & 0xFF
|
ch = cv2.waitChar(0)
|
||||||
if ch == ord('f'):
|
if ch == 'f':
|
||||||
if PY3:
|
if PY3:
|
||||||
cur_func_name = next(dist_func_names)
|
cur_func_name = next(dist_func_names)
|
||||||
else:
|
else:
|
||||||
|
@ -66,14 +66,14 @@ if __name__ == '__main__':
|
|||||||
cv2.createTrackbar('hi', 'floodfill', 20, 255, update)
|
cv2.createTrackbar('hi', 'floodfill', 20, 255, update)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
ch = 0xFF & cv2.waitKey()
|
ch = cv2.waitChar()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord('f'):
|
if ch == 'f':
|
||||||
fixed_range = not fixed_range
|
fixed_range = not fixed_range
|
||||||
print('using %s range' % ('floating', 'fixed')[fixed_range])
|
print('using %s range' % ('floating', 'fixed')[fixed_range])
|
||||||
update()
|
update()
|
||||||
if ch == ord('c'):
|
if ch == 'c':
|
||||||
connectivity = 12-connectivity
|
connectivity = 12-connectivity
|
||||||
print('connectivity =', connectivity)
|
print('connectivity =', connectivity)
|
||||||
update()
|
update()
|
||||||
|
@ -63,7 +63,7 @@ if __name__ == '__main__':
|
|||||||
draw_gaussain(img, m, cov, (0, 0, 255))
|
draw_gaussain(img, m, cov, (0, 0, 255))
|
||||||
|
|
||||||
cv2.imshow('gaussian mixture', img)
|
cv2.imshow('gaussian mixture', img)
|
||||||
ch = 0xFF & cv2.waitKey(0)
|
ch = cv2.waitChar(0)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -129,27 +129,27 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
cv2.imshow('output',output)
|
cv2.imshow('output',output)
|
||||||
cv2.imshow('input',img)
|
cv2.imshow('input',img)
|
||||||
k = 0xFF & cv2.waitKey(1)
|
k = cv2.waitChar(1)
|
||||||
|
|
||||||
# key bindings
|
# key bindings
|
||||||
if k == 27: # esc to exit
|
if k == 27: # esc to exit
|
||||||
break
|
break
|
||||||
elif k == ord('0'): # BG drawing
|
elif k == '0': # BG drawing
|
||||||
print(" mark background regions with left mouse button \n")
|
print(" mark background regions with left mouse button \n")
|
||||||
value = DRAW_BG
|
value = DRAW_BG
|
||||||
elif k == ord('1'): # FG drawing
|
elif k == '1': # FG drawing
|
||||||
print(" mark foreground regions with left mouse button \n")
|
print(" mark foreground regions with left mouse button \n")
|
||||||
value = DRAW_FG
|
value = DRAW_FG
|
||||||
elif k == ord('2'): # PR_BG drawing
|
elif k == '2': # PR_BG drawing
|
||||||
value = DRAW_PR_BG
|
value = DRAW_PR_BG
|
||||||
elif k == ord('3'): # PR_FG drawing
|
elif k == '3': # PR_FG drawing
|
||||||
value = DRAW_PR_FG
|
value = DRAW_PR_FG
|
||||||
elif k == ord('s'): # save image
|
elif k == 's': # save image
|
||||||
bar = np.zeros((img.shape[0],5,3),np.uint8)
|
bar = np.zeros((img.shape[0],5,3),np.uint8)
|
||||||
res = np.hstack((img2,bar,img,bar,output))
|
res = np.hstack((img2,bar,img,bar,output))
|
||||||
cv2.imwrite('grabcut_output.png',res)
|
cv2.imwrite('grabcut_output.png',res)
|
||||||
print(" Result saved as image \n")
|
print(" Result saved as image \n")
|
||||||
elif k == ord('r'): # reset everything
|
elif k == 'r': # reset everything
|
||||||
print("resetting \n")
|
print("resetting \n")
|
||||||
rect = (0,0,1,1)
|
rect = (0,0,1,1)
|
||||||
drawing = False
|
drawing = False
|
||||||
@ -160,7 +160,7 @@ if __name__ == '__main__':
|
|||||||
img = img2.copy()
|
img = img2.copy()
|
||||||
mask = np.zeros(img.shape[:2],dtype = np.uint8) # mask initialized to PR_BG
|
mask = np.zeros(img.shape[:2],dtype = np.uint8) # mask initialized to PR_BG
|
||||||
output = np.zeros(img.shape,np.uint8) # output image to be shown
|
output = np.zeros(img.shape,np.uint8) # output image to be shown
|
||||||
elif k == ord('n'): # segment the image
|
elif k == 'n': # segment the image
|
||||||
print(""" For finer touchups, mark foreground and background after pressing keys 0-3
|
print(""" For finer touchups, mark foreground and background after pressing keys 0-3
|
||||||
and again press 'n' \n""")
|
and again press 'n' \n""")
|
||||||
if (rect_or_mask == 0): # grabcut with rect
|
if (rect_or_mask == 0): # grabcut with rect
|
||||||
|
@ -84,29 +84,29 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
cv2.imshow('image',im)
|
cv2.imshow('image',im)
|
||||||
while True:
|
while True:
|
||||||
k = cv2.waitKey(0)&0xFF
|
k = cv2.waitChar(0)
|
||||||
if k == ord('a'):
|
if k == 'a':
|
||||||
curve = hist_curve(im)
|
curve = hist_curve(im)
|
||||||
cv2.imshow('histogram',curve)
|
cv2.imshow('histogram',curve)
|
||||||
cv2.imshow('image',im)
|
cv2.imshow('image',im)
|
||||||
print('a')
|
print('a')
|
||||||
elif k == ord('b'):
|
elif k == 'b':
|
||||||
print('b')
|
print('b')
|
||||||
lines = hist_lines(im)
|
lines = hist_lines(im)
|
||||||
cv2.imshow('histogram',lines)
|
cv2.imshow('histogram',lines)
|
||||||
cv2.imshow('image',gray)
|
cv2.imshow('image',gray)
|
||||||
elif k == ord('c'):
|
elif k == 'c':
|
||||||
print('c')
|
print('c')
|
||||||
equ = cv2.equalizeHist(gray)
|
equ = cv2.equalizeHist(gray)
|
||||||
lines = hist_lines(equ)
|
lines = hist_lines(equ)
|
||||||
cv2.imshow('histogram',lines)
|
cv2.imshow('histogram',lines)
|
||||||
cv2.imshow('image',equ)
|
cv2.imshow('image',equ)
|
||||||
elif k == ord('d'):
|
elif k == 'd':
|
||||||
print('d')
|
print('d')
|
||||||
curve = hist_curve(gray)
|
curve = hist_curve(gray)
|
||||||
cv2.imshow('histogram',curve)
|
cv2.imshow('histogram',curve)
|
||||||
cv2.imshow('image',gray)
|
cv2.imshow('image',gray)
|
||||||
elif k == ord('e'):
|
elif k == 'e':
|
||||||
print('e')
|
print('e')
|
||||||
norm = cv2.normalize(gray, gray, alpha = 0,beta = 255,norm_type = cv2.NORM_MINMAX)
|
norm = cv2.normalize(gray, gray, alpha = 0,beta = 255,norm_type = cv2.NORM_MINMAX)
|
||||||
lines = hist_lines(norm)
|
lines = hist_lines(norm)
|
||||||
|
@ -41,13 +41,13 @@ if __name__ == '__main__':
|
|||||||
sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255))
|
sketch = Sketcher('img', [img_mark, mark], lambda : ((255, 255, 255), 255))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
ch = 0xFF & cv2.waitKey()
|
ch = cv2.waitChar()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
res = cv2.inpaint(img_mark, mark, 3, cv2.INPAINT_TELEA)
|
res = cv2.inpaint(img_mark, mark, 3, cv2.INPAINT_TELEA)
|
||||||
cv2.imshow('inpaint', res)
|
cv2.imshow('inpaint', res)
|
||||||
if ch == ord('r'):
|
if ch == 'r':
|
||||||
img_mark[:] = img
|
img_mark[:] = img
|
||||||
mark[:] = 0
|
mark[:] = 0
|
||||||
sketch.show()
|
sketch.show()
|
||||||
|
@ -86,11 +86,11 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
cv2.imshow("Kalman", img)
|
cv2.imshow("Kalman", img)
|
||||||
|
|
||||||
code = cv2.waitKey(100)
|
code = cv2.waitChar(100)
|
||||||
if code != -1:
|
if code != -1:
|
||||||
break
|
break
|
||||||
|
|
||||||
if (code % 0x100) in [27, ord('q'), ord('Q')]:
|
if code in [27, 'q', 'Q']:
|
||||||
break
|
break
|
||||||
|
|
||||||
cv2.destroyWindow("Kalman")
|
cv2.destroyWindow("Kalman")
|
||||||
|
@ -44,7 +44,7 @@ if __name__ == '__main__':
|
|||||||
cv2.circle(img, (x, y), 1, c, -1)
|
cv2.circle(img, (x, y), 1, c, -1)
|
||||||
|
|
||||||
cv2.imshow('gaussian mixture', img)
|
cv2.imshow('gaussian mixture', img)
|
||||||
ch = 0xFF & cv2.waitKey(0)
|
ch = cv2.waitChar(0)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -70,5 +70,5 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
cv2.imshow('laplacian pyramid filter', res)
|
cv2.imshow('laplacian pyramid filter', res)
|
||||||
|
|
||||||
if cv2.waitKey(1) & 0xFF == 27:
|
if cv2.waitChar(1) == 27:
|
||||||
break
|
break
|
||||||
|
@ -90,17 +90,17 @@ class App:
|
|||||||
|
|
||||||
cv2.imshow('lk_homography', vis)
|
cv2.imshow('lk_homography', vis)
|
||||||
|
|
||||||
ch = 0xFF & cv2.waitKey(1)
|
ch = cv2.waitChar(1)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
self.frame0 = frame.copy()
|
self.frame0 = frame.copy()
|
||||||
self.p0 = cv2.goodFeaturesToTrack(frame_gray, **feature_params)
|
self.p0 = cv2.goodFeaturesToTrack(frame_gray, **feature_params)
|
||||||
if self.p0 is not None:
|
if self.p0 is not None:
|
||||||
self.p1 = self.p0
|
self.p1 = self.p0
|
||||||
self.gray0 = frame_gray
|
self.gray0 = frame_gray
|
||||||
self.gray1 = frame_gray
|
self.gray1 = frame_gray
|
||||||
if ch == ord('r'):
|
if ch == 'r':
|
||||||
self.use_ransac = not self.use_ransac
|
self.use_ransac = not self.use_ransac
|
||||||
|
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ class App:
|
|||||||
self.prev_gray = frame_gray
|
self.prev_gray = frame_gray
|
||||||
cv2.imshow('lk_track', vis)
|
cv2.imshow('lk_track', vis)
|
||||||
|
|
||||||
ch = 0xFF & cv2.waitKey(1)
|
ch = cv2.waitChar(1)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
|
|
||||||
|
@ -79,15 +79,15 @@ if __name__ == '__main__':
|
|||||||
cv2.createTrackbar('iters', 'morphology', 1, 10, update)
|
cv2.createTrackbar('iters', 'morphology', 1, 10, update)
|
||||||
update()
|
update()
|
||||||
while True:
|
while True:
|
||||||
ch = 0xFF & cv2.waitKey()
|
ch = cv2.waitChar()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord('1'):
|
if ch == '1':
|
||||||
if PY3:
|
if PY3:
|
||||||
cur_mode = next(modes)
|
cur_mode = next(modes)
|
||||||
else:
|
else:
|
||||||
cur_mode = modes.next()
|
cur_mode = modes.next()
|
||||||
if ch == ord('2'):
|
if ch == '2':
|
||||||
if PY3:
|
if PY3:
|
||||||
cur_str_mode = next(str_modes)
|
cur_str_mode = next(str_modes)
|
||||||
else:
|
else:
|
||||||
|
@ -176,12 +176,12 @@ class App:
|
|||||||
self.rect_sel.draw(vis)
|
self.rect_sel.draw(vis)
|
||||||
|
|
||||||
cv2.imshow('frame', vis)
|
cv2.imshow('frame', vis)
|
||||||
ch = cv2.waitKey(10) & 0xFF
|
ch = cv2.waitChar(10)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
self.paused = not self.paused
|
self.paused = not self.paused
|
||||||
if ch == ord('c'):
|
if ch == 'c':
|
||||||
self.trackers = []
|
self.trackers = []
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,6 +78,6 @@ if __name__ == '__main__':
|
|||||||
drag_start = None
|
drag_start = None
|
||||||
gray=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
gray=cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
|
||||||
cv2.imshow("gray",gray)
|
cv2.imshow("gray",gray)
|
||||||
if (cv2.waitKey() & 255) == 27:
|
if cv2.waitChar() == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -37,6 +37,6 @@ if __name__ == '__main__':
|
|||||||
cv2.polylines(vis, hulls, 1, (0, 255, 0))
|
cv2.polylines(vis, hulls, 1, (0, 255, 0))
|
||||||
|
|
||||||
cv2.imshow('img', vis)
|
cv2.imshow('img', vis)
|
||||||
if 0xFF & cv2.waitKey(5) == 27:
|
if cv2.waitChar(5) == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -83,13 +83,13 @@ if __name__ == '__main__':
|
|||||||
cur_glitch = warp_flow(cur_glitch, flow)
|
cur_glitch = warp_flow(cur_glitch, flow)
|
||||||
cv2.imshow('glitch', cur_glitch)
|
cv2.imshow('glitch', cur_glitch)
|
||||||
|
|
||||||
ch = 0xFF & cv2.waitKey(5)
|
ch = cv2.waitChar(5)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord('1'):
|
if ch == '1':
|
||||||
show_hsv = not show_hsv
|
show_hsv = not show_hsv
|
||||||
print('HSV flow visualization is', ['off', 'on'][show_hsv])
|
print('HSV flow visualization is', ['off', 'on'][show_hsv])
|
||||||
if ch == ord('2'):
|
if ch == '2':
|
||||||
show_glitch = not show_glitch
|
show_glitch = not show_glitch
|
||||||
if show_glitch:
|
if show_glitch:
|
||||||
cur_glitch = img.copy()
|
cur_glitch = img.copy()
|
||||||
|
@ -65,7 +65,7 @@ if __name__ == '__main__':
|
|||||||
draw_detections(img, found_filtered, 3)
|
draw_detections(img, found_filtered, 3)
|
||||||
print('%d (%d) found' % (len(found_filtered), len(found)))
|
print('%d (%d) found' % (len(found_filtered), len(found)))
|
||||||
cv2.imshow('img', img)
|
cv2.imshow('img', img)
|
||||||
ch = 0xFF & cv2.waitKey()
|
ch = cv2.waitChar()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -75,10 +75,10 @@ class App:
|
|||||||
|
|
||||||
self.rect_sel.draw(vis)
|
self.rect_sel.draw(vis)
|
||||||
cv2.imshow('plane', vis)
|
cv2.imshow('plane', vis)
|
||||||
ch = cv2.waitKey(1) & 0xFF
|
ch = cv2.waitChar(1)
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
self.paused = not self.paused
|
self.paused = not self.paused
|
||||||
if ch == ord('c'):
|
if ch == 'c':
|
||||||
self.tracker.clear()
|
self.tracker.clear()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
|
@ -170,10 +170,10 @@ class App:
|
|||||||
|
|
||||||
self.rect_sel.draw(vis)
|
self.rect_sel.draw(vis)
|
||||||
cv2.imshow('plane', vis)
|
cv2.imshow('plane', vis)
|
||||||
ch = cv2.waitKey(1) & 0xFF
|
ch = cv2.waitChar(1)
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
self.paused = not self.paused
|
self.paused = not self.paused
|
||||||
if ch == ord('c'):
|
if ch == 'c':
|
||||||
self.tracker.clear()
|
self.tracker.clear()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
|
@ -49,7 +49,7 @@ if __name__ == '__main__':
|
|||||||
squares = find_squares(img)
|
squares = find_squares(img)
|
||||||
cv2.drawContours( img, squares, -1, (0, 255, 0), 3 )
|
cv2.drawContours( img, squares, -1, (0, 255, 0), 3 )
|
||||||
cv2.imshow('squares', img)
|
cv2.imshow('squares', img)
|
||||||
ch = 0xFF & cv2.waitKey()
|
ch = cv2.waitChar()
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -108,9 +108,9 @@ if __name__ == '__main__':
|
|||||||
img = render.getNextFrame()
|
img = render.getNextFrame()
|
||||||
cv2.imshow('img', img)
|
cv2.imshow('img', img)
|
||||||
|
|
||||||
ch = 0xFF & cv2.waitKey(3)
|
ch = cv2.waitChar(3)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
#import os
|
#import os
|
||||||
#print (os.environ['PYTHONPATH'])
|
#print (os.environ['PYTHONPATH'])
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -69,6 +69,6 @@ if __name__ == '__main__':
|
|||||||
vis = a.copy()
|
vis = a.copy()
|
||||||
draw_str(vis, (20, 20), 'frame %d' % frame_i)
|
draw_str(vis, (20, 20), 'frame %d' % frame_i)
|
||||||
cv2.imshow('a', vis)
|
cv2.imshow('a', vis)
|
||||||
if 0xFF & cv2.waitKey(5) == 27:
|
if cv2.waitChar(5) == 27:
|
||||||
break
|
break
|
||||||
cv2.destroyAllWindows()
|
cv2.destroyAllWindows()
|
||||||
|
@ -217,10 +217,10 @@ if __name__ == '__main__':
|
|||||||
ret, img = cap.read()
|
ret, img = cap.read()
|
||||||
imgs.append(img)
|
imgs.append(img)
|
||||||
cv2.imshow('capture %d' % i, img)
|
cv2.imshow('capture %d' % i, img)
|
||||||
ch = 0xFF & cv2.waitKey(1)
|
ch = cv2.waitChar(1)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
for i, img in enumerate(imgs):
|
for i, img in enumerate(imgs):
|
||||||
fn = '%s/shot_%d_%03d.bmp' % (shotdir, i, shot_idx)
|
fn = '%s/shot_%d_%03d.bmp' % (shotdir, i, shot_idx)
|
||||||
cv2.imwrite(fn, img)
|
cv2.imwrite(fn, img)
|
||||||
|
@ -81,8 +81,8 @@ if __name__ == '__main__':
|
|||||||
else:
|
else:
|
||||||
task = DummyTask(process_frame(frame, t))
|
task = DummyTask(process_frame(frame, t))
|
||||||
pending.append(task)
|
pending.append(task)
|
||||||
ch = 0xFF & cv2.waitKey(1)
|
ch = cv2.waitChar(1)
|
||||||
if ch == ord(' '):
|
if ch == ' ':
|
||||||
threaded_mode = not threaded_mode
|
threaded_mode = not threaded_mode
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
|
@ -58,10 +58,10 @@ while True:
|
|||||||
cv2.putText(img, "FPS: {}".format(fps), (15, 80), font, 1.0, color)
|
cv2.putText(img, "FPS: {}".format(fps), (15, 80), font, 1.0, color)
|
||||||
cv2.imshow("Video", img)
|
cv2.imshow("Video", img)
|
||||||
|
|
||||||
k = 0xFF & cv2.waitKey(1)
|
k = cv2.waitChar(1)
|
||||||
|
|
||||||
if k == 27:
|
if k == 27:
|
||||||
break
|
break
|
||||||
elif k == ord("g"):
|
elif k == 'g':
|
||||||
convert_rgb = not convert_rgb
|
convert_rgb = not convert_rgb
|
||||||
cap.set(cv2.CAP_PROP_CONVERT_RGB, convert_rgb)
|
cap.set(cv2.CAP_PROP_CONVERT_RGB, convert_rgb)
|
||||||
|
@ -56,19 +56,19 @@ class App:
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while cv2.getWindowProperty('img', 0) != -1 or cv2.getWindowProperty('watershed', 0) != -1:
|
while cv2.getWindowProperty('img', 0) != -1 or cv2.getWindowProperty('watershed', 0) != -1:
|
||||||
ch = 0xFF & cv2.waitKey(50)
|
ch = cv2.waitChar(50)
|
||||||
if ch == 27:
|
if ch == 27:
|
||||||
break
|
break
|
||||||
if ch >= ord('1') and ch <= ord('7'):
|
if ch >= '1' and ch <= '7':
|
||||||
self.cur_marker = ch - ord('0')
|
self.cur_marker = ch - '0'
|
||||||
print('marker: ', self.cur_marker)
|
print('marker: ', self.cur_marker)
|
||||||
if ch == ord(' ') or (self.sketch.dirty and self.auto_update):
|
if ch == ' ' or (self.sketch.dirty and self.auto_update):
|
||||||
self.watershed()
|
self.watershed()
|
||||||
self.sketch.dirty = False
|
self.sketch.dirty = False
|
||||||
if ch in [ord('a'), ord('A')]:
|
if ch in ['a', 'A']:
|
||||||
self.auto_update = not self.auto_update
|
self.auto_update = not self.auto_update
|
||||||
print('auto_update if', ['off', 'on'][self.auto_update])
|
print('auto_update if', ['off', 'on'][self.auto_update])
|
||||||
if ch in [ord('r'), ord('R')]:
|
if ch in ['r', 'R']:
|
||||||
self.markers[:] = 0
|
self.markers[:] = 0
|
||||||
self.markers_vis[:] = self.img
|
self.markers_vis[:] = self.img
|
||||||
self.sketch.show()
|
self.sketch.show()
|
||||||
|
@ -105,7 +105,7 @@ int main(int argc, const char** argv)
|
|||||||
imshow("foreground mask", fgmask);
|
imshow("foreground mask", fgmask);
|
||||||
imshow("foreground image", fgimg);
|
imshow("foreground image", fgimg);
|
||||||
|
|
||||||
char key = (char)waitKey(30);
|
char key = waitChar(30);
|
||||||
|
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user