I'm trying few things in Halcon for the first time. But couldnt figure out, not even in the documentation, how to set the exposure for the image aquisition... my code so far is this, but my test environment is dark, and would like to brighten up the image a little bit:
open_framegrabber ('uEye', 1, 1, 0, 0, 0, 0, 'default', -1, 'default', -1, 'default', 'default', 'default', -1, -1, AcqHandle)
dev_open_window (0, 0, 500, 300, 'light gray', WindowHandleButton)
i := 0
create_bar_code_model ([], [], BarCodeHandle)
while (i < 100)
grab_image (Image, AcqHandle)
find_bar_code (Image, SymbolRegions, BarCodeHandle, 'auto', DecodedDataStrings)
get_bar_code_result (BarCodeHandle, 'all', 'decoded_types', BarCodeResults)
i:= i+1
endwhile
close_framegrabber (AcqHandle)
You can set the exposure with:
set_framegrabber_param (AcqHandle, 'exposure', 10.0)
Using Halcon assistants is an easy way of finding and setting the parameters Assistants->Open New Image Acquisition->Source(uEye)->Connect->Parameters:
You could change the parameters there and use the last tab to generate the code automatically.
Also using the example program examples/hdevelop/Image/Acquisition/ueye_parameters.hdev will give you the list of all available parameters on your camera:
Related
I'm doing my first gnome-shell extension (gnome shell 41.3) and I seem to encounter the most common problems, finding the right manual for that...
What I try to achive is...
A Widget shown (above everything) on the desktop...
Draw something into the widget...
Write some Text to the widget...
What I already acomplished is...
Using a DrawingArea and Cairo (I assume) I can use .moveTo (), .lineTo (), etc..., .stroke() to draw something into my widget...
Whe widget is displayed above everything else and stuff...
My extension has a settings widget to configure...
What I am missing is...
Any clue on how to put text in addition to the drawing stuff onto the Drawing area...
I did 1.5 days of duckduckgoing into it but, again, I'm running in circles with not a single Idea on how to proceed...
Could anyone point me into the correct direction, plz...???
Pseudo Code goes something like this
const {St, GLib} = imports.gi;
var area = new St.DrawingArea({
style_class : 'bg-color',
reactive : true,
can_focus : true,
track_hover : true,
width: myWidth,
height: myHeight
});
area.connect('repaint', (area) => drawMyStuff(area));
Main.layoutManager.addChrome(area, {
affectsInputRegion : false,
affectsStruts : false,
trackFullscreen : false,
});
timeout = GLib.timeout_add(0, 500, () => {
this.area.queue_repaint();
return true;
});
function drawMyStuff(area) {
let cr = area.get_context();
cr.translate(area.width / 2, area.height / 2);
cr.scale(area.width / 2, area.height / 2);
cr.setSourceRGBA (1, 1, 1, 1);
cr.arc(0.0, 0.0, 1.0 - 0.05, 0, 2 * Math.PI);
cr.fill();
/*
* Would like to print some text here but obviously I am to stupid to do so...
* Help me StackExchangeCommunity, you're my only hope...
*
* Obviously it is not that easy:
* cr.setSourceRGBA (1, 0, 0, 1);
* cr.write(0.0, 0.0, "Not a moon")
* cr.fill();
*
*/
cr.$dispose();
return true;
}
It's kinda hard to find out and I had no luck finding any documentation on that but after digging into the GJS Code here (https://gitlab.gnome.org/GNOME/gjs/-/blob/HEAD/modules/cairo-context.cpp) I was able to understand a lot more on how to do cairo stuff like this (https://www.cairographics.org/manual/) from GJS...
The solution for my question stated above goes like this:
function drawMyStuff(area) {
let cr = area.get_context();
cr.translate(area.width / 2, area.height / 2);
cr.scale(area.width / 2, area.height / 2);
cr.setSourceRGBA (1, 1, 1, 1);
cr.arc(0.0, 0.0, 1.0 - 0.05, 0, 2 * Math.PI);
cr.fill();
/*
* Thank me, I'm my only hope...
*
* Obviously it is that easy:
*
*/
cr.moveTo(-0.5,-0.5);
cr.setSourceRGBA (1, 0, 0, 1);
cr.setFontSize(0.125);
cr.showText('No Moon');
cr.$dispose();
return true;
}
OS: Windows 10
I have very simple GUI application in Qt. In this app I only set the window name to "tmpAppName".
Now I would like to run the second app which set the first App to foreground ( tmpAppName ).
My second App:
auto hwndAppToForeground = FindWindowExA(0,0,0,"tmpAppName");
if(!hwndAppToForeground)
{
qDebug()<<"No window with name tmpAppName";
exit(0);
}
auto foregroundWindow = GetForegroundWindow();
Sleep(5000);
if(foregroundWindow!=hwndAppToForeground)
{
SetForegroundWindow(hwndAppToForeground);
SetActiveWindow(hwndAppToForeground);
SetFocus(hwndAppToForeground);
SetWindowPos(hwndAppToForeground, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
I using Sleep(5000) because during that time I set other application in the foreground ( for example Audacity ).
The line:
SetWindowPos(hwndAppToForeground, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
is very helpfull, but I get window in the foreground but not active and when I check which window is in the foreground I get something different then "tmpAppName":
And I would like to achieve:
I'm using Embarcadero RAD Studio C++ builder XE7.
For a drawing function using the Windows GDI, I need to add a clip region to the device context of a canvas.
By testing my code, I noticed that sometimes the clipping region was smaller than the expected size. I searched why and I found a strange behavior of the OffsetRgn() function which lets me a little puzzled.
To apply the clip region, I use a code similar to the following:
std::unique_ptr<TBitmap> pBitmap(new TBitmap());
pBitmap->PixelFormat = pf32bit;
pBitmap->AlphaFormat = afDefined;
pBitmap->SetSize(60, 7);
TCanvas* pCanvas = pBitmap->Canvas;
::SelectClipRgn(pCanvas->Handle, NULL);
const TRect sourceRect = pCanvas->ClipRect;
HRGN pClipRegion = ::CreateRectRgn(50, -2, 60, 8);
::SelectClipRgn(pCanvas->Handle, pClipRegion);
const TRect intermediateRect = pCanvas->ClipRect;
const int deltaX = pCanvas->ClipRect.Left - 50;
const int deltaY = pCanvas->ClipRect.Top - (-2);
::OffsetRgn(pClipRegion, -deltaX, -deltaY);
::SelectClipRgn(pCanvas->Handle, pClipRegion);
const TRect finalRect = pCanvas->ClipRect;
NOTE written like this and out of his context, the above code does not really make sense, and I know it's illogical. Please do not judge its quality, this is not the purpose of my question. I gathered several excerpts that I grouped into an executable code putting the problem forward.
The hardcoded values are an example of values I get in my application when the problem occurs. If I execute the above code, I measure:
left = 0, top = 0, right = 60, bottom = 7 in sourceRect value
left = 50, top = 0, right = 60, bottom = 7 in intermediateRect value
left = 50, top = 0, right = 60, bottom = 6 in finalRect
I however expected that the bottom value should also be equals to 7 in finalRect, which is the canvas limit, as I only moved the region and nothing else. So why it's value become suddenly smaller than expected?
So I finally found the substance of the case. Based on this post:
Why does calling GetRgnBox on the result of GetClipRgn return a very different rect than GetClipRect?
The clip region is applied in logical units relatively to the canvas origin, whereas the clipping rectangle I tried to apply was measured in pixels from a [0, 0] origin.
As I incorrectly thought in my code that the origin was always [0, 0] for the both systems, the resulting region could be incorrect in several special cases, causing this strange shifting I sometimes noticed between the clipping really applied and which I expected.
Measuring the canvas origin with the GetWindowOrgEx() function highlighted the issue.
However for the above shown case, issue came because the clip region was moved by an offset of -2, taking so the value of -4 on top and 6 on bottom, which is then clipped to fit the canvas bounds while the clip region is applied, resulting to a clipping with value of 0 on top and 6 on bottom.
I am using Chart.js 2.0 version to draw graphs, i want to define minimum step size in bar graph
var myNewChart = new Chart(grapharea, {
type: 'bar',
data: barData,
options: {
responsive: true,
scales: {
yAxes: [
{
ticks: {
min: 0, // it is for ignoring negative step.
beginAtZero: true,
stepSize: 1 // if i use this it always set it '1', which look very awkward if it have high value e.g. '100'.
}
}
]
}
}
});
this time i am using
stepSize: 1
i am using this step size to ignore the point value e.g. '0.5', it shows when the max graph values id less e.g '2'.
if i use this it always set the step it '1', which look very awkward if it have high value e.g. '100'.
I am looking for such thing:
suggestedMin = 1
Is there any thing to define thie minimum step size which should not be fixed in higher value cases.
If you don't want to show point value (e.g. 0.5) labels you could write a callback function to filter the point value labels instead of using stepSize.
Like this:
ticks: {
min: 0, // it is for ignoring negative step.
beginAtZero: true,
callback: function(value, index, values) {
if (Math.floor(value) === value) {
return value;
}
}
}
Working fiddle here: https://jsfiddle.net/ma7h611L/
Update:
As noted by Atta H. and Lekoaf below, Chart.js added the precision property to ticks. It is available since version 2.7.3. See Lekoaf's answer how to use this.
ticks: {
precision: 0
}
This worked equally well as the callback function above and is much cleaner.
precision, if defined and stepSize is not specified, the step size will be rounded to this many decimal places.
https://www.chartjs.org/docs/latest/axes/cartesian/linear.html
I have a set of objects grouped with Raphael.set(). What I want to do is to move the whole set (change x and y coordinates) from one place to another.
How I can move the whole set as a single object?
What I found already is that when an .attr({X: newX, Y: newY}) is called every element from the set will be positioned on this coordinated which will result in piling all the elements in one place.
Edit: Refer to Rick Westera's answer as translate is now deprecated.
Use .translate(x, y), example:
var paper = Raphael('stage', 300, 300);
var set = paper.set();
set.push(paper.rect(0,0,30,50));
set.push(paper.circle(40,50,10));
set.push(paper.path("M 0 70 L 100 70"));
set.translate(100, 100);
http://jsfiddle.net/q4vUx/
Use transform('Tx,y') as translate is deprecated. For example:
var paper = Raphael('stage', 300, 300);
var set = paper.set();
set.push(paper.rect(0, 0, 100, 100));
set.push(paper.text(50, 50, "Foo"));
set.transform("T100,50");
Note that there are two types of translation:
'T100,50' will move the set 100px to the right and 50 down using the global axis.
't100,50' will do the same but using the set's local axis (ie. it depends on which way the set has been rotated).
This is what i'm using to reposition a set, in my case is a set of fonts returned by Paper.print() but i think it should work with any kind of set.
var glyphs = paper.print(0, 0, text, paper.getFont(font, 800), fontSize).hide();
glyphs.transform('...T' + [posx, posy] + 'R' + [angle, posx, posy]).show();
hope it helps.