protected override void OnLoad(EventArgs e) { // 設定影像輸入 inputSource = new ImageSource(ResourcesPath + "image_test.jpg"); //inputSource = new VideoSource(@"..\..\..\resources\video_test.mp4"); //inputSource = new StreamSource(); // 創建場景 scene = new Scene(); model = Model.LoadModel(ResourcesPath + @"models\IronMan\IronMan.obj"); // 請輸入您的模型路徑 scene.Models.Add(model); // 調整模型大小 model.Resize(0.035f); // 加入燈光 // scene.Lights.Add(new AmbientLight(Color4.White, 0.8f)); // 建立 workflow 物件 workflow = new ArWorkflow(inputSource); // 設定 marker 對應的 scene Bitmap marker = new Bitmap(ResourcesPath + "marker.png"); // 請輸入您 Marker 圖檔的路徑 workflow.MarkerPairs[marker] = scene; workflow.TrainMarkers(); // 修改後一定要執行!! // 開啟光源追蹤模組 workflow.EnableLightTracking = true; // 開啟色彩融合模組 //workflow.EnableColorHarmonizing = true; base.OnLoad(e); }
protected override void OnLoad(EventArgs e) { // 設定影像輸入 inputSource = new ImageSource("圖片.jpg"); // 建立 workflow 物件 workflow = new ArWorkflow(inputSource); // 導入 marker圖像 marker = new Bitmap("marker.jpg"); // 設定場景 scene = new Scene(); // ... // 設定 marker 對應的 scene workflow.MarkerPairs[marker] = scene; // 啟用需要的擬真方法 // LightSourceSimulation = true; // ColorTransfer = true; base.OnLoad(e); }
public void SetParams(Input input, string inputPath, string markerPath, string modelPath, float resizeRate, float rotationX, float rotationY, float rotationZ, bool lightTracking, bool colorHarmonizing, bool spin) { if (input == Input.Image) { inputSource = new ImageSource(inputPath); } else if (input == Input.Video) { inputSource = new VideoSource(inputPath); } else { inputSource = new StreamSource(int.Parse(inputPath)); } workflow = new ArWorkflow(inputSource); scene = new Scene(); model = Model.LoadModel(modelPath); model.Resize(resizeRate); model.Rotation(x: rotationX, y: rotationY, z: rotationZ); scene.Models.Add(model); if (!lightTracking) { scene.Lights.Add(new AmbientLight(Color4.White, 0.8f)); } Bitmap marker = new Bitmap(markerPath); workflow.MarkerPairs[marker] = scene; workflow.TrainMarkers(); workflow.EnableLightTracking = lightTracking; workflow.EnableColorHarmonizing = colorHarmonizing; this.spin = spin; }