{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# DummyGrabber\n\nThis demo shows with the example of the ``DummyGrabber``\nhow grabber and cameras are used in ``itom``.\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from itom import dataIO\nfrom itom import dataObject\nfrom itom import plot\nfrom itom import liveImage" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start camera (e.g.: ``DummyGrabber``)\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "camera = dataIO(\"DummyGrabber\") # noise camera\ncameraGaussian = dataIO(\"DummyGrabber\", imageType=\"gaussianSpot\") # moving Gaussian spot \ncameraGaussianArray = dataIO(\"DummyGrabber\", imageType=\"gaussianSpotArray\") # moving 4 Gaussian spots" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set region of interest (ROI).\nx: [100,499] -> width: 400 (borders are included!)\ny: [40, 349] -> height: 310\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "camera.setParam(\"roi\", [100, 40, 400, 300])\n# or:\n# camera.setParam(\"roi[0]\", 100)\n# camera.setParam(\"roi[2]\", 400) #...\n\nprint(\"width:\", camera.getParam(\"sizex\"))\nprint(\"height:\", camera.getParam(\"sizey\"))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Set bits per pixel (bpp). \n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "camera.setParam(\"bpp\", 8)\n\n# print available parameters of that device\nprint(\"DummyGrabber has the following parameters:\")\nprint(camera.getParamList())\n\n# print detailed information about parameters:\nprint(camera.getParamListInfo())" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read parameters from device.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "sizex = camera.getParam(\"sizex\")\nsizey = camera.getParam(\"sizey\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start camera.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "camera.startDevice()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Acquire single image.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "camera.acquire()\n\n# Create empty dataObject for getting the image\ndata = dataObject()\n\n# get a reference to the acquired image\n# the reference is then available by the recently created dataObject\ncamera.getVal(data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "

Warning

The method **getVal** returns only a shallow copy of the plugin internal memory.\n Therefore, the content of data will change when the next image is acquired.\n In order to create a deep copy of data, type:\n\n```python\ncamera.copyVal(data)

\n```\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "# You can also convert the data afterwards to a deep copy by typing:\ndataCopy = data.copy()\n\n# plot the acquired image\nplot(data)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Stop camera.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "camera.stopDevice()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Start a live image.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "liveImage(camera)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "liveImage(cameraGaussian)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "liveImage(cameraGaussianArray)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Acquire an image stack of 10 measurements.\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "num = 100\ncamera.startDevice()\nimage = dataObject()\nimageStack = dataObject([num, sizey, sizex], \"uint8\")\n\n# stop the auto grabbing of the live image\ncamera.disableAutoGrabbing()\n\nfor idx in range(num):\n camera.acquire()\n camera.getVal(image)\n imageStack[idx, :, :] = image\n print(idx)\n\ncamera.stopDevice()\n# acquire stack finished\n\n# plot stack (use arrows in widget to switch between planes)\nplot(imageStack)\n\n# enable the auto grabbing of the live image\ncamera.enableAutoGrabbing()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 0 }