HoughLineP Segmentation Fault OpenCV - qt

I am using Unix and delevoped a program that run without problems under Windows.
When running under unix I get a segmentation fault at the HoughlineP operation:
vector lines;
HoughLinesP(image, lines, 1, CV_PI/180, a, b, c );
variables a, b, c are decleared in the constructor and later on changed by some sliders of the gui.
vector lines is empty and should be filled by the HoughlinesP function but liked described the function fails.
Is this a special unix problem?
I haven't find any solutions on the web?
imageanlyzer.h:
vector<Vec4i> m_lines;
ImageAnalyzer::ImageAnalyzer(QObject *parent) : QObject(parent)
{
m_performAnalysis = false;
m_lowThresh = 74;
m_rho = 1;
m_highThresh = 205;
m_threshold = 20;
m_minLineLength = 16;
m_maxLineGap = 16;
m_blurSize = 3;
m_adptTreshSize = 33;
m_dilationSize = 1;
m_erodeSize = 1;
m_adptTreshC = -15;
m_heading = 260;
m_matchingValue = 0;
}
the problem occurs here:
void ImageAnalyzer::extractLines()
{
// Probalistic Hough Transform
HoughLinesP(getCanny4HoughImg(), m_lines, (double)m_rho, CV_PI/180, m_threshold, (double)m_minLineLength, (double)m_maxLineGap);
}
The getCanny4HoughImg() returns in image. I checked the this already.

Related

Add Toggle On/Off button to a .mq4 indicator

Could someone tell me how to add an ON/OFF button on this gap finder indicator I've recently modified?
I'm an amateur noobie programmer and I can only code basic things and this is getting pretty challenging for me.
I've tried to integrate and modify part of other codes with buttons template but no way.
This are the indicators inputs which are customizable
Indicator Input Parameters
This is how it prints gaps on charts
Indicator on chart
CODE
#property indicator_chart_window
#property indicator_buffers 1
#property description "Automatically render boxes for liquidity gaps "
#property indicator_color1 Black
extern double Gap_Size_Minimum = 100;
extern int ExtendBars = 1000;
extern int History = 1000;
extern color Gap_Up = Aqua;
extern color Gap_Down = Tomato;
input ENUM_LINE_STYLE Rectangle_Style = STYLE_SOLID;
double Pip;
int init()
{
Pip = Point;
if(Digits==3 || Digits==5) Pip = 10*Point;
return(0);
}
int deinit()
{
string ObjName;
for(int i = ObjectsTotal()-1; i>=0; i--)
{
ObjName = ObjectName(i);
if(StringFind(ObjName,"liquidity_gaps",0)>=0)
ObjectDelete(ObjName);
}
return(0);
}
int start()
{
int i, limit, counted_bars=IndicatorCounted();
limit = MathMin(History,Bars-counted_bars-1);
string ObjName;
for(i=limit; i>=0; i--)
{
if(i>Bars-2) continue;
if(MathAbs(Open[i]-Close[i+1]) > Gap_Size_Minimum*Pip)
{
ObjName = "liquidity_gaps_Up_"+Time[i];
color ObjColor;
if(Open[i] > Close[i+1]) ObjColor = Gap_Up;
else ObjColor = Gap_Down;
if(ObjectFind(ObjName)<0)
{
ObjectCreate(ObjName,OBJ_RECTANGLE,0,Time[i+1],Close[i+1],Time[i],Open[i]);
ObjectSet(ObjName,OBJPROP_BACK,0);
ObjectSet(ObjName,OBJPROP_COLOR,ObjColor);
ObjectSet(ObjName,OBJPROP_STYLE,Rectangle_Style);
}
}
//datetime thistime = Time[i];
int ib = i+ExtendBars;
while(ib>=0)
{
ObjName = "liquidity_gaps_Up_"+Time[ib];
if(ObjectFind(ObjName)>=0)
{
double pr2 = ObjectGet(ObjName,OBJPROP_PRICE2);
double pr1 = ObjectGet(ObjName,OBJPROP_PRICE2);
ObjectSet(ObjName,OBJPROP_TIME2,Time[i]);
ObjectSet(ObjName,OBJPROP_PRICE2,pr2);
}
ib--;
}
}
return(0);
}
Indicator download for MT4
Thanks in advance for you kind help

How to flatten nginx buffer chain?

