--- /dev/null
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace Tizen.NUI
+{
+ internal static partial class Interop
+ {
+ internal static partial class CameraView
+ {
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CameraView_New__SWIG_0")]
+ public static extern global::System.IntPtr New(global::System.IntPtr jarg1, int jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_CameraView__SWIG_0")]
+ public static extern global::System.IntPtr NewCameraView();
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_delete_CameraView")]
+ public static extern void DeleteCameraView(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_new_CameraView__SWIG_1")]
+ public static extern global::System.IntPtr NewCameraView(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CameraView_Assign")]
+ public static extern global::System.IntPtr Assign(global::System.Runtime.InteropServices.HandleRef jarg1, global::System.Runtime.InteropServices.HandleRef jarg2);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CameraView_DownCast")]
+ public static extern global::System.IntPtr DownCast(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CameraView_Update")]
+ public static extern void Update(global::System.Runtime.InteropServices.HandleRef jarg1);
+
+ [global::System.Runtime.InteropServices.DllImport(NDalicPINVOKE.Lib, EntryPoint = "CSharp_Dali_CameraView_SWIGUpcast")]
+ public static extern global::System.IntPtr Upcast(global::System.IntPtr jarg1);
+
+ }
+ }
+}
--- /dev/null
+/*
+ * Copyright(c) 2021 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+using System;
+using System.ComponentModel;
+using System.Runtime.InteropServices;
+
+namespace Tizen.NUI.BaseComponents
+{
+ /// <summary>
+ /// CameraView is a view for camera preview.
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public class CameraView : View
+ {
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public enum DisplayType
+ {
+ Window = 0, // HW overlay
+ Image // texture stream
+ };
+
+ /// <summary>
+ /// Creates an initialized CameraView.
+ /// </summary>
+ /// <param name="handle">Multimedia Camera handle</param>
+ /// <param name="type">DisplayType</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public CameraView(global::System.IntPtr handle, DisplayType type = DisplayType.Window) : this(Interop.CameraView.New(handle, (int)type), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ internal CameraView(CameraView cameraView) : this(Interop.CameraView.NewCameraView(CameraView.getCPtr(cameraView)), true)
+ {
+ if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
+ }
+
+ internal CameraView(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
+ {
+ }
+
+ internal static global::System.Runtime.InteropServices.HandleRef getCPtr(CameraView obj)
+ {
+ return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
+ }
+
+ /// <summary>
+ /// Called when the camera view needs to be updated if the camera setting is changed..
+ /// </summary>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ public void Update()
+ {
+ Interop.CameraView.Update(SwigCPtr);
+ }
+
+ /// <summary>
+ /// Dispose.
+ /// </summary>
+ /// <param name="type">DisposeTypes</param>
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void Dispose(DisposeTypes type)
+ {
+ if (disposed)
+ {
+ return;
+ }
+
+ base.Dispose(type);
+ }
+
+ /// This will not be public opened.
+ [EditorBrowsable(EditorBrowsableState.Never)]
+ protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
+ {
+ Interop.CameraView.DeleteCameraView(swigCPtr);
+ }
+ }
+
+}
--- /dev/null
+
+using global::System;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.Samples
+{
+ using tlog = Tizen.Log;
+
+ public class CameraVideoViewTest : IExample
+ {
+
+ Window win;
+ CameraView cameraView;
+ VideoView videoView;
+ Tizen.Multimedia.Camera camera;
+
+ const string tag = "gab_test";
+
+ public void Activate()
+ {
+ win = NUIApplication.GetDefaultWindow();
+ win.BackgroundColor = new Color(1, 1, 1, 0);
+ win.KeyEvent += Win_KeyEvent;
+
+ AddCameraView();
+ AddVideoView();
+ }
+
+ private void AddCameraView()
+ {
+ camera = new Tizen.Multimedia.Camera(Tizen.Multimedia.CameraDevice.Front);
+
+ // default display type is Window (Overlay mode)
+ cameraView = new CameraView(camera.Handle, CameraView.DisplayType.Window);
+ cameraView.Size = new Size(300, 300);
+ cameraView.Position = new Position(100, 50);
+
+ if (camera != null && camera.State == Tizen.Multimedia.CameraState.Created)
+ {
+ camera.StartPreview();
+ }
+ win.Add(cameraView);
+ }
+
+ private void AddVideoView()
+ {
+ videoView = new VideoView();
+ videoView.Underlay = false;
+ string resourcePath = Tizen.Applications.Application.Current.DirectoryInfo.Resource + "v.mp4";
+ videoView.ResourceUrl = resourcePath;
+ videoView.Looping = true;
+ videoView.Size = new Size(300, 300);
+ videoView.Position = new Position(100, 360);
+ videoView.Play();
+ win.Add(videoView);
+ }
+
+ public void Deactivate()
+ {
+ win.KeyEvent -= Win_KeyEvent;
+
+ if (camera != null )
+ {
+ if(camera.State == Tizen.Multimedia.CameraState.Preview)
+ camera.StopPreview();
+
+ camera.Dispose();
+ }
+
+ videoView.Dispose();
+
+ tlog.Fatal(tag, $"Deactivate()! cameraView dispsed");
+ }
+
+
+ private void Win_KeyEvent(object sender, Window.KeyEventArgs e)
+ {
+ if (e.Key.State == Key.StateType.Down)
+ {
+ tlog.Fatal(tag, $"key pressed name={e.Key.KeyPressedName}");
+ if (e.Key.KeyPressedName == "XF86Back")
+ {
+ Deactivate();
+ }
+ }
+ }
+
+ }
+}
+
+
--- /dev/null
+
+using global::System;
+using Tizen.NUI.BaseComponents;
+using Tizen.NUI.Components;
+
+namespace Tizen.NUI.Samples
+{
+ using tlog = Tizen.Log;
+
+ public class CameraViewTest : IExample
+ {
+
+ Window win;
+ CameraView overlayCameraView;
+ CameraView imageCameraView;
+ Button overlayButton;
+ Button nativeButton;
+ Button sizeButton;
+ Button rotationButton;
+
+ Tizen.Multimedia.Camera overlayCamera;
+ Tizen.Multimedia.Camera imageCamera;
+
+ const string tag = "NUI";
+
+ public void Activate()
+ {
+ win = NUIApplication.GetDefaultWindow();
+ win.BackgroundColor = new Color(1, 1, 1, 0);
+ win.KeyEvent += Win_KeyEvent;
+
+ overlayButton = new Button();
+ overlayButton.Text = "Overlay";
+ overlayButton.Size = new Size(100, 100);
+ overlayButton.Position = new Position( 50, 750);
+ overlayButton.Clicked += OverlayButtonClicked;
+ win.Add(overlayButton);
+
+ nativeButton = new Button();
+ nativeButton.Text = "Image";
+ nativeButton.Size = new Size(100, 100);
+ nativeButton.Position = new Position( 160, 750);
+ nativeButton.Clicked += NativeButtonClicked;
+ win.Add(nativeButton);
+
+ sizeButton = new Button();
+ sizeButton.Text = "Size";
+ sizeButton.Size = new Size(100, 100);
+ sizeButton.Position = new Position(50, 850);
+ sizeButton.Clicked += sizeButtonClicked;
+ win.Add(sizeButton);
+
+
+ rotationButton = new Button();
+ rotationButton.Text = "Rotation";
+ rotationButton.Size = new Size(100, 100);
+ rotationButton.Position = new Position(160, 850);
+ rotationButton.Clicked += rotationButtonClicked;
+ win.Add(rotationButton);
+
+ OverlayCamera();
+ // ImageCamera();
+
+ }
+
+ private int rotationCnt = 0;
+ private void rotationButtonClicked(object sender, ClickedEventArgs e)
+ {
+ int rotation = rotationCnt % 4;
+ Vector3 axis;
+ Degree degree;
+ if(overlayCamera != null) {
+ switch(rotation)
+ {
+ case 0 :
+ overlayCamera.DisplaySettings.Rotation = Tizen.Multimedia.Rotation.Rotate0;
+ overlayCameraView.Update();
+ break;
+ case 1:
+ overlayCamera.DisplaySettings.Rotation = Tizen.Multimedia.Rotation.Rotate90;
+ overlayCameraView.Update();
+ break;
+ case 2:
+ overlayCamera.DisplaySettings.Rotation = Tizen.Multimedia.Rotation.Rotate180;
+ overlayCameraView.Update();
+ break;
+ case 3:
+ overlayCamera.DisplaySettings.Rotation = Tizen.Multimedia.Rotation.Rotate270;
+ overlayCameraView.Update();
+ break;
+ default:
+ overlayCamera.DisplaySettings.Rotation = Tizen.Multimedia.Rotation.Rotate0;
+ overlayCameraView.Update();
+ break;
+ }
+ }
+ rotationCnt++;
+ }
+
+ private void OverlayButtonClicked(object sender, ClickedEventArgs e)
+ {
+ if(imageCamera != null)
+ {
+ imageCamera.StopPreview();
+ imageCamera.Dispose();
+ imageCamera = null;
+ win.Remove(imageCameraView);
+ }
+ if(overlayCamera == null)
+ {
+ OverlayCamera();
+ }
+ }
+
+ private void NativeButtonClicked(object sender, ClickedEventArgs e)
+ {
+ if(overlayCamera != null)
+ {
+ overlayCamera.StopPreview();
+ overlayCamera.Dispose();
+ overlayCamera = null;
+ win.Remove(overlayCameraView);
+ }
+ if(imageCamera == null)
+ {
+ ImageCamera();
+ }
+ }
+
+ private void OverlayCamera()
+ {
+
+ overlayCamera = new Tizen.Multimedia.Camera(Tizen.Multimedia.CameraDevice.Front);
+ // default display type is Window (Overlay mode)
+ overlayCameraView = new CameraView(overlayCamera.Handle);
+ overlayCameraView.PositionUsesPivotPoint = true;
+ overlayCameraView.ParentOrigin = ParentOrigin.TopLeft;
+ overlayCameraView.PivotPoint = PivotPoint.TopLeft;
+ overlayCameraView.Size = new Size(300, 400);
+ overlayCameraView.Position = new Position(100, 200);
+
+ overlayCamera.StartPreview();
+
+ win.Add(overlayCameraView);
+ }
+
+ private void ImageCamera()
+ {
+
+ imageCamera = new Tizen.Multimedia.Camera(Tizen.Multimedia.CameraDevice.Front);
+ // default display type is Window (Overlay mode)
+ imageCameraView = new CameraView(imageCamera.Handle, CameraView.DisplayType.Image);
+ imageCameraView.PositionUsesPivotPoint = true;
+ imageCameraView.ParentOrigin = ParentOrigin.TopLeft;
+ imageCameraView.PivotPoint = PivotPoint.TopLeft;
+ imageCameraView.Position = new Position(0, 400);
+ imageCameraView.Size = new Size(300, 300);
+
+ imageCamera.StartPreview();
+
+ win.Add(imageCameraView);
+ }
+
+ private int size = 300;
+ private void sizeButtonClicked(object sender, ClickedEventArgs e)
+ {
+ if(overlayCameraView != null)
+ overlayCameraView.Size = new Size(size, size);
+ if(imageCameraView != null)
+ imageCameraView.Size = new Size(size, size);
+ size += 20;
+ }
+
+
+ public void Deactivate()
+ {
+ win.KeyEvent -= Win_KeyEvent;
+
+ if(imageCamera != null)
+ {
+
+ imageCamera.StopPreview();
+ imageCamera.Dispose();
+ imageCamera = null;
+
+ win.Remove(imageCameraView);
+ imageCameraView.Dispose();
+ }
+
+ if(overlayCamera != null)
+ {
+ overlayCamera.StopPreview();
+ overlayCamera.Dispose();
+ overlayCamera = null;
+ win.Remove(overlayCameraView);
+ overlayCameraView.Dispose();
+ }
+
+
+ tlog.Fatal(tag, $"Deactivate()! cameraView disposed");
+ }
+
+
+ private void Win_KeyEvent(object sender, Window.KeyEventArgs e)
+ {
+ if (e.Key.State == Key.StateType.Down)
+ {
+ tlog.Fatal(tag, $"key pressed name={e.Key.KeyPressedName}");
+ if (e.Key.KeyPressedName == "XF86Back")
+ {
+ Deactivate();
+ }
+ }
+ }
+
+ }
+}
+
+
+
<ProjectReference Include="../../../src/Tizen.Applications.ComponentBased/Tizen.Applications.ComponentBased.csproj" />
<ProjectReference Include="../../../src/Tizen.Log/Tizen.Log.csproj" />
<ProjectReference Include="../../../src/Tizen.Multimedia.MediaPlayer/Tizen.Multimedia.MediaPlayer.csproj" />
+ <ProjectReference Include="../../../src/Tizen.Multimedia.Camera/Tizen.Multimedia.Camera.csproj" />
<ProjectReference Include="../../../src/Tizen.System.SystemSettings/Tizen.System.SystemSettings.csproj" />
<ProjectReference Include="../../../src/Tizen.NUI/Tizen.NUI.csproj" />
<ProjectReference Include="../../../src/Tizen.NUI.Components/Tizen.NUI.Components.csproj" />
<icon>Tizen.NUI.Samples.png</icon>
<metadata key="http://tizen.org/metadata/prefer_dotnet_aot" value="true" />
</ui-application>
+ <privileges>
+ <privilege>http://tizen.org/privilege/camera</privilege>
+ </privileges>
</manifest>