/* replaces one contour with another */ CV_IMPL void cvSubstituteContour( CvContourScanner scanner, CvSeq * new_contour ) { _CvContourInfo *l_cinfo; CV_FUNCNAME( "cvSubstituteContour" ); __BEGIN__; if( !scanner ) CV_ERROR( CV_StsNullPtr, "" ); l_cinfo = scanner->l_cinfo; if( l_cinfo && l_cinfo->contour && l_cinfo->contour != new_contour ) { l_cinfo->contour = new_contour; scanner->subst_flag = 1; } __END__; }
void CvMatrix::save( const char* filename, const char* matname ) { CV_FUNCNAME( "CvMatrix::write" ); __BEGIN__; if( !matrix ) return; if( icvIsXmlOrYaml( filename ) ) cvSave( filename, matrix, matname ); else { if( save_image ) save_image( filename, matrix ); else CV_ERROR( CV_StsNotImplemented, "Saving a matrixe in such a format requires HigGUI.\n" "Link it to your program and call any function from it\n" ); } __END__; }
CV_IMPL const char* cvGetWindowName( void* window_handle ) { const char* window_name = ""; CV_FUNCNAME( "cvGetWindowName" ); __BEGIN__; CvWindow* window; if( window_handle == 0 ) CV_ERROR( CV_StsNullPtr, "NULL window" ); window = icvWindowByHWND( (HWND)window_handle ); if( window ) window_name = window->name; __END__; return window_name; }
CV_IMPL void cvReleaseImage( IplImage ** image ) { CV_FUNCNAME( "cvReleaseImage" ); __BEGIN__ if( !image ) CV_ERROR( CV_StsNullPtr, "" ); if( *image ) { IplImage* img = *image; *image = 0; cvReleaseData( img ); cvReleaseImageHeader( &img ); } __END__; }
CV_IMPL const char* cvGetWindowName( void* window_handle ) { const char* window_name = ""; CV_FUNCNAME( "cvGetWindowName" ); __BEGIN__; CvWindow* window = 0; if( window_handle == 0 ) CV_ERROR( CV_StsNullPtr, "NULL window" ); // window = TODO: find window by handle if( window ) window_name = window->name; __END__; return 0; }
/** \internal \fn bool wrprDeviceIsValid( gige::IDevice& device ) \brief Wrapper to GigEVisionAPI function IDevice::Connect() \param device - selected device \return true - device valid */ bool wrprDeviceIsValid( gige::IDevice& device ) { bool b_ret = device != NULL; CV_FUNCNAME("wrprDeviceIsConnect"); __BEGIN__; if(b_ret) { try { b_ret = device.IsValid (); } catch (...) { CV_ERROR(CV_StsError, "GigEVisionAPI: API device validation state (from IsValid()) failed.\n"); b_ret = false; } } __END__; return (b_ret); }
CV_IMPL void* cvGetWindowHandle( const char* window_name ) { void* hwnd = 0; CV_FUNCNAME( "cvGetWindowHandle" ); __BEGIN__; CvWindow* window; if( window_name == 0 ) CV_ERROR( CV_StsNullPtr, "NULL window name" ); window = icvFindWindowByName( window_name ); if( window ) hwnd = (void*)window->hwnd; __END__; return hwnd; }
CV_IMPL void cvMoveWindow( const char* name, int x, int y ) { CV_FUNCNAME( "cvMoveWindow" ); __BEGIN__; CvWindow* window; RECT rect; if( !name ) CV_ERROR( CV_StsNullPtr, "NULL name" ); window = icvFindWindowByName(name); if(!window) EXIT; GetWindowRect( window->frame, &rect ); MoveWindow( window->frame, x, y, rect.right - rect.left, rect.bottom - rect.top, TRUE); __END__; }
CV_IMPL void cvSetMouseCallback( const char* window_name, CvMouseCallback on_mouse, void* param ) { CV_FUNCNAME( "cvSetMouseCallback" ); __BEGIN__; CvWindow* window = 0; if( !window_name ) CV_ERROR( CV_StsNullPtr, "NULL window name" ); window = icvFindWindowByName(window_name); if( !window ) EXIT; window->on_mouse = on_mouse; window->on_mouse_param = param; __END__; }
void CvANN_MLP::set_activ_func( int _activ_func, double _f_param1, double _f_param2 ) { CV_FUNCNAME( "CvANN_MLP::set_activ_func" ); __BEGIN__; if( _activ_func < 0 || _activ_func > GAUSSIAN ) CV_ERROR( CV_StsOutOfRange, "Unknown activation function" ); activ_func = _activ_func; switch( activ_func ) { case SIGMOID_SYM: max_val = 0.95; min_val = -max_val; max_val1 = 0.98; min_val1 = -max_val1; if( fabs(_f_param1) < FLT_EPSILON ) _f_param1 = 2./3; if( fabs(_f_param2) < FLT_EPSILON ) _f_param2 = 1.7159; break; case GAUSSIAN: max_val = 1.; min_val = 0.05; max_val1 = 1.; min_val1 = 0.02; if( fabs(_f_param1) < FLT_EPSILON ) _f_param1 = 1.; if( fabs(_f_param2) < FLT_EPSILON ) _f_param2 = 1.; break; default: min_val = max_val = min_val1 = max_val1 = 0.; _f_param1 = 1.; _f_param2 = 0.; } f_param1 = _f_param1; f_param2 = _f_param2; __END__; }
OPENCVAPI CvSize cvGetSize( const CvArr* arr ) { CvSize size = { 0, 0 }; CV_FUNCNAME( "cvGetSize" ); __BEGIN__; if( _CV_IS_ARR( arr )) { CvMat *mat = (CvMat*)arr; size.width = mat->width; size.height = mat->height; } else if( _CV_IS_IMAGE( arr )) { IplImage* img = (IplImage*)arr; if( img->roi ) { size.width = img->roi->width; size.height = img->roi->height; } else { size.width = img->width; size.height = img->height; } } else { CV_ERROR( CV_StsBadArg, "Parameter of cvGetSize is neither CvMat nor IplImage" ); } __END__; return size; }
CV_IMPL IplImage* cvCloneImage( const IplImage* src ) { IplImage* dst = 0; CV_FUNCNAME( "cvCloneImage" ); __BEGIN__; if( !_CV_IS_IMAGE( src )) CV_ERROR( CV_StsBadArg, "Bad image header" ); if( !CvIPL.cloneImage ) { CV_CALL( dst = (IplImage*)cvAlloc( sizeof(*dst))); memcpy( dst, src, sizeof(*src)); dst->roi = 0; if( src->roi ) { dst->roi = icvCreateROI( src->roi->coi, src->roi->xOffset, src->roi->yOffset, src->roi->width, src->roi->height ); } if( src->imageData ) { int size = src->imageSize; cvCreateData( dst ); memcpy( dst->imageData, src->imageData, size ); } } else { dst = CvIPL.cloneImage( src ); } __END__; return dst; }
CV_IMPL void cvShowImage( const char* name, const CvArr* arr ) { CV_FUNCNAME( "cvShowImage" ); __BEGIN__; CvWindow* window; if( !name ) CV_ERROR( CV_StsNullPtr, "NULL name" ); CV_LOCK_MUTEX(); window = icvFindWindowByName(name); if(!window) { cvNamedWindow(name, 1); window = icvFindWindowByName(name); } if( window && arr ) { #ifdef HAVE_OPENGL if (window->useGl) { cv::imshow(name, cv::cvarrToMat(arr)); return; } #endif CvImageWidget * image_widget = CV_IMAGE_WIDGET( window->widget ); cvImageWidgetSetImage( image_widget, arr ); } CV_UNLOCK_MUTEX(); __END__; }
/** \internal \fn bool wrprDeviceDisconnect ( gige::IDevice& device ) \brief Wrapper to GigEVisionAPI function IDevice::Disconnect() \param device - selected device \return true - device valid */ bool wrprDeviceDisconnect ( gige::IDevice& device ) { bool b_ret = device != NULL; CV_FUNCNAME("wrprDeviceDisconnect"); __BEGIN__; if(b_ret) { try { device->Disconnect (); } catch (...) { CV_ERROR(CV_StsError, "GigEVisionAPI: API device disconnect (from Disconnect()) failed.\n"); b_ret = false; } } __END__; return (b_ret); }
const CvMat* CvMLData::get_var_idx() { CV_FUNCNAME( "CvMLData::get_var_idx" ); __BEGIN__; int avcount = 0; if ( !values ) CV_ERROR( CV_StsInternal, "data is empty" ); assert( var_idx_mask ); avcount = cvFloor( cvNorm( var_idx_mask, 0, CV_L1 ) ); int* vidx; if ( avcount == values->cols ) return 0; if ( !var_idx_out || ( var_idx_out && var_idx_out->cols != avcount ) ) { cvReleaseMat( &var_idx_out ); var_idx_out = cvCreateMat( 1, avcount, CV_32SC1); if ( response_idx >=0 ) var_idx_mask->data.ptr[response_idx] = 0; } vidx = var_idx_out->data.i; for(int i = 0; i < var_idx_mask->cols; i++) if ( var_idx_mask->data.ptr[i] ) { *vidx = i; vidx++; } __END__; return var_idx_out; }
CV_IMPL CvRect cvGetImageROI( const IplImage* img ) { CvRect rect = { 0, 0, 0, 0 }; CV_FUNCNAME( "cvGetImageROI" ); __BEGIN__; if( !img ) CV_ERROR( IPL_StsNullPtr, "Null pointer to image" ); if( img->roi ) rect = cvRect( img->roi->xOffset, img->roi->yOffset, img->roi->width, img->roi->height ); else rect = cvRect( 0, 0, img->width, img->height ); __END__; return rect; }
CV_IMPL void cvImgToObs_DCT( const void* arr, float *obs, CvSize dctSize, CvSize obsSize, CvSize delta ) { CV_FUNCNAME( "cvImgToObs_DCT" ); __BEGIN__; CvMat stub, *mat = (CvMat*)arr; CV_CALL( mat = cvGetMat( arr, &stub )); if( CV_ARR_TYPE( mat->type ) != CV_8UC1 ) CV_ERROR( CV_StsUnsupportedFormat, "" ); IPPI_CALL( icvImgToObs_DCT_8u32f_C1R( (uchar*)mat->data.ptr, mat->step, icvGetMatSize(mat), obs, dctSize, obsSize, delta )); __END__; }
const CvMat* CvMLData::get_var_types() { CV_FUNCNAME( "CvMLData::get_var_types" ); __BEGIN__; uchar *var_types_out_ptr = 0; int avcount, vt_size; if ( !values ) CV_ERROR( CV_StsInternal, "data is empty" ); assert( var_idx_mask ); avcount = cvFloor( cvNorm( var_idx_mask, 0, CV_L1 ) ); vt_size = avcount + (response_idx >= 0); if ( avcount == values->cols || (avcount == values->cols-1 && response_idx == values->cols-1) ) return var_types; if ( !var_types_out || ( var_types_out && var_types_out->cols != vt_size ) ) { cvReleaseMat( &var_types_out ); var_types_out = cvCreateMat( 1, vt_size, CV_8UC1 ); } var_types_out_ptr = var_types_out->data.ptr; for( int i = 0; i < var_types->cols; i++) { if (i == response_idx || !var_idx_mask->data.ptr[i]) continue; *var_types_out_ptr = var_types->data.ptr[i]; var_types_out_ptr++; } if ( response_idx >= 0 ) *var_types_out_ptr = var_types->data.ptr[response_idx]; __END__; return var_types_out; }
/* retrieves next point of the chain curve and updates reader */ CV_IMPL CvPoint cvReadChainPoint( CvChainPtReader * reader ) { char *ptr; int code; CvPoint pt = { 0, 0 }; CV_FUNCNAME( "cvReadChainPoint" ); __BEGIN__; if( !reader ) CV_ERROR( CV_StsNullPtr, "" ); pt = reader->pt; ptr = reader->ptr; if( ptr ) { code = *ptr++; if( ptr >= reader->block_max ) { cvChangeSeqBlock( (CvSeqReader *) reader, 1 ); ptr = reader->ptr; } reader->ptr = ptr; reader->code = (char)code; assert( (code & ~7) == 0 ); reader->pt.x = pt.x + icvCodeDeltas[code].x; reader->pt.y = pt.y + icvCodeDeltas[code].y; } __END__; return pt; }
CV_IMPL void cvResizeWindow(const char* name, int width, int height ) { CV_FUNCNAME( "cvResizeWindow" ); __BEGIN__; int i; CvWindow* window; RECT rmw, rw, rect; if( !name ) CV_ERROR( CV_StsNullPtr, "NULL name" ); window = icvFindWindowByName(name); if(!window) EXIT; // Repeat two times because after the first resizing of the mainhWnd window // toolbar may resize too for(i = 0; i < (window->toolbar.toolbar ? 2 : 1); i++) { rw = icvCalcWindowRect(window); MoveWindow(window->hwnd, rw.left, rw.top, rw.right - rw.left + 1, rw.bottom - rw.top + 1, FALSE); GetClientRect(window->hwnd, &rw); GetWindowRect(window->frame, &rmw); // Resize the mainhWnd window in order to make the bitmap fit into the child window MoveWindow(window->frame, rmw.left, rmw.top, rmw.right - rmw.left + width - rw.right + rw.left, rmw.bottom - rmw.top + height - rw.bottom + rw.top, TRUE); } rect = icvCalcWindowRect(window); MoveWindow(window->hwnd, rect.left, rect.top, rect.right - rect.left + 1, rect.bottom - rect.top + 1, TRUE); __END__; }
void releaseBGMeanStatModel( BGMeanStatModel** _model ){ CV_FUNCNAME( "releaseBGMeanStatModel" ); __BEGIN__; if( !_model ) CV_ERROR( CV_StsNullPtr, "" ); if( *_model ){ BGMeanStatModel* model = *_model; cvFree( &model->frame_cbuffer ); cvFree( &model->mean ); cvFree( &model->std_dev ); cvReleaseImage( &model->foreground ); cvReleaseImage( &model->background ); cvReleaseMemStorage(&model->storage); cvFree( _model ); } __END__; }
CV_IMPL void cvMoveWindow( const char* name, int x, int y ) { CV_FUNCNAME( "cvMoveWindow" ); __BEGIN__; CvWindow* window; if( !name ) CV_ERROR( CV_StsNullPtr, "NULL name" ); window = icvFindWindowByName(name); if(!window) EXIT; CV_LOCK_MUTEX(); gtk_window_move( GTK_WINDOW(window->frame), x, y ); CV_UNLOCK_MUTEX(); __END__; }
double cvGetPropWindowAutoSize_GTK(const char* name) { double result = -1; CV_FUNCNAME( "cvGetPropWindowAutoSize_GTK" ); __BEGIN__; CvWindow* window; if (!name) CV_ERROR( CV_StsNullPtr, "NULL name string" ); window = icvFindWindowByName( name ); if (!window) EXIT; // keep silence here result = window->flags & CV_WINDOW_AUTOSIZE; __END__; return result; }
double cvGetRatioWindow_GTK(const char* name) { double result = -1; CV_FUNCNAME( "cvGetRatioWindow_GTK" ); __BEGIN__; CvWindow* window; if (!name) CV_ERROR( CV_StsNullPtr, "NULL name string" ); window = icvFindWindowByName( name ); if (!window) EXIT; // keep silence here result = static_cast<double>(window->widget->allocation.width) / window->widget->allocation.height; __END__; return result; }
CV_IMPL CvMat* cvCloneMat( const CvMat* src ) { CvMat* dst = 0; CV_FUNCNAME( "cvCloneMat" ); __BEGIN__; if( !_CV_IS_ARR( src )) CV_ERROR( CV_StsBadArg, "Bad CvMat header" ); CV_CALL( dst = cvCreateMatHeader( src->height, src->width, src->type )); if( src->data.ptr ) { CV_CALL( cvCreateData( dst )); CV_CALL( cvCopy( src, dst )); } __END__; return dst; }
const CvMat* CvMLData::get_responses() { CV_FUNCNAME( "CvMLData::get_responses_ptr" ); __BEGIN__; int var_count = 0; if ( !values ) CV_ERROR( CV_StsInternal, "data is empty" ); var_count = values->cols; if ( response_idx < 0 || response_idx >= var_count ) return 0; if ( !response_out ) response_out = cvCreateMatHeader( values->rows, 1, CV_32FC1 ); else cvInitMatHeader( response_out, values->rows, 1, CV_32FC1); cvGetCol( values, response_out, response_idx ); __END__; return response_out; }
CV_IMPL CvScalar cvSum( const CvArr* arr ) { CvScalar sum = {{0,0,0,0}}; CV_FUNCNAME("cvSum"); assert(false); __BEGIN__; //int type, coi = 0; //int mat_step; //CvSize size; //CvMat stub, ; CvMat *mat = (CvMat*)arr; if(CV_IS_IMAGE(arr)) { sum = icvSumIplImage((const IplImage*)arr); EXIT; } else if(CV_IS_MAT(mat)) { if( CV_IS_MATND(mat) ) { CV_ERROR( CV_StsBadArg, "Only mat are supported here" ); EXIT; } sum = icvSumMat(mat); EXIT; } __END__; return sum; }
CV_IMPL void cvDestroyWindow( const char* name ) { CV_FUNCNAME( "cvDestroyWindow" ); __BEGIN__; CvWindow* window; HWND mainhWnd; if(!name) CV_ERROR( CV_StsNullPtr, "NULL name string" ); window = icvFindWindowByName( name ); if( !window ) EXIT; mainhWnd = window->frame; SendMessage(window->hwnd, WM_CLOSE, 0, 0); SendMessage( mainhWnd, WM_CLOSE, 0, 0); // Do NOT call _remove_window -- CvWindow list will be updated automatically ... __END__; }
CV_IMPL void cvShowImage( const char* name, const CvArr* arr ) { CV_FUNCNAME( "cvShowImage" ); __BEGIN__; CvWindow* window; if( !name ) CV_ERROR( CV_StsNullPtr, "NULL name" ); CV_LOCK_MUTEX(); window = icvFindWindowByName(name); if( window && arr ){ CvImageWidget * image_widget = CV_IMAGE_WIDGET( window->widget ); cvImageWidgetSetImage( image_widget, arr ); } CV_UNLOCK_MUTEX(); __END__; }
void CvMLData::mix_train_and_test_idx() { CV_FUNCNAME( "CvMLData::mix_train_and_test_idx" ); __BEGIN__; if ( !values ) CV_ERROR( CV_StsInternal, "data is empty" ); __END__; if ( !sample_idx) return; if ( train_sample_count > 0 && train_sample_count < values->rows ) { int n = values->rows; for (int i = 0; i < n; i++) { int a = (*rng)(n); int b = (*rng)(n); int t; CV_SWAP( sample_idx[a], sample_idx[b], t ); } } }