MCPcopy Create free account
hub / github.com/creatale/node-dv / cvSetData

Function cvSetData

deps/opencv/modules/core/src/array.cpp:888–968  ·  view source on GitHub ↗

Assigns external data to array

Source from the content-addressed store, hash-verified

886
887// Assigns external data to array
888CV_IMPL void
889cvSetData( CvArr* arr, void* data, int step )
890{
891 int pix_size, min_step;
892
893 if( CV_IS_MAT_HDR(arr) || CV_IS_MATND_HDR(arr) )
894 cvReleaseData( arr );
895
896 if( CV_IS_MAT_HDR( arr ))
897 {
898 CvMat* mat = (CvMat*)arr;
899
900 int type = CV_MAT_TYPE(mat->type);
901 pix_size = CV_ELEM_SIZE(type);
902 min_step = mat->cols*pix_size;
903
904 if( step != CV_AUTOSTEP && step != 0 )
905 {
906 if( step < min_step && data != 0 )
907 CV_Error( CV_BadStep, "" );
908 mat->step = step;
909 }
910 else
911 mat->step = min_step;
912
913 mat->data.ptr = (uchar*)data;
914 mat->type = CV_MAT_MAGIC_VAL | type |
915 (mat->rows == 1 || mat->step == min_step ? CV_MAT_CONT_FLAG : 0);
916 icvCheckHuge( mat );
917 }
918 else if( CV_IS_IMAGE_HDR( arr ))
919 {
920 IplImage* img = (IplImage*)arr;
921
922 pix_size = ((img->depth & 255) >> 3)*img->nChannels;
923 min_step = img->width*pix_size;
924
925 if( step != CV_AUTOSTEP && img->height > 1 )
926 {
927 if( step < min_step && data != 0 )
928 CV_Error( CV_BadStep, "" );
929 img->widthStep = step;
930 }
931 else
932 {
933 img->widthStep = min_step;
934 }
935
936 img->imageSize = img->widthStep * img->height;
937 img->imageData = img->imageDataOrigin = (char*)data;
938
939 if( (((int)(size_t)data | step) & 7) == 0 &&
940 cvAlign(img->width * pix_size, 8) == step )
941 img->align = 8;
942 else
943 img->align = 4;
944 }
945 else if( CV_IS_MATND_HDR( arr ))

Callers 3

matrix.cppFile · 0.85
cvGetImageFunction · 0.85
cvCreatePyramidFunction · 0.85

Calls 3

cvReleaseDataFunction · 0.85
icvCheckHugeFunction · 0.85
cvAlignFunction · 0.85

Tested by

no test coverage detected