Skip to content

Commit

Permalink
Commit #113
Browse files Browse the repository at this point in the history
- Fixed importing pyueye and IDS related issue when SDK is not installed (issue #4 ).
- Fixed CPU based fitting bug in pyfit3Dcspline.
  • Loading branch information
samhitech committed Mar 28, 2023
1 parent f501fab commit 6f836f7
Show file tree
Hide file tree
Showing 8 changed files with 158 additions and 17 deletions.
1 change: 1 addition & 0 deletions src/microEye/fitting/fit.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ def localize_frame(
else:
if varim is None:
rois, coords = get_roi_list(image, points, roiSize)
varims = None
else:
rois, varims, coords = get_roi_list_CMOS(
image, varim, points, roiSize)
Expand Down
3 changes: 2 additions & 1 deletion src/microEye/hardware/CameraListWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
from PyQt5.QtWidgets import *

from ..thread_worker import *
from .ueye_camera import IDS_Camera
from .thorlabs import *

try:
from pyueye import ueye
from .ueye_camera import IDS_Camera
except Exception:
ueye = None
IDS_Camera = None

try:
import vimba as vb
Expand Down
6 changes: 4 additions & 2 deletions src/microEye/hardware/acquisition_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@
from .thorlabs import *
from .thorlabs_panel import Thorlabs_Panel
from ..thread_worker import *
from .ueye_camera import IDS_Camera
from .ueye_panel import IDS_Panel
from .kinesis import *
from .scan_acquisition import *
from ..hid_controller import *

try:
from pyueye import ueye
from .ueye_camera import IDS_Camera
from .ueye_panel import IDS_Panel
except Exception:
ueye = None
IDS_Camera = None
IDS_Panel = None

try:
import vimba as vb
Expand Down
19 changes: 13 additions & 6 deletions src/microEye/hardware/control_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,15 @@
from .port_config import *
from .thorlabs import *
from .thorlabs_panel import Thorlabs_Panel
from .ueye_camera import IDS_Camera
from .ueye_panel import IDS_Panel

try:
from pyueye import ueye
from .ueye_camera import IDS_Camera
from .ueye_panel import IDS_Panel
except Exception:
ueye = None
IDS_Camera = None
IDS_Panel = None

warnings.filterwarnings("ignore", category=OptimizeWarning)

Expand Down Expand Up @@ -624,7 +631,7 @@ def worker_function(self, progress_callback, movez_callback):
self._exec_time = 0
time = QDateTime.currentDateTime()
QThread.msleep(100)
while(self.isVisible()):
while (self.isVisible()):
try:
# dt = Gaussian(
# np.array(range(512)), 255, np.random.normal() + 256, 50)
Expand All @@ -648,7 +655,7 @@ def worker_function(self, progress_callback, movez_callback):
data = np.squeeze(data)
# self.ydata_temp = self.ydata
self.peak_fit(movez_callback, data.copy())
if(self.file is not None):
if (self.file is not None):
np.savetxt(self.file,
np.array((self._exec_time, self.popt[1]))
.reshape((1, 2)), delimiter=";")
Expand Down Expand Up @@ -866,7 +873,7 @@ def start_IR(self):
'''Starts the IR peak position acquisition and
creates a file in the current directory.
'''
if(self.file is None):
if (self.file is None):
filename = None
if filename is None:
filename, _ = QFileDialog.getSaveFileName(
Expand All @@ -880,7 +887,7 @@ def start_IR(self):
def stop_IR(self):
'''Stops the IR peak position acquisition and closes the file.
'''
if(self.file is not None):
if (self.file is not None):
self.file.close()
self.file = None
self.frames_saved = 0
Expand Down
124 changes: 124 additions & 0 deletions src/microEye/hardware/line_profiler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
import pyqtgraph as pg
import qdarkstyle
import numpy as np
import tifffile as tf
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtSerialPort import *
from PyQt5.QtGui import *
# from ..uImage import uImage


class LineProfiler(QGroupBox):

def __init__(self) -> None:
super().__init__()

self.setTitle('Line Profiler')

self.lineProfiles = []

layout = QFormLayout()
self.setLayout(layout)

params = QHBoxLayout()

self.x_1 = QSpinBox()
self.x_1.setMinimum(0)
self.x_1.setMaximum(10**5)
self.x_1.setValue(0)
self.x_2 = QSpinBox()
self.x_2.setMinimum(0)
self.x_2.setMaximum(10**5)
self.x_2.setValue(0)

self.y_1 = QSpinBox()
self.y_1.setMinimum(0)
self.y_1.setMaximum(10**5)
self.y_1.setValue(0)
self.y_2 = QSpinBox()
self.y_2.setMinimum(0)
self.y_2.setMaximum(10**5)
self.y_2.setValue(256)

self.lineWidth = QSpinBox()
self.lineWidth.setMinimum(0)
self.lineWidth.setMaximum(255)
self.lineWidth.setValue(1)

self.average = QSpinBox()
self.average.setMinimum(1)
self.average.setMaximum(128)
self.average.setValue(1)

self.add = QPushButton('Add', clicked=lambda: self.lineProfiles.append(
{
'P1': (self.x_1.value(), self.y_1.value()),
'P2': (self.x_2.value(), self.y_2.value()),
'Width': self.lineWidth.value()
}
))

self.clear = QPushButton(
'Clear',
clicked=lambda: self.lineProfiles.clear())

params.addWidget(
QLabel('X 1'))
params.addWidget(
self.x_1)
params.addWidget(
QLabel('Y 1'))
params.addWidget(
self.y_1)
params.addWidget(
QLabel('X 2'))
params.addWidget(
self.x_2)
params.addWidget(
QLabel('Y 2'))
params.addWidget(
self.y_2)
params.addWidget(
QLabel('Line Width'))
params.addWidget(
self.lineWidth)
params.addWidget(
QLabel('Average [frames]'))
params.addWidget(
self.average)

self.plot = pg.PlotWidget()
greenP = pg.mkPen(color='g')
self.plot_ref = self.plot.plot(
np.zeros((256)), np.zeros((256)), pen=greenP)

layout.addRow(params)
layout.addRow(self.plot)

def save_browse_clicked(self):
"""Slot for browse clicked event"""
directory = QFileDialog.getExistingDirectory(
self, "Select Directory")

if len(directory) > 0:
self._directory = directory
self.save_dir_edit.setText(self._directory)

def get_params(self):
return (
(self.x_1.value(), self.y_1.value()),
(self.x_2.value(), self.y_2.value()),
self.lineWidth.value(),
self.average.value())


if __name__ == '__main__':

app = QApplication([])
app.setStyleSheet(qdarkstyle.load_stylesheet(qt_api='pyqt5'))

win = LineProfiler()
win.show()

app.exec_()
11 changes: 9 additions & 2 deletions src/microEye/hardware/miEye.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,15 @@
from .scan_acquisition import *
from .thorlabs import *
from .thorlabs_panel import Thorlabs_Panel
from .ueye_camera import IDS_Camera
from .ueye_panel import IDS_Panel

try:
from pyueye import ueye
from .ueye_camera import IDS_Camera
from .ueye_panel import IDS_Panel
except Exception:
ueye = None
IDS_Camera = None
IDS_Panel = None

try:
import vimba as vb
Expand Down
5 changes: 2 additions & 3 deletions src/microEye/hardware/thorlabs_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from pyueye import ueye

from ..qlist_slider import *
from ..thread_worker import *
Expand Down Expand Up @@ -865,7 +864,7 @@ def _capture(self, nRet, cam: thorlabs_camera):
time = QDateTime.currentDateTime()
self._nFrames = int(self.frames_tbox.text())
# Continuous image capture
while(nRet == ueye.IS_SUCCESS):
while(nRet == 0):
self._exec_time = time.msecsTo(QDateTime.currentDateTime())
time = QDateTime.currentDateTime()

Expand Down Expand Up @@ -919,7 +918,7 @@ def _display(self, nRet, cam: thorlabs_camera):
try:
time = QDateTime.currentDateTime()
# Continuous image display
while(nRet == ueye.IS_SUCCESS):
while(nRet == 0):
# for display time estimations

# proceed only if the buffer is not empty
Expand Down
6 changes: 3 additions & 3 deletions src/microEye/hardware/ueye_panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def _capture(self, nRet, cam: IDS_Camera):
time = QDateTime.currentDateTime()
self._nFrames = int(self.frames_tbox.text())
# Continuous image capture
while(nRet == ueye.IS_SUCCESS):
while (nRet == ueye.IS_SUCCESS):
self._exec_time = time.msecsTo(QDateTime.currentDateTime())
time = QDateTime.currentDateTime()

Expand Down Expand Up @@ -979,7 +979,7 @@ def _display(self, nRet, cam: IDS_Camera):
counter = 0
accumulator = None
# Continuous image display
while(nRet == ueye.IS_SUCCESS):
while (nRet == ueye.IS_SUCCESS):
# for display time estimations

# proceed only if the buffer is not empty
Expand Down Expand Up @@ -1107,7 +1107,7 @@ def saveMetadata(index: int):
getFilename(index),
ome.to_xml())

while(nRet == ueye.IS_SUCCESS):
while (nRet == ueye.IS_SUCCESS):
# save in case frame stack is not empty
if not self._frames.empty():
# for save time estimations
Expand Down

0 comments on commit 6f836f7

Please sign in to comment.