I'm trying to take an nginx buffer chain and work with it in some experimental code. In order to do so, I need to first flatten the chain into a single block of memory. Here's what I've got so far (actual production code is a bit different, so this is untested):
u_char *flatten_chain(ngx_chain_t *out) {
off_t bsize;
ngx_chain_t *out_ptr;
u_char *ret, *ret_ptr;
uint64_t flattenSize = 0;
out_ptr = out;
while (out_ptr) {
if(!out_ptr->buf->in_file) {
bsize = ngx_buf_size(out_ptr->buf);
flattenSize += bsize;
}
out_ptr = out_ptr->next;
}
ret = malloc(flattenSize);
ret_ptr = ret;
out_ptr = out;
while (out_ptr) {
bsize = ngx_buf_size(out_ptr->buf);
if(!out_ptr->buf->in_file) {
memcpy(ret_ptr, out_ptr->buf->pos, (size_t)bsize);
ret_ptr += bsize;
}
out_ptr = out_ptr->next;
}
return(ret);
}
However, it doesn't seem to work. Disclaimer: it's possible that it does work and my data is getting corrupted somewhere else... but while I look into that, can someone please confirm or deny that the above should work?
Thanks!

abc PDF generate a blank page on IIS

I am creating an PDF from HTML using ABC PDF 8.0, it works well on my local end but generate a blank page on IIS, I already down grade IE, and provide the all permission to folder. When I tried to generate the PDF through any external link like Google.com it works perfectly. more over my link is accessible and there is no error on the page. please find below the code for your reference.
var url="test.com"
if (XSettings.InstallLicense(abcPDFkey))
{
using (Doc theDoc = new Doc())
{
//apply a rotation transform
double w = theDoc.MediaBox.Width;
double h = theDoc.MediaBox.Height;
double l = theDoc.MediaBox.Left;
double b = theDoc.MediaBox.Bottom;
theDoc.Transform.Rotate(90, l, b);
theDoc.Transform.Translate(w, 0);
// To fix time out
theDoc.HtmlOptions.RetryCount = 1;
theDoc.HtmlOptions.Timeout = 25000;
// rotate our rectangle
theDoc.Rect.Width = h;
theDoc.Rect.Height = w;
theDoc.HtmlOptions.Engine = EngineType.Gecko;
theDoc.HtmlOptions.ImageQuality = 60;
int theID;
theID = theDoc.AddImageUrl(url);
while (true)
{
theDoc.FrameRect();
if (!theDoc.Chainable(theID))
break;
theDoc.Page = theDoc.AddPage();
theID = theDoc.AddImageToChain(theID);
int NewtheID = theDoc.GetInfoInt(theDoc.Root, "Pages");
theDoc.SetInfo(NewtheID, "/Rotate", "90");
}
for (int i = 1; i <= theDoc.PageCount; i++)
{
theDoc.PageNumber = i;
theDoc.Flatten();
}
foreach (IndirectObject io in theDoc.ObjectSoup)
{
if (io is PixMap)
{
PixMap pm = (PixMap)io;
pm.Realize(); // eliminate indexed color images
pm.Resize(pm.Width / 6, pm.Height / 6);
}
}
theDoc.Save(System.Web.HttpContext.Current.Server.MapPath("PDFFileName"));
theDoc.Clear();
}
Please help, thanks
Ok, I figured out what was the issue.
First of all I define the relative path for all my Images, and secondly Our server have internal IP, I define the URL for internal IP instead of public domain. that fix my issue..
cheers !!

Negotiating an allocator between Directshow filters fails

I'm developing a custom Directshow source filter to provide decompressed video data to a rendering filter. I've used the PushSource sample provided by the Directshow SDK as a basis for my filter. I'm attempting to connect this to a VideoMixingRenderer9 filter.
When creating the graph I'm calling ConnectDirect():
HRESULT hr = mp_graph_builder->ConnectDirect(OutPin, InPin, &mediaType);
but during this call, calling SetProperties on the downstream filters allocator (in DecideBufferSize()), fails with D3DERR_INVALIDCALL (0x8876086c):
ALLOCATOR_PROPERTIES actual;
memset(&actual,0,sizeof(actual));
hr = pAlloc->SetProperties(pRequest, &actual);
If I let it try to use my allocator (the one provided by CBaseOutputPin) when setting the allocator on the downstream filter, this fails with E_FAIL (in CBaseOutputPin::DecideAllocator)
hr = pPin->NotifyAllocator(*ppAlloc, FALSE);
Any help would be much appreciated!
Thanks.
EDIT:
This is the media type provided by GetMediaType
VIDEOINFOHEADER *pvi = (VIDEOINFOHEADER*)pMediaType->AllocFormatBuffer(sizeof(VIDEOINFOHEADER));
if (pvi == 0)
return(E_OUTOFMEMORY);
ZeroMemory(pvi, pMediaType->cbFormat);
pvi->AvgTimePerFrame = m_rtFrameLength;
pMediaType->formattype = FORMAT_VideoInfo;
pMediaType->majortype = MEDIATYPE_Video;
pMediaType->subtype = MEDIASUBTYPE_RGB24;
pMediaType->bTemporalCompression = FALSE;
pMediaType->bFixedSizeSamples = TRUE;
pMediaType->formattype = FORMAT_VideoInfo;
pvi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pvi->bmiHeader.biWidth = (640 / 128 + 1) * 128;
pvi->bmiHeader.biHeight = -480; // negative so top down..
pvi->bmiHeader.biPlanes = 1;
pvi->bmiHeader.biBitCount = 24;
pvi->bmiHeader.biCompression = NULL; // ok if rgb else use MAKEFOURCC(...)
pvi->bmiHeader.biSizeImage = GetBitmapSize(&pvi->bmiHeader);
pvi->bmiHeader.biClrImportant = 0;
pvi->bmiHeader.biClrUsed = 0; //Use max colour depth
pvi->bmiHeader.biXPelsPerMeter = 0;
pvi->bmiHeader.biYPelsPerMeter = 0;
SetRectEmpty(&(pvi->rcSource));
SetRectEmpty(&(pvi->rcTarget));
pvi->rcSource.bottom = 480;
pvi->rcSource.right = 640;
pvi->rcTarget.bottom = 480;
pvi->rcTarget.right = 640;
pMediaType->SetType(&MEDIATYPE_Video);
pMediaType->SetFormatType(&FORMAT_VideoInfo);
pMediaType->SetTemporalCompression(FALSE);
const GUID SubTypeGUID = GetBitmapSubtype(&pvi->bmiHeader);
pMediaType->SetSubtype(&SubTypeGUID);
pMediaType->SetSampleSize(pvi->bmiHeader.biSizeImage);
and DecideBufferSize where pAlloc->SetProperties is called
HRESULT CPushPinBitmap::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pRequest) {
HRESULT hr;
CAutoLock cAutoLock(CBasePin::m_pLock);
CheckPointer(pAlloc, E_POINTER);
CheckPointer(pRequest, E_POINTER);
if (pRequest->cBuffers == 0) {
pRequest->cBuffers = 2;
}
pRequest->cbBuffer = 480 * ( (640 / 128 + 1) * 128 ) * 3;
ALLOCATOR_PROPERTIES actual;
memset(&actual,0,sizeof(actual));
hr = pAlloc->SetProperties(pRequest, &actual);
if (FAILED(hr)) {
return hr;
}
if (actual.cbBuffer < pRequest->cbBuffer) {
return E_FAIL;
}
return S_OK;
}
The constants are only temporary!
There is no way you can use your own allocator with VMR/EVR filters. They just insist on their own, which in turn is backed on DirectDraw/Direct3D surfaces.
To connect directly to VMR/EVR filters you need a different strategy. The allocator is always theirs. You need to support extended strides. See Handling Format Changes from the Video Renderer.

Declaring variables for limited scope at the head of the for loop

In Java, you sometimes do something like this:
for (int a = 1, b = 2; b < high;) {
if (b % 2 == 0) {
result += b;
}
int tmp = b;
b = a + b;
a = tmp;
}
Here, I used a for loop instead of a while loop to limit the scope of a and b.
But how can I achieve this in JavaFX? The for loop doesn't seem to offer this possibility. Do I have to use a while loop?
You could use the Java trick of anonymous blocks:
var high = 10;
{
var a = 0;
for (b in [1..high-1]) {
// this is fine
println("{a}");
}
}
// won't compile here
//println("{a}");
The are simmilar expressions in JavaFX but with those expressions you will get a double loop. According to this doc.

Resources