Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Histograms of oriented gradients implementation

The previous image shows what I am getting when I run the vi and if I click cancel or close the window that appears, the PC will immediately exit labview

 

0 Kudos
Message 11 of 24
(2,442 Views)

Hello,

 

that is a strange error. I have never seen it before.

I cannot help you here, sorry.

 

I assume you installed OpenCV 2.4.5 (and added the proper folder to the system path), right?

 

What does it say if you look at the files that are generated with the error ("files that help describe the problem")?

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 12 of 24
(2,442 Views)

Untitled.png

 

0 Kudos
Message 13 of 24
(2,436 Views)

When I open the file generated with the error this is what it looks like

 

0 Kudos
Message 14 of 24
(2,435 Views)
This looks like TS3W.exe crashed.
Googling takes me to a PC game.Strange,I really don't know the cause of this???

https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 15 of 24
(2,431 Views)

you get an error from the Dell block that is called 1097, i get the same.

i got LV to crash but when i copyed the part and i copied the used files into my vi file path, the program did not crash anymore, but i do not detech anyone:-(

0 Kudos
Message 16 of 24
(2,387 Views)

Hello,

 

I will try to take a look and report back.

 

Sorry for the late reply.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 17 of 24
(2,367 Views)

Hello,

 

can you try the attached image (taken from online pedestrian database) with the following values:

 

6.12.png

 

and see if you get the same results:

 

6.12.png

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 18 of 24
(2,364 Views)

Dear Klemen,

 

the labview vi worked perfectly but without specifying the image path,when i put any other image path i receive the same image you had posted (the first one)

any ideas?

 

Thank you

 

0 Kudos
Message 19 of 24
(2,337 Views)

Hello,

 

this is how I have implemented HOG from opencv to LabView

 

typedef struct HogParams
{
	/*
    win_size – Detection window size. Align to block size and block stride.
    block_size – Block size in pixels. Align to cell size. Only (16,16) is supported for now.
    block_stride – Block stride. It must be a multiple of cell size.
    cell_size – Cell size. Only (8, 8) is supported for now.
    nbins – Number of bins. Only 9 bins per cell are supported for now.
    win_sigma – Gaussian smoothing window parameter.
    threshold_L2hys – L2-Hys normalization method shrinkage.
    gamma_correction – Flag to specify whether the gamma correction preprocessing is required or not.
    nlevels – Maximum number of detection window increases.
	derivAperture - size of extended sobel kernel (1, 3, 5, 7), for size 1 kernel 1,3 and 3,1 is used, no gaussian smoothing is done
	*/
	int32_t cellsize_width;
	int32_t cellsize_height;
	int32_t blocksize_width;
	int32_t blocksize_height;
	int32_t winsize_width;
	int32_t winsize_height;
	int32_t blockstride_x;
	int32_t blockstride_y;
	int32_t nBins;
	double win_sigma;
	double threshold_L2hys;
	int32_t gammaCorrection;
	int32_t derivAperture;
	int32_t winstride_x;
	int32_t winstride_y;
} HogParams;

typedef struct Arr1D_float
{
	int32_t dimSize;
	float Arr[1];
} Arr1D_float, **Arr1D_floatHdl;

int GetHOGFeatures(Arr1D_floatHdl FeatArrHdl, IMAQ_Image *img, HogParams *Params) //returns -1 on HOG window parameters missmatch
{
	ImageInfo *Info = NULL;
	Info = (ImageInfo*)img->address;
	CheckImage(Info, Info);

	cv::Mat GREYimg;
	GREYimg = cv::Mat(Info->yRes, Info->xRes, CV_8U, (char*)Info->imageStart, sizeof(uint8_t)*Info->pixelsPerLine);
	//cv::cvtColor(BGRAimg, GREYimg, CV_BGRA2GRAY);

	//set params into hog object
	cv::HOGDescriptor hog;
	hog.winSize = cv::Size(Params->winsize_width, Params->winsize_height);
	hog.blockSize = cv::Size(Params->blocksize_width, Params->blocksize_height);
	hog.blockStride = cv::Size(Params->blockstride_x, Params->blockstride_y);
	hog.cellSize = cv::Size(Params->cellsize_width, Params->cellsize_height);
	hog.nbins = Params->nBins;
	hog.derivAperture = Params->derivAperture;
	hog.winSigma = Params->win_sigma;
	hog.L2HysThreshold = Params->threshold_L2hys;
	hog.gammaCorrection = (Params->gammaCorrection != 0);

	MgErr error = mgNoErr;

	cv::vector<float> ders;
	cv::vector<cv::Point> locations;

	try
	{
		//winstride - step of window
		//padding - borderpadding
		//raises exception with incorrect params ... todo replace trycatch with paramchecking
		hog.compute(GREYimg, ders, cv::Size(Params->winstride_x, Params->winstride_y), cv::Size(0,0), locations);
	}
	catch(...)
	{
		return -1;
	}
	//copy out the data into LabView
	error = DSSetHandleSize(FeatArrHdl, sizeof(int32_t) + ders.size()*sizeof(float));
	memcpy((*FeatArrHdl)->Arr, ders.data(), sizeof(float)*ders.size());
	(*FeatArrHdl)->dimSize = ders.size();
	
	return error;
}

 it works allright, the checkimage function only checks some formal image parameters and sets bordersize to 0. The input image must be uchar8 bit

0 Kudos
Message 20 of 24
(2,331 Views)