public async void BulkExport(List <StorageFile> files, int maxFrames, int frameTime)
        {
            var picker2 = new FolderPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            picker2.FileTypeFilter.Add("*");
            // Select AEDAT file to be converted
            StorageFolder folder = await picker2.PickSingleFolderAsync();

            if (folder == null)
            {
                showLoading.IsActive      = false;
                backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                return;
            }

            foreach (StorageFile file in files)
            {
                var headerData = await AedatUtilities.GetHeaderData(file);

                var aedatFile = (await file.OpenReadAsync()).AsStreamForRead();
                aedatFile.Seek(headerData.Item1, SeekOrigin.Begin);//skip over header.

                // Determine camera type from AEDAT header
                CameraParameters cam = headerData.Item2;
                if (cam == null)
                {
                    await invalidCameraDataDialog.ShowAsync();

                    return;
                }
                showLoading.IsActive      = true;
                backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Visible;

                StorageFolder folder2 = await folder.CreateFolderAsync(file.Name.Replace(".aedat", "") + " EventChunks");

                if (playbackType.IsOn)
                {
                    await TimeBasedReconstruction(aedatFile, cam, frameTime, maxFrames, folder2, file.Name.Replace(".aedat", ""));
                }
                else
                {
                    int numOfEvents = Int32.Parse(numOfEventInput.Text);
                    await EventBasedReconstruction(aedatFile, cam, numOfEvents, maxFrames, folder2, file.Name.Replace(".aedat", ""));
                }
            }
            showLoading.IsActive      = false;
            backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }
        public static async Task <List <AEDATEvent> > GetEvents(StorageFile file)
        {
            var headerData = await AedatUtilities.GetHeaderData(file);

            int endOfHeaderIndex = headerData.Item1;
            CameraParameters cam = headerData.Item2;

            byte[] aedatBytes = new byte[5 * Convert.ToInt32(Math.Pow(10, 8))];             // Read 0.5 GB at a time

            var aedatFile = (await file.OpenReadAsync()).AsStreamForRead();

            aedatFile.Seek(endOfHeaderIndex, SeekOrigin.Begin);                 // Skip over header.

            List <AEDATEvent> tableData = new List <AEDATEvent>();

            if (cam == null)
            {
                ContentDialog invalidData = new ContentDialog()
                {
                    Title           = "Error",
                    Content         = "Could not parse camera parameters.",
                    CloseButtonText = "Close"
                };
                await invalidData.ShowAsync();

                return(null);
            }

            int bytesRead = aedatFile.Read(aedatBytes, 0, aedatBytes.Length);

            while (bytesRead != 0)
            {
                for (int i = 0, length = bytesRead; i < length; i += dataEntrySize)
                {
                    tableData.Add(new AEDATEvent(aedatBytes, i, cam));
                }
                bytesRead = aedatFile.Read(aedatBytes, 0, aedatBytes.Length);
            }
            return(tableData);
        }
        private async void SelectFile_Tapped(object sender, TappedRoutedEventArgs e)
        {
            EventColor onColor;
            EventColor offColor;
            int        frameTime;
            int        maxFrames;
            float      fps;

            try
            {
                // Grab video reconstruction settings from GUI
                // Will throw a FormatException if input is invalid (negative numbers or input has letters)
                (frameTime, maxFrames, onColor, offColor, fps) = ParseVideoSettings();
            }
            catch (FormatException)
            {
                await invaldVideoSettingsDialog.ShowAsync();

                return;
            }

            // Select AEDAT file to be converted to video
            var picker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            picker.FileTypeFilter.Add(".AEDAT");

            // Select AEDAT file to be converted
            StorageFile file = await picker.PickSingleFileAsync();

            if (file == null)
            {
                return;
            }

            var headerData = await AedatUtilities.GetHeaderData(file);

            var aedatFile = (await file.OpenReadAsync()).AsStreamForRead();

            aedatFile.Seek(headerData.Item1, SeekOrigin.Begin);                 // Skip over header.

            CameraParameters cam = headerData.Item2;

            if (cam == null)
            {
                await invalidCameraDataDialog.ShowAsync();

                return;
            }
            showLoading.IsActive      = true;
            backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Visible;
            float            playback_frametime = 1.0f / fps;
            MediaComposition composition;

            if (playbackType.IsOn)
            {
                composition = await TimeBasedReconstruction(aedatFile, cam, onColor, offColor, frameTime, maxFrames, playback_frametime);
            }
            else
            {
                int numOfEvents = Int32.Parse(numOfEventInput.Text);
                composition = await EventBasedReconstruction(aedatFile, cam, onColor, offColor, numOfEvents, maxFrames, playback_frametime);
            }
            SaveCompositionToFile(composition, file.DisplayName, cam.cameraX, cam.cameraY);
        }
Exemplo n.º 4
0
        private async void SelectFile_Tapped(object sender, TappedRoutedEventArgs e)
        {
            EventColor onColor;
            EventColor offColor;
            int        frameTime;
            int        maxFrames;

            try
            {
                // Grab video reconstruction settings from GUI
                // Will throw a FormatException if input is invalid (negative numbers or input has letters)
                (frameTime, maxFrames, onColor, offColor) = ParseFrameSettings();
            }
            catch (FormatException)
            {
                await invaldVideoSettingsDialog.ShowAsync();

                return;
            }

            // Select AEDAT file to be converted to video
            var picker = new FileOpenPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            picker.FileTypeFilter.Add(".AEDAT");


            // Select AEDAT file to be converted
            IReadOnlyList <StorageFile> files = await picker.PickMultipleFilesAsync();

            if (files == null)
            {
                showLoading.IsActive      = false;
                backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                return;
            }

            var picker2 = new FolderPicker
            {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.PicturesLibrary
            };

            picker2.FileTypeFilter.Add("*");

            // Select AEDAT file to be converted
            StorageFolder folder = await picker2.PickSingleFolderAsync();

            if (folder == null)
            {
                showLoading.IsActive      = false;
                backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                return;
            }

            foreach (var file in files)
            {
                var headerData = await AedatUtilities.GetHeaderData(file);

                var aedatFile = (await file.OpenReadAsync()).AsStreamForRead();
                aedatFile.Seek(headerData.Item1, SeekOrigin.Begin);                 //Skip over header.

                CameraParameters cam = headerData.Item2;
                if (cam == null)
                {
                    await invalidCameraDataDialog.ShowAsync();

                    return;
                }
                showLoading.IsActive      = true;
                backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Visible;


                StorageFolder folder2 = await folder.CreateFolderAsync(file.Name.Replace(".aedat", "") + (playbackType.IsOn ? " time based" : " event based") + " Frames");

                if (playbackType.IsOn)
                {
                    await TimeBasedReconstruction(aedatFile, cam, onColor, offColor, frameTime, maxFrames, folder2, file.Name.Replace(".aedat", ""));
                }
                else
                {
                    int numOfEvents = Int32.Parse(numOfEventInput.Text);
                    await EventBasedReconstruction(aedatFile, cam, onColor, offColor, numOfEvents, maxFrames, folder2, file.Name.Replace(".aedat", ""));
                }
            }
            showLoading.IsActive      = false;
            backgroundTint.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
        }