### Execute a PySpin Example Script Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Example command demonstrating how to run a preinstalled PySpin example script from the command prompt after successful PySpin installation. ```bash py -3.7 Examples\Python3\Acquisition.py ``` -------------------------------- ### Run PySpin Example Script Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Command to execute a PySpin example script located in the Examples folder of the extracted tarball. ```bash python3.7 Examples/Python3/DeviceEvents.py ``` -------------------------------- ### Run PySpin Examples on Linux Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Execute PySpin examples located in the 'Examples' folder of the extracted tarball, specifying the Python version to use for execution. ```bash python3.7 Examples/Python3/DeviceEvents.py ``` -------------------------------- ### PySpin API Differences: IRegister Get/Set Methods Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Details the changes to Get() and Set() methods for IRegister and register nodes, now using NumPy arrays for data transfer. ```APIDOC IRegister and Register Nodes: - Methods Get() and Set() use NumPy arrays. - Get(): Takes in the length of the register to read and two optional bools, returns a NumPy array. - Set(): Takes in a single NumPy array. ``` -------------------------------- ### Install NumPy and Matplotlib for PySpin on Linux Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Install essential Python libraries for PySpin: NumPy (required, version 1.15+) and Matplotlib (optional, used in examples). Commands are provided for various Python versions and installation scopes (user-only or site-wide). ```bash python -m pip install --upgrade --user numpy matplotlib ``` ```bash sudo python -m pip install --upgrade numpy matplotlib ``` ```bash python3.5 -m pip install --upgrade --user numpy matplotlib ``` ```bash sudo python3.5 -m pip install --upgrade numpy matplotlib ``` ```bash python3.6 -m pip install --upgrade --user numpy matplotlib ``` ```bash sudo python3.6 -m pip install --upgrade numpy matplotlib ``` ```bash python3.7 -m pip install --upgrade --user numpy matplotlib ``` ```bash sudo python3.7 -m pip install --upgrade numpy matplotlib ``` -------------------------------- ### Install Python Dependencies for PySpin Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Commands to update pip and install essential Python libraries like NumPy and Matplotlib, which are prerequisites for PySpin. Optionally, Pillow can be installed for enhanced image output support in examples. ```bash -m ensurepip -m pip install --upgrade pip numpy matplotlib py -3.7 -m pip install Pillow==5.2.0 ``` -------------------------------- ### Install PySpin Wheel Package on Linux Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Install the PySpin wheel package for your specific Python version. Ensure the corresponding Spinnaker SDK Debian packages are installed beforehand. Commands are provided for both site-wide and user-only installations. ```bash sudo python -m pip install spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl ``` ```bash python -m pip install --user spinnaker_python-1.x.x.x-cp27-cp27mu-linux_x86_64.whl ``` ```bash sudo python3.5 -m pip install spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl ``` ```bash python3.5 -m pip install --user spinnaker_python-1.x.x.x-cp35-cp35m-linux_x86_64.whl ``` ```bash sudo python3.6 -m pip install spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl ``` ```bash python3.6 -m pip install --user spinnaker_python-1.x.x.x-cp36-cp36m-linux_x86_64.whl ``` ```bash sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl ``` ```bash python3.7 -m pip install --user spinnaker_python-1.x.x.x-cp37-cp37m-linux_x86_64.whl ``` -------------------------------- ### Install PySpin Python Wheel Package Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Command to install the PySpin Python wheel package. It is crucial to ensure the downloaded wheel file's version and architecture match the target Python installation. ```bash -m pip install spinnaker_python-1.x.x.x-cp37-cp37m-win_amd64.whl ``` -------------------------------- ### PySpin API Differences: Pass-by-Reference Functions Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Explains that functions previously using pass-by-reference now return the type directly and take 'void' as input, providing examples for various list-returning methods. ```APIDOC Pass-by-Reference Functions: - Now return the type and take in void. - GetFeatures(): Returns a Python list of IValue (instead of taking in a FeatureList_t reference). - GetChildren(): Returns a Python list of INode (instead of taking in a NodeList_t reference). - Same with GetEntries(), GetNodes(). - GetPropertyNames(): Returns a Python list of str (instead of taking in a gcstring_vector reference). - See DeviceEvents example for usage. ``` -------------------------------- ### Install NumPy and Matplotlib for PySpin on macOS Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Install essential Python libraries for PySpin on macOS: NumPy (required, version 1.15+) and Matplotlib (optional, used in examples). Commands are provided for various Python versions and installation scopes (user-only or site-wide). ```bash python -m pip install --upgrade --user numpy matplotlib ``` ```bash sudo python -m pip install --upgrade numpy matplotlib ``` ```bash python3.6 -m pip install --upgrade --user numpy matplotlib ``` ```bash sudo python3.6 -m pip install --upgrade numpy matplotlib ``` ```bash python3.7 -m pip install --upgrade --user numpy matplotlib ``` ```bash sudo python3.7 -m pip install --upgrade numpy matplotlib ``` -------------------------------- ### PySpin API Differences: Node Callbacks Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Details the change in node callback mechanism, now using a callback class instead of a function pointer, and updated registration methods. ```APIDOC Node Callbacks: - Take in a callback class instead of a function pointer. - Register is now RegisterNodeCallback. - Deregister is now DeregisterNodeCallback. - See NodeMapCallback example for more details. ``` -------------------------------- ### PySpin API Differences: Excluded C++ Headers Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Lists specific C++ API headers that have not been wrapped in PySpin. ```APIDOC Excluded C++ Headers: - Headers with "Adapter" or "Port" in the name. - NodeMapRef.h - NodeMapFactory.h - Synch.h - GCSynch.h - Counter.h - filestream.h ``` -------------------------------- ### PySpin API Differences: Image Creation and Data Access Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Describes how image creation and data access differ, including NumPy array usage and specific methods for 1-D and 2/3-D arrays. ```APIDOC Image Creation: - Using NumPy arrays is supported (int type of array must be uint8). Image Data Access: - Image.GetData(): - Returns a 1-D NumPy array of integers. - Integer type depends on the pixel format. - Image.GetNDArray(): - Returns a 2 or 3-D NumPy array of integers. - Only for select image formats. - Can be used with libraries such as PIL and/or OpenCV. ``` -------------------------------- ### PySpin API Differences: Manual Resource Release Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Highlights the need for manual release/deletion of specific PySpin objects (CameraPtr, CameraList, etc.) before program exit using the 'del' operator. ```APIDOC Resource Release: - CameraPtr, CameraList, InterfacePtr, InterfaceList, and SystemPtr: - Have to be manually released and/or deleted before program exit. - Use 'del' operator. - See EnumerationEvents example for usage. ``` -------------------------------- ### Install Pillow for Python 3.7 Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Command to install a specific version of Pillow compatible with Python 3.7 using pip, as a prerequisite for PySpin. ```bash python3.7 -m pip install Pillow==5.2.0 ``` -------------------------------- ### Install pip for Python on Debian/Ubuntu Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt This command ensures that pip, the Python package installer, is available for both Python 2 and Python 3 on Debian-based systems, facilitating subsequent package management. ```bash sudo apt-get install python-pip python3-pip ``` -------------------------------- ### PySpin API Differences: INode and IValue Initialization Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Explains the requirement to initialize INode and IValue types (e.g., returned from GetNode()) to their specific pointer types before accessing functions. ```APIDOC INode and IValue Types: - Must be initialized to their respective pointer types (ex. CFloatPtr, CEnumerationPtr) to access their functions. ``` -------------------------------- ### Install PySpin Wheel for Python 3.7 on MacOS Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Command to install the PySpin wheel package for a specific Python version on MacOS, assuming Spinnaker SDK prerequisites are met. ```bash sudo python3.7 -m pip install spinnaker_python-1.x.x.x-cp37-cp37mu-macos_x86_x64.whl ``` -------------------------------- ### PySpin API Differences: SpinnakerException Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Details changes to SpinnakerException in PySpin, replacing its methods with attributes for error information and allowing direct printing. ```APIDOC SpinnakerException: - All methods no longer exist. - Replace usages with the following attributes: - message: Normal exception message. - fullmessage: Exception message including line, file, function, build date, and time (from C++ library). - errorcode: Integer error code of the exception. - The instance itself can be printed (derives from BaseException). ``` -------------------------------- ### Install Pillow for Matplotlib on Linux Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Install Pillow to improve Matplotlib's support for various output image file formats. Note that specific Pillow versions might be required depending on your Python version. ```bash python3.7 -m pip install Pillow==5.2.0 ``` -------------------------------- ### PySpin API Differences: IImage.CalculateChannelStatistics Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Describes the new method for calculating channel statistics, replacing ImageStatistics, and its return type. ```APIDOC IImage.CalculateChannelStatistics(StatisticsChannel channel): - Returns a ChannelStatistics object. - Represents stats for the given channel in the image. - Stats are properties within the ChannelStatistics object. - Replaces ImageStatistics. ``` -------------------------------- ### Uninstall PySpin (User-specific) on Linux/MacOS Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Command to remove a user-specific PySpin installation for a specific Python version on Linux or MacOS. ```bash -m pip uninstall spinnaker-python ``` -------------------------------- ### Uninstall PySpin (Site-wide) on Linux/MacOS Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Command to remove a site-wide PySpin installation for a specific Python version on Linux or MacOS, requiring sudo privileges. ```bash sudo -m pip uninstall spinnaker-python ``` -------------------------------- ### Update pip for Python on macOS Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Ensure pip is updated for your specific Python version on macOS, which allows for proper management and installation of new Python packages and wheels. ```bash sudo -m ensurepip ``` -------------------------------- ### Uninstall PySpin on Windows Source: https://github.com/capai/misc/blob/master/spinnaker/pyspin/README.txt Command to remove PySpin for a specific Python version on Windows, requiring an administrator command prompt. ```bash -m pip uninstall spinnaker-python ``` -------------------------------- ### Sampling One Row Per MMSI Group Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Groups the 'df190' DataFrame by 'mmsi' and then samples one random row from each group. This is useful for getting a representative entry for each unique ship. ```python df190.groupby('mmsi').sample() ``` -------------------------------- ### Getting Unique MMSI Values from Filtered DataFrame Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Retrieves and displays the unique 'mmsi' identifiers present in the 'df2' DataFrame. ```python df2.mmsi.unique() ``` -------------------------------- ### Writing GCS Paths to Text File Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Writes each generated Google Cloud Storage path from the 'outputs' list to a text file, with each path on a new line. The file is named 'MT_shiptype_Cruise_candidates.txt'. ```python with open('/home/jetze/Downloads/texts/MT_shiptype_Cruise_candidates.txt', 'w') as f: f.writelines(["%s\n" % item for item in outputs]) ``` -------------------------------- ### Displaying Generated GCS Paths Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Outputs the list of Google Cloud Storage paths generated in the previous step, typically for inspection in an interactive environment. ```python outputs ``` -------------------------------- ### Generating GCS Paths for Ship Data Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Iterates through 'mmsi', 'type', and 'url' from 'df2' to construct Google Cloud Storage (GCS) paths. Each path is formatted to include ship identifiers and a part of the URL, then appended to a list. ```python outputs = [] for m, t, u in zip(df2.mmsi.values, df2.type.values, df2.url.values): string = str(m) + '_' + str(t) +'_' + u.split('=')[-1] output = 'gs://marine-net/shiptype/MT/Passenger/'+string outputs.append(output) ``` -------------------------------- ### Importing Libraries for Data Analysis Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Imports the pandas library for data manipulation and enables matplotlib inline plotting for Jupyter environments. ```python import pandas as pd %matplotlib inline ``` -------------------------------- ### Convert SeaShips Dataset from VOC to KITTI Source: https://github.com/capai/misc/blob/master/tmp/merging/README.md This snippet demonstrates how to convert the SeaShips dataset from VOC (Pascal VOC) format to KITTI format using the vod-converter tool. It specifies the source and destination paths for the conversion. ```python python vod_converter/main.py --from voc --from-path ~/datasets/SeaShips --to kitti --to-path ~/datasets/SeaShips-kitti ``` -------------------------------- ### Fix Corrupt KITTI Dataset Text File Source: https://github.com/capai/misc/blob/master/tmp/merging/README.md This snippet provides a bash command to regenerate the 'train.txt' file for a KITTI dataset when it is corrupt. It lists image files and pipes their names to create a new 'train.txt'. ```bash cd datasets/kitti && ls -1 training/image_2 | cut -d. -f1 > train.txt && cd - ``` -------------------------------- ### Saving Sampled URLs to CSV File Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Saves the 'output' Series (containing sampled URLs) to a CSV file named 'MT_shiptype_Cruise_sample_190.txt'. The index and header are excluded from the output. ```python output.to_csv('/home/jetze/Downloads/texts/MT_shiptype_Cruise_sample_190.txt', index=False, header=False) ``` -------------------------------- ### Extracting Sample URL Per MMSI Group Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Groups 'df190' by 'mmsi', samples one row per group, and then extracts the 'url' column from these sampled rows. `group_keys=False` prevents adding group keys to the output index. ```python output = df190.groupby('mmsi', group_keys=False).apply(lambda df: df.sample(1))['url'] ``` -------------------------------- ### Reading Lines from a Text File Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Opens a text file named 'MT_passenger.txt' in read mode and reads all its lines into a list called 'tmp'. ```python with open('/home/jetze/Downloads/MT_passenger.txt', 'r') as f: tmp = f.readlines() ``` -------------------------------- ### Analyzing Unique MMSI Counts by Length Threshold Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Prints the count of unique 'mmsi' values for ships exceeding various length thresholds, providing insights into the distribution of larger vessels. ```python print(df[df['length']>60]['mmsi'].unique().shape) # 690 print(df[df['length']>80]['mmsi'].unique().shape) # 533 print(df[df['length']>100]['mmsi'].unique().shape) # 431 print(df[df['length']>120]['mmsi'].unique().shape) # 332 print(df[df['length']>140]['mmsi'].unique().shape) # 232 print(df[df['length']>160]['mmsi'].unique().shape) # 188 print(df[df['length']>180]['mmsi'].unique().shape) # 134 print(df[df['length']>190]['mmsi'].unique().shape) # 75 ``` -------------------------------- ### Creating Sub-DataFrame for Ships Over 160 Length Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Creates a new DataFrame 'df2' containing 'mmsi', 'url', and 'type' columns for ships with a 'length' greater than 160. A copy is made to avoid SettingWithCopyWarning. ```python df2 = df[df['length']>160][['mmsi','url','type']].copy() ``` -------------------------------- ### Loading Data from CSV into Pandas DataFrame Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Reads a CSV file containing passenger dimensions into a pandas DataFrame named 'df'. ```python df = pd.read_csv('/home/jetze/Downloads/passenger_dimensions.csv') ``` -------------------------------- ### Saving All URLs for Ships Over 190 Length to CSV Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Saves all 'url' values from the 'df190' DataFrame (ships over 190 length) to a CSV file named 'MT_shiptype_Cruise_candidates_190.txt'. The index and header are not included. ```python df190['url'].to_csv('/home/jetze/Downloads/texts/MT_shiptype_Cruise_candidates_190.txt', index=False, header=False) ``` -------------------------------- ### Creating Sub-DataFrame for Ships Over 190 Length Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Creates a new DataFrame 'df190' containing 'mmsi', 'url', and 'type' columns for ships with a 'length' greater than 190. A copy is made to ensure independent modification. ```python df190 = df[df['length']>190][['mmsi','url','type']].copy() ``` -------------------------------- ### Calculating Length and Width in DataFrame Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Calculates 'length' and 'width' columns in the DataFrame by summing existing dimension columns 'a' and 'b' for length, and 'c' and 'd' for width. ```python df['length'] = df['a'] + df['b'] df['width'] = df['c'] + df['d'] ``` -------------------------------- ### Generating Filename String in DataFrame (Potential Error) Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Attempts to create a 'fn' column by concatenating 'mmsi', 'type', and 'url' values. Note: The expression `df2.mmsi['mmsi']` is likely a typo and would cause an error, as `df2.mmsi` is a Series, not a DataFrame with a 'mmsi' column. ```python df2['fn'] = str(df2.mmsi['mmsi'])+ + str(df2['type']) + str(df2['url']) ``` -------------------------------- ### Removing Newline Characters from List Elements Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Creates a new list 'tmp2' by iterating through 'tmp' and removing newline characters from each string element. ```python tmp2 = [t.replace('\n', '') for t in tmp] ``` -------------------------------- ### Extracting Unique MMSI for Ships Over 190 Length Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Filters the original DataFrame 'df' for ships with 'length' greater than 190 and extracts their unique 'mmsi' values, storing them in the 'draft' variable. ```python draft = df[df['length']>190].mmsi.unique() ``` -------------------------------- ### Checking Type of First Character of MMSI Array String Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Converts the 'draft' array of unique MMSI values to its string representation, then converts that string to a list of characters, and finally checks the data type of the first character in this list. This is typically used for debugging or type verification. ```python type(list(str(draft))[0]) ``` -------------------------------- ### Checking Shape of DataFrame Filtered by Length Source: https://github.com/capai/misc/blob/master/tmp/Untitled.ipynb Displays the dimensions (rows, columns) of the DataFrame after filtering for entries where 'length' is greater than 190. ```python df[df['length']>190].shape ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.