View with center and corners
Forum rules
'+1' posts are welcome in this area of the forums to indicate your support for a particular feature suggestion. Suggestions that get the most +1's will be seriously considered for inclusion in future versions of SharpCap.
'+1' posts are welcome in this area of the forums to indicate your support for a particular feature suggestion. Suggestions that get the most +1's will be seriously considered for inclusion in future versions of SharpCap.
-
- Posts: 503
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: View with center and corners
Hello Robin,
Thanks for the explanation (Dispose() and BeginnInvoke). I will try it in the next days (or nights).
I tried yesterday the frame.ChangeBitDepth(8) function ... but without success.
And without success too ... it was not possible to use the stretch.
Jean-Francois
Thanks for the explanation (Dispose() and BeginnInvoke). I will try it in the next days (or nights).
I tried yesterday the frame.ChangeBitDepth(8) function ... but without success.
And without success too ... it was not possible to use the stretch.
Jean-Francois
- admin
- Site Admin
- Posts: 14257
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: View with center and corners
Hi Jean-Francois,
remember that those functions (change bit depth, display stretch) do not change the frame itself - they return a new frame that has the changes applied to it. Maybe that is the issue?
cheers,
Robin
remember that those functions (change bit depth, display stretch) do not change the frame itself - they return a new frame that has the changes applied to it. Maybe that is the issue?
cheers,
Robin
-
- Posts: 503
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: View with center and corners
Hello Robin,
Yes, that should be the problem ... I tested the following:
Jean-Francois
Yes, that should be the problem ... I tested the following:
Code: Select all
frame = frame.DisplayTransform(stretch)
or
frame = args.Frame.ChangeBitDepth(8)
-
- Posts: 503
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: View with center and corners
Hello,
I have now a new version.
It can show 8 or 16 bits images.
In addition, it is possible to change the gamma value with a slider.
I wanted a triple slider. But I do not found how to do.
It is now a single slider for changing the gamma value (= middle point of the histogram).
Regards,
Jean-Francois
I have now a new version.
It can show 8 or 16 bits images.
In addition, it is possible to change the gamma value with a slider.
Code: Select all
# *******************************************************************************************
# SharpCap script "Nine_zone.py"
# 2024/08/31 Jean-Francois
#
# Version: 2.0.0: Lot of correction. Now 8 and 16 bit MONO, Gamma setting.
# Version: 1.0.0: First version
#
# The script works only with a SharpCap PRO version.
# *******************************************************************************************
import os
import math
import clr
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
import System.Drawing
import System.Windows.Forms
from System import Array, EventHandler
from System.Drawing import *
from System.Windows.Forms import *
from System.Threading import Thread, ApartmentState, ParameterizedThreadStart
from SharpCap.Base import Interfaces
H = SharpCap.SelectedCamera.Controls.Resolution.CaptureArea.Height
W = SharpCap.SelectedCamera.Controls.Resolution.CaptureArea.Width
Boxsize = 100
bH = Boxsize
bW = Boxsize
Rect_1 = Rectangle(0, 0, bW, bH)
Rect_2 = Rectangle((W-bW)//2, 0, bW, bH)
Rect_3 = Rectangle(W - bW, 0, bW, bH)
Rect_4 = Rectangle(0, (H-bH)//2, bW, bH)
Rect_5 = Rectangle((W-bW)//2, (H-bH)//2, bW, bH)
Rect_6 = Rectangle(W - bW, (H-bH)//2, bW, bH)
Rect_7 = Rectangle(0, H - bH, bW, bH)
Rect_8 = Rectangle((W-bW)//2, H - bH, bW, bH)
Rect_9 = Rectangle(W - bW, H - bH, bW, bH)
stretch_gamma = 0.5
colour_space = SharpCap.SelectedCamera.Controls.ColourSpace.Value
def Show_picture_box(bmp):
form_nine_zone.pictureBox1.Image = bmp
def framehandler(sender, args):
global stretch_gamma, colour_space
if (dumpdata):
try:
stretch = Interfaces.ReciprocalLevelStretch(0.0, stretch_gamma, 1.0, False)
if (colour_space == 'MONO16' or colour_space == 'RAW16'):
frame = args.Frame.ChangeBitDepth(8).DisplayTransform(stretch).GetFrameBitmap()
else:
frame = args.Frame.DisplayTransform(stretch).GetFrameBitmap()
bitmap = Bitmap(3 * bW + 2, 3 * bH + 2)
gr = Graphics.FromImage(bitmap)
gr.DrawImage(frame, Rectangle( 0, 0, bW, bH), Rect_1, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( bW + 1, 0, bW, bH), Rect_2, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle(2*bW + 2, 0, bW, bH), Rect_3, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( 0, bH + 1, bW, bH), Rect_4, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( bW + 1, bH + 1, bW, bH), Rect_5, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle(2*bW + 2, bH + 1, bW, bH), Rect_6, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( 0, 2*bH + 2, bW, bH), Rect_7, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( bW + 1, 2*bH + 2, bW, bH), Rect_8, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle(2*bW + 2, 2*bH + 2, bW, bH), Rect_9, GraphicsUnit.Pixel)
form_nine_zone.BeginInvoke(lambda: Show_picture_box(bitmap))
frame.Dispose() # here frame is a bitmap
except:
print("Problem framehandler")
# *****************************************************************************
def Show_Nine_zone(self):
global dumpdata, colour_space
global bH, bW, Rect_1, Rect_2, Rect_3, Rect_4, Rect_5, Rect_6, Rect_7, Rect_8, Rect_9
Boxsize = int(self.textBoxSize.Text)
bH = Boxsize
bW = Boxsize
Rect_1 = Rectangle(0, 0, bW, bH)
Rect_2 = Rectangle((W-bW)//2, 0, bW, bH)
Rect_3 = Rectangle(W - bW, 0, bW, bH)
Rect_4 = Rectangle(0, (H-bH)//2, bW, bH)
Rect_5 = Rectangle((W-bW)//2, (H-bH)//2, bW, bH)
Rect_6 = Rectangle(W - bW, (H-bH)//2, bW, bH)
Rect_7 = Rectangle(0, H - bH, bW, bH)
Rect_8 = Rectangle((W-bW)//2, H - bH, bW, bH)
Rect_9 = Rectangle(W - bW, H - bH, bW, bH)
#self.pictureBox1.Size = System.Drawing.Size(3*Boxsize + 2, 3*Boxsize + 2)
if (3*Boxsize + 2 > 450):
new_width = int((3*Boxsize + 2)/1.476)
self.ClientSize = System.Drawing.Size(new_width, new_width + 75)
self.trackBar1.Size = Size(self.ClientSize.Width - 10, 35)
self.AutoScaleDimensions = SizeF(96, 96)
if (3*Boxsize + 2 < 450):
new_width = 300
self.ClientSize = System.Drawing.Size(new_width, new_width + 75)
self.trackBar1.Size = Size(self.ClientSize.Width - 10, 35)
self.AutoScaleDimensions = SizeF(96, 96)
if (self.Nine_zone.Text == "Start"):
self.Nine_zone.Text = "Stop"
self.Nine_zone.BackColor = Color.Red
colour_space = SharpCap.SelectedCamera.Controls.ColourSpace.Value
dumpdata = True
SharpCap.SelectedCamera.FrameCaptured += framehandler
elif (self.Nine_zone.Text == "Stop"):
self.Nine_zone.Text = "Start"
self.Nine_zone.BackColor = Color.Gainsboro
colour_space = SharpCap.SelectedCamera.Controls.ColourSpace.Value
dumpdata = False
SharpCap.SelectedCamera.FrameCaptured -= framehandler
print()
print("Nine Zones:")
print("*****************")
# *****************************************************************************
class Nine_zoneWINMenuForm(Form):
def __init__(self):
self.SuspendLayout()
self.InitializeComponent()
self.setupCheckButtons()
self.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi
self.AutoScaleDimensions = SizeF(96, 96)
self.ResumeLayout()
def InitializeComponent(self):
self.Text = "Nine Zones"
self.ClientSize = System.Drawing.Size(300, 500) #340)
self.TopMost = True
def setupCheckButtons(self):
self.Nine_zone = Button()
self.Nine_zone.Text = "Start"
self.Nine_zone.Location = Point(20, 10)
self.Nine_zone.Click += self.Nine_zone_meas
self.Nine_zone.AutoSize = True
self.labelSize = Label()
self.labelSize.AutoSize = True
self.labelSize.Location = Point(110, 14)
self.labelSize.Name = "labelSize"
self.labelSize.Text = "Size:"
self.textBoxSize = TextBox()
self.textBoxSize.AutoSize = True
self.textBoxSize.Location = Point(145, 12)
self.textBoxSize.Name = "textBoxSize"
self.textBoxSize.Size = Size(35, 20)
self.textBoxSize.Text = str(Boxsize)
self.button_Exit = Button()
self.button_Exit.Text = "Exit"
self.button_Exit.Location = Point(200, 10)
self.button_Exit.Click += self.exit
self.button_Exit.AutoSize = True
self.pictureBox1 = System.Windows.Forms.PictureBox()
self.pictureBox1.Location = System.Drawing.Point(3, 70)
self.pictureBox1.Name = "pictureBox1"
self.pictureBox1.Size = System.Drawing.Size(3*Boxsize + 2, 3*Boxsize + 2)
self.pictureBox1.TabIndex = 0
self.pictureBox1.TabStop = False
self.trackBar1 = TrackBar()
self.trackBar1.Location = Point(8, 40)
self.trackBar1.Size = Size(self.ClientSize.Width - 10, 35)
self.trackBar1.Scroll += EventHandler(self.trackBar1_Scroll)
self.trackBar1.Minimum = 0
self.trackBar1.Maximum = 100
self.trackBar1.TickFrequency = 10
self.trackBar1.Value = 50
self.Controls.Add(self.Nine_zone)
self.Controls.Add(self.labelSize)
self.Controls.Add(self.textBoxSize)
self.Controls.Add(self.button_Exit)
self.Controls.Add(self.pictureBox1)
self.Controls.Add(self.trackBar1)
def Nine_zone_meas(self, sender, event):
th = Thread(ParameterizedThreadStart(Show_Nine_zone))
th.SetApartmentState(ApartmentState.STA)
th.Start(self)
def trackBar1_Scroll(self, sender, event):
global stretch_gamma
stretch_gamma = self.trackBar1.Value / 100
def exit(self, sender, event):
self.Close()
def BeforeClosing(self, sender, event):
print("Stop before closing script")
dumpdata = False
SharpCap.SelectedCamera.FrameCaptured -= framehandler
form_nine_zone = Nine_zoneWINMenuForm()
form_nine_zone.StartPosition = FormStartPosition.CenterScreen
form_nine_zone.TopMost = True
form_nine_zone.FormClosing += form_nine_zone.BeforeClosing
form_nine_zone.Show()
It is now a single slider for changing the gamma value (= middle point of the histogram).
Regards,
Jean-Francois
You do not have the required permissions to view the files attached to this post.
-
- Posts: 503
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: View with center and corners
Hello Robin,
How do you do the zoom in "pixels" ?
I tried with Bitmap/Graphics function. But I still not found the correct way.
Here an example if I scale 4x the bitmap before showing it.
In comparison the same region on the image in SharpCap (with zoom = 300%).
The camera is set to MONO8 with a lot of gain.
Regards,
Jean-Francois
How do you do the zoom in "pixels" ?
I tried with Bitmap/Graphics function. But I still not found the correct way.
Here an example if I scale 4x the bitmap before showing it.
In comparison the same region on the image in SharpCap (with zoom = 300%).
The camera is set to MONO8 with a lot of gain.
Regards,
Jean-Francois
You do not have the required permissions to view the files attached to this post.
- admin
- Site Admin
- Posts: 14257
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: View with center and corners
Hi,
if you are using a Graphics object then try
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
before drawing the bitmap at 4x size into the graphics - that should get you the blocky, big pixel, look.
cheers,
Robin
if you are using a Graphics object then try
graphics.InterpolationMode = InterpolationMode.NearestNeighbor;
before drawing the bitmap at 4x size into the graphics - that should get you the blocky, big pixel, look.
cheers,
Robin
-
- Posts: 503
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: View with center and corners
Hello Robin,
OK, thanks. It works after adding "from System.Drawing.Drawing2D import InterpolationMode".
Here the script with the last modification.
Left: the zoom in my script, right: the zoom in SharpCap window. Regards,
Jean-Francois
OK, thanks. It works after adding "from System.Drawing.Drawing2D import InterpolationMode".
Here the script with the last modification.
Code: Select all
# *******************************************************************************************
# SharpCap script "Nine_zone.py"
# 2024/09/04 Jean-Francois
#
# Version: 2.1.0: Add pixel zoom
# Version: 2.0.0: Lot of correction. Now 8 and 16 bit MONO, Gamma setting
# Version: 1.0.0: First version
#
# The script works only with a SharpCap PRO version.
# *******************************************************************************************
import os
import math
import clr
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
import System.Drawing
import System.Windows.Forms
from System import Array, EventHandler
from System.Drawing import *
from System.Drawing.Drawing2D import InterpolationMode
from System.Windows.Forms import *
from System.Threading import Thread, ApartmentState, ParameterizedThreadStart
from SharpCap.Base import Interfaces
H = SharpCap.SelectedCamera.Controls.Resolution.CaptureArea.Height
W = SharpCap.SelectedCamera.Controls.Resolution.CaptureArea.Width
Boxsize = 100
bH = Boxsize
bW = Boxsize
Rect_1 = Rectangle(0, 0, bW, bH)
Rect_2 = Rectangle((W-bW)//2, 0, bW, bH)
Rect_3 = Rectangle(W - bW, 0, bW, bH)
Rect_4 = Rectangle(0, (H-bH)//2, bW, bH)
Rect_5 = Rectangle((W-bW)//2, (H-bH)//2, bW, bH)
Rect_6 = Rectangle(W - bW, (H-bH)//2, bW, bH)
Rect_7 = Rectangle(0, H - bH, bW, bH)
Rect_8 = Rectangle((W-bW)//2, H - bH, bW, bH)
Rect_9 = Rectangle(W - bW, H - bH, bW, bH)
stretch_gamma = 0.5
colour_space = SharpCap.SelectedCamera.Controls.ColourSpace.Value
zoom = 1
def Show_picture_box(bmp):
form_nine_zone.pictureBox1.Image = bmp
def framehandler(sender, args):
global stretch_gamma, colour_space, zoom
if (dumpdata):
try:
stretch = Interfaces.ReciprocalLevelStretch(0.0, stretch_gamma, 1.0, False)
if (colour_space == 'MONO16' or colour_space == 'RAW16'):
frame = args.Frame.ChangeBitDepth(8).DisplayTransform(stretch).GetFrameBitmap()
else:
frame = args.Frame.DisplayTransform(stretch).GetFrameBitmap()
bitmap = Bitmap(zoom*(3 * bW + 2), zoom*(3 * bH + 2))
gr = Graphics.FromImage(bitmap)
gr.InterpolationMode = InterpolationMode.NearestNeighbor
gr.ScaleTransform(zoom, zoom)
gr.DrawImage(frame, Rectangle( 0, 0, bW, bH), Rect_1, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( bW + 1, 0, bW, bH), Rect_2, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle(2*bW + 2, 0, bW, bH), Rect_3, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( 0, bH + 1, bW, bH), Rect_4, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( bW + 1, bH + 1, bW, bH), Rect_5, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle(2*bW + 2, bH + 1, bW, bH), Rect_6, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( 0, 2*bH + 2, bW, bH), Rect_7, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle( bW + 1, 2*bH + 2, bW, bH), Rect_8, GraphicsUnit.Pixel)
gr.DrawImage(frame, Rectangle(2*bW + 2, 2*bH + 2, bW, bH), Rect_9, GraphicsUnit.Pixel)
form_nine_zone.BeginInvoke(lambda: Show_picture_box(bitmap))
frame.Dispose() # here frame is a bitmap
except:
print("Problem framehandler")
# *****************************************************************************
def Show_Nine_zone(self):
global dumpdata, colour_space, zoom
global bH, bW, Rect_1, Rect_2, Rect_3, Rect_4, Rect_5, Rect_6, Rect_7, Rect_8, Rect_9
Boxsize = int(self.textBoxSize.Text)
bH = Boxsize
bW = Boxsize
Rect_1 = Rectangle(0, 0, bW, bH)
Rect_2 = Rectangle((W-bW)//2, 0, bW, bH)
Rect_3 = Rectangle(W - bW, 0, bW, bH)
Rect_4 = Rectangle(0, (H-bH)//2, bW, bH)
Rect_5 = Rectangle((W-bW)//2, (H-bH)//2, bW, bH)
Rect_6 = Rectangle(W - bW, (H-bH)//2, bW, bH)
Rect_7 = Rectangle(0, H - bH, bW, bH)
Rect_8 = Rectangle((W-bW)//2, H - bH, bW, bH)
Rect_9 = Rectangle(W - bW, H - bH, bW, bH)
if (self.comboboxZoom.Text == "100%"):
zoom = 1
elif (self.comboboxZoom.Text == "200%"):
zoom = 2
elif (self.comboboxZoom.Text == "300%"):
zoom = 3
elif (self.comboboxZoom.Text == "400%"):
zoom = 4
elif (self.comboboxZoom.Text == "600%"):
zoom = 6
elif (self.comboboxZoom.Text == "800%"):
zoom = 8
self.pictureBox1.Size = System.Drawing.Size(zoom*(3*Boxsize + 2), zoom*(3*Boxsize + 2))
# if (3*Boxsize + 2 > 450):
# new_width = int((3*Boxsize + 2)/1.476)
# self.ClientSize = System.Drawing.Size(new_width, new_width + 75)
# self.trackBar1.Size = Size(self.ClientSize.Width - 10, 35)
# self.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi
# self.AutoScaleDimensions = SizeF(96, 96)
# if (3*Boxsize + 2 < 450):
# new_width = 300
# self.ClientSize = System.Drawing.Size(new_width, new_width + 75)
# self.trackBar1.Size = Size(self.ClientSize.Width - 10, 35)
# self.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi
# self.AutoScaleDimensions = SizeF(96, 96)
if (self.Nine_zone.Text == "Start"):
self.Nine_zone.Text = "Stop"
self.Nine_zone.BackColor = Color.Red
colour_space = SharpCap.SelectedCamera.Controls.ColourSpace.Value
dumpdata = True
SharpCap.SelectedCamera.FrameCaptured += framehandler
elif (self.Nine_zone.Text == "Stop"):
self.Nine_zone.Text = "Start"
self.Nine_zone.BackColor = Color.Gainsboro
colour_space = SharpCap.SelectedCamera.Controls.ColourSpace.Value
dumpdata = False
SharpCap.SelectedCamera.FrameCaptured -= framehandler
print()
print("Nine Zones:")
print("*****************")
# *****************************************************************************
class Nine_zoneWINMenuForm(Form):
def __init__(self):
self.SuspendLayout()
self.InitializeComponent()
self.setupCheckButtons()
self.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi
self.AutoScaleDimensions = SizeF(96, 96)
self.ResumeLayout()
def InitializeComponent(self):
self.Text = "Nine Zones"
self.ClientSize = System.Drawing.Size(400, 500) #340)
self.TopMost = True
def setupCheckButtons(self):
self.Nine_zone = Button()
self.Nine_zone.Text = "Start"
self.Nine_zone.Location = Point(20, 10)
self.Nine_zone.Click += self.Nine_zone_meas
self.Nine_zone.AutoSize = True
self.labelSize = Label()
self.labelSize.AutoSize = True
self.labelSize.Location = Point(110, 14)
self.labelSize.Name = "labelSize"
self.labelSize.Text = "Size:"
self.textBoxSize = TextBox()
self.textBoxSize.AutoSize = True
self.textBoxSize.Location = Point(142, 11)
self.textBoxSize.Name = "textBoxSize"
self.textBoxSize.Size = Size(35, 20)
self.textBoxSize.Text = str(Boxsize)
self.labelZoom = Label()
self.labelZoom.AutoSize = True
self.labelZoom.Location = Point(195, 14)
self.labelZoom.Name = "labelZoom"
self.labelZoom.Text = "Zoom:"
self.comboboxZoom = ComboBox()
self.comboboxZoom.Location = Point(240, 11)
self.comboboxZoom.Size = Size(60,10)
self.comboboxZoom.Items.Add("100%")
self.comboboxZoom.Items.Add("200%")
self.comboboxZoom.Items.Add("300%")
self.comboboxZoom.Items.Add("400%")
self.comboboxZoom.Items.Add("600%")
self.comboboxZoom.Items.Add("800%")
self.comboboxZoom.SelectedItem = "100%"
self.button_Exit = Button()
self.button_Exit.Text = "Exit"
self.button_Exit.Location = Point(310, 10)
self.button_Exit.Click += self.exit
self.button_Exit.AutoSize = True
self.pictureBox1 = System.Windows.Forms.PictureBox()
self.pictureBox1.Location = System.Drawing.Point(3, 70)
self.pictureBox1.Name = "pictureBox1"
#self.pictureBox1.Size = System.Drawing.Size(3*Boxsize + 2, 3*Boxsize + 2)
self.pictureBox1.TabIndex = 0
self.pictureBox1.TabStop = False
self.pictureBox1.BackColor = Color.Red
self.pictureBox1.AutoSize = True
self.trackBar1 = TrackBar()
self.trackBar1.Location = Point(8, 40)
self.trackBar1.Size = Size(self.ClientSize.Width - 10, 35)
self.trackBar1.Scroll += EventHandler(self.trackBar1_Scroll)
self.trackBar1.Minimum = 0
self.trackBar1.Maximum = 100
self.trackBar1.TickFrequency = 10
self.trackBar1.Value = 50
self.Controls.Add(self.Nine_zone)
self.Controls.Add(self.labelSize)
self.Controls.Add(self.textBoxSize)
self.Controls.Add(self.labelZoom)
self.Controls.Add(self.comboboxZoom)
self.Controls.Add(self.button_Exit)
self.Controls.Add(self.pictureBox1)
self.Controls.Add(self.trackBar1)
def Nine_zone_meas(self, sender, event):
th = Thread(ParameterizedThreadStart(Show_Nine_zone))
th.SetApartmentState(ApartmentState.STA)
th.Start(self)
def trackBar1_Scroll(self, sender, event):
global stretch_gamma
stretch_gamma = self.trackBar1.Value / 100
def exit(self, sender, event):
self.Close()
def BeforeClosing(self, sender, event):
print("Stop before closing script")
dumpdata = False
SharpCap.SelectedCamera.FrameCaptured -= framehandler
form_nine_zone = Nine_zoneWINMenuForm()
form_nine_zone.StartPosition = FormStartPosition.CenterScreen
form_nine_zone.TopMost = True
form_nine_zone.FormClosing += form_nine_zone.BeforeClosing
form_nine_zone.Show()
Left: the zoom in my script, right: the zoom in SharpCap window. Regards,
Jean-Francois
You do not have the required permissions to view the files attached to this post.
-
- Posts: 503
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: View with center and corners
Hello,
OK, here my last version.
I add the possibility to move the view.
How to do ? ... simply click with the left mouse button on the centre and then move the mouse (with the button pressed).
When you release the mouse button, the view comes back to the centre (and corners).
I tested with different cameras. It works fine. But, with a very large sensor, it needs a lot of memory.
It crashed several times (when the 12 GB memory allocation in SharpCap settings was full).
I tested it with more memory reservation (32 GB) ... and the same ... with the 60 MPixel camera in 16 bit, it was a new crash around 34 GB RAM.
With smaller camera sensor or in 8 bit ... no problem.
Robin, can you have a quick look in my code ?
How can I release more memory ?
The script is now a "menu" version.
Rename the file with *.py in place of *.txt.
Select it in the "File" - "SharpCap Settings" - "Startup Scripts" and restart SharpCap.
A new menu should be visible.
Regards,
Jean-Francois
OK, here my last version.
I add the possibility to move the view.
How to do ? ... simply click with the left mouse button on the centre and then move the mouse (with the button pressed).
When you release the mouse button, the view comes back to the centre (and corners).
I tested with different cameras. It works fine. But, with a very large sensor, it needs a lot of memory.
It crashed several times (when the 12 GB memory allocation in SharpCap settings was full).
I tested it with more memory reservation (32 GB) ... and the same ... with the 60 MPixel camera in 16 bit, it was a new crash around 34 GB RAM.
With smaller camera sensor or in 8 bit ... no problem.
Robin, can you have a quick look in my code ?
How can I release more memory ?
The script is now a "menu" version.
Rename the file with *.py in place of *.txt.
Select it in the "File" - "SharpCap Settings" - "Startup Scripts" and restart SharpCap.
A new menu should be visible.
Regards,
Jean-Francois
You do not have the required permissions to view the files attached to this post.
-
- Posts: 503
- Joined: Sun Oct 13, 2019 10:52 am
- Location: Germany
Re: View with center and corners
Hello Robin,
I did some additional research and I add 2 Dispose() (for "gr" and "bitmap").
But it has not the wanted effect ... means it has no effect.
For a ROI up to 7200x6422, no problem ... the maximum RAM for SharpCap is between 1.4 GB and 3.3 GB (and goes up and down continuously).
For the maximum sensor size of 9600x6422 ... then it is more problem. The used RAM grows up to the limit set in SharpCap.
Here the memory use for both ROI: I repeat it with the maximum possible RAM size on my desktop computer ... 123 GB.
And it was continuously growing, until SharpCap completely crash and the window disappear around 121 GB memory use.
OK, for the people trying my script ... if you have a small sensor, then it is no problem. At least you have several free GB RAM that you can set in SharpCap settings. If you have a 60 Mpixel sensor, then take care to not use my script if you use the full frame.
Regards,
Jean-Francois
I did some additional research and I add 2 Dispose() (for "gr" and "bitmap").
But it has not the wanted effect ... means it has no effect.
For a ROI up to 7200x6422, no problem ... the maximum RAM for SharpCap is between 1.4 GB and 3.3 GB (and goes up and down continuously).
For the maximum sensor size of 9600x6422 ... then it is more problem. The used RAM grows up to the limit set in SharpCap.
Here the memory use for both ROI: I repeat it with the maximum possible RAM size on my desktop computer ... 123 GB.
And it was continuously growing, until SharpCap completely crash and the window disappear around 121 GB memory use.
OK, for the people trying my script ... if you have a small sensor, then it is no problem. At least you have several free GB RAM that you can set in SharpCap settings. If you have a 60 Mpixel sensor, then take care to not use my script if you use the full frame.
Regards,
Jean-Francois
You do not have the required permissions to view the files attached to this post.
- admin
- Site Admin
- Posts: 14257
- Joined: Sat Feb 11, 2017 3:52 pm
- Location: Vale of the White Horse, UK
- Contact:
Re: View with center and corners
Hi Jean-Francois,
I think your problem is in these lines of code
There are intermediate results here that are SharpCap frame objects that need to have .Release() called on them. In particular, the objects returned by .ChangeBitDepth() and .DisplayTransform() need to be stored into variables and then .Release() called on them.
cheers,
Robin
I think your problem is in these lines of code
Code: Select all
if (colour_space == 'MONO16' or colour_space == 'RAW16'):
frame = args.Frame.ChangeBitDepth(8).DisplayTransform(stretch).GetFrameBitmap()
else:
frame = args.Frame.DisplayTransform(stretch).GetFrameBitmap()
cheers,
Robin