diff --git a/FexTracker/FexTrackerRel.dll b/FexTracker/FexTrackerRel.dll index 15a35bbdc..6e9ba7390 100644 Binary files a/FexTracker/FexTrackerRel.dll and b/FexTracker/FexTrackerRel.dll differ diff --git a/FexTracker/FexTrackerRel.lib b/FexTracker/FexTrackerRel.lib index b49534a48..16572f282 100644 Binary files a/FexTracker/FexTrackerRel.lib and b/FexTracker/FexTrackerRel.lib differ diff --git a/FexTracker/FexTrackerRel_Opti.dll b/FexTracker/FexTrackerRel_Opti.dll index 73f1e2b16..36de0f8d2 100644 Binary files a/FexTracker/FexTrackerRel_Opti.dll and b/FexTracker/FexTrackerRel_Opti.dll differ diff --git a/FexTracker/FexTrackerRel_Opti.lib b/FexTracker/FexTrackerRel_Opti.lib index 382cfc32b..263b8742b 100644 Binary files a/FexTracker/FexTrackerRel_Opti.lib and b/FexTracker/FexTrackerRel_Opti.lib differ diff --git a/core/FexTracker.h b/core/FexTracker.h index 09902b456..5787680b0 100644 --- a/core/FexTracker.h +++ b/core/FexTracker.h @@ -17,6 +17,7 @@ class FEXTRACKER_API FexTrackerConfig { public: inline FexTrackerConfig() : + FeatureNumber(0), EdgeDetectSigma(1.f), WindowX(3), WindowY(3), SearchRange(15), @@ -29,6 +30,8 @@ public: MinDistanceSquare(100.f) {}; + int FeatureNumber; + int WindowX, WindowY; //static const int window_size = 7; int SearchRange; diff --git a/core/bitmaps/button_track_move.bmp b/core/bitmaps/button_track_move.bmp new file mode 100644 index 000000000..db356c2a7 Binary files /dev/null and b/core/bitmaps/button_track_move.bmp differ diff --git a/core/bitmaps/button_track_movement.bmp b/core/bitmaps/button_track_movement.bmp index 06a5f1d82..101e7cc69 100644 Binary files a/core/bitmaps/button_track_movement.bmp and b/core/bitmaps/button_track_movement.bmp differ diff --git a/core/bitmaps/button_track_point_add.bmp b/core/bitmaps/button_track_point_add.bmp index 9feacbf62..03129a4c2 100644 Binary files a/core/bitmaps/button_track_point_add.bmp and b/core/bitmaps/button_track_point_add.bmp differ diff --git a/core/bitmaps/button_track_point_del.bmp b/core/bitmaps/button_track_point_del.bmp index 4757fa4c6..7e0fddee2 100644 Binary files a/core/bitmaps/button_track_point_del.bmp and b/core/bitmaps/button_track_point_del.bmp differ diff --git a/core/bitmaps/button_track_trail.bmp b/core/bitmaps/button_track_trail.bmp new file mode 100644 index 000000000..51e6b33c0 Binary files /dev/null and b/core/bitmaps/button_track_trail.bmp differ diff --git a/core/dialog_fextracker.cpp b/core/dialog_fextracker.cpp new file mode 100644 index 000000000..3cd5cdd67 --- /dev/null +++ b/core/dialog_fextracker.cpp @@ -0,0 +1,121 @@ +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +/////////// +// Headers +#include "dialog_fextracker.h" +#include "FexTracker.h" + + +/////////////// +// Constructor +DialogFexTracker::DialogFexTracker(wxWindow *parent, FexTrackerConfig *_cfg) +: wxDialog (parent,-1,_("Tracker configuration"),wxDefaultPosition) +{ + cfg = _cfg; + cfg->FeatureNumber = 0; + + wxNotebook *MainNB = new wxNotebook(this,-1, wxDefaultPosition, wxSize(300,500), wxNO_BORDER ); + + wxWindow *StdWnd = new wxPanel(MainNB,-1); + wxWindow *AdvWnd = new wxPanel(MainNB,-1); + + FeatureNumber = new wxTextCtrl(StdWnd,-1,_T("250")); + MinDistanceSquare = new wxTextCtrl(StdWnd,-1,_T("100")); + SearchRange = new wxTextCtrl(StdWnd,-1,_T("15")); + MaxResidue = new wxTextCtrl(StdWnd,-1,_T("10")); + MaxIterations = new wxTextCtrl(StdWnd,-1,_T("10")); + + EdgeDetectSigma = new wxTextCtrl(AdvWnd,-1,_T("1.0")); + WindowX = new wxTextCtrl(AdvWnd,-1,_T("3")); + WindowY = new wxTextCtrl(AdvWnd,-1,_T("3")); + MinDeterminant = new wxTextCtrl(AdvWnd,-1,_T("0.01")); + MinDisplacement = new wxTextCtrl(AdvWnd,-1,_T("0.1")); + + wxSizer *Sizer = new wxBoxSizer(wxVERTICAL); + wxStaticText *Static; + Static = new wxStaticText(StdWnd,-1,_("Number of points to track:")); + Sizer->Add(Static,0,wxALIGN_LEFT,5); + Sizer->Add(FeatureNumber,0,wxALIGN_LEFT,5); + Static = new wxStaticText(StdWnd,-1,_("Minimal (sqared) distance between two points: ")); + Sizer->Add(Static,0,wxALIGN_LEFT,5); + Sizer->Add(MinDistanceSquare,0,wxALIGN_LEFT,5); + Static = new wxStaticText(StdWnd,-1,_("Maximum feature movement:")); + Sizer->Add(Static,0,wxALIGN_LEFT,5); + Sizer->Add(SearchRange,0,wxALIGN_LEFT,5); + Static = new wxStaticText(StdWnd,-1,_("Maximum feature appearance change:")); + Sizer->Add(Static,0,wxALIGN_LEFT,5); + Sizer->Add(MaxResidue,0,wxALIGN_LEFT,5); + Static = new wxStaticText(StdWnd,-1,_("How much CPU per feature?")); + Sizer->Add(Static,0,wxALIGN_LEFT,5); + Sizer->Add(MaxIterations,0,wxALIGN_LEFT,5); + + wxSizer *SizerAdd = new wxBoxSizer(wxVERTICAL); + Static = new wxStaticText(AdvWnd,-1,_("Edge detect filter size:")); + SizerAdd->Add(Static,0,wxALIGN_LEFT,5); + SizerAdd->Add(EdgeDetectSigma,0,wxALIGN_LEFT,5); + Static = new wxStaticText(AdvWnd,-1,_("Feature comparison width:")); + SizerAdd->Add(Static,0,wxALIGN_LEFT,5); + SizerAdd->Add(WindowX,0,wxALIGN_LEFT,5); + Static = new wxStaticText(AdvWnd,-1,_("Feature comparison height:")); + SizerAdd->Add(Static,0,wxALIGN_LEFT,5); + SizerAdd->Add(WindowY,0,wxALIGN_LEFT,5); + Static = new wxStaticText(AdvWnd,-1,_("Minimal determinant:")); + SizerAdd->Add(Static,0,wxALIGN_LEFT,5); + SizerAdd->Add(MinDeterminant,0,wxALIGN_LEFT,5); + Static = new wxStaticText(AdvWnd,-1,_("Minimal displacement per iteration:")); + SizerAdd->Add(Static,0,wxALIGN_LEFT,5); + SizerAdd->Add(MinDisplacement,0,wxALIGN_LEFT,5); + + StdWnd->SetSizer( Sizer ); + StdWnd->SetAutoLayout( 1 ); + MainNB->AddPage( StdWnd, _T("Standard Settings") ); + + AdvWnd->SetSizer( SizerAdd ); + AdvWnd->SetAutoLayout( 1 ); + MainNB->AddPage( AdvWnd, _T("Advanced Settings") ); + + wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); + MainSizer->Add(MainNB,1,wxEXPAND|wxALL,5); + MainSizer->AddSpacer(2); + wxButton *but = new wxButton(this,BUTTON_START,_("Go!")); + MainSizer->Add(but,0,wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER,5); + + MainSizer->SetSizeHints( this ); + SetSizer(MainSizer); + SetAutoLayout(true); + CenterOnParent(); +} + + +/////////////// +// Event table +BEGIN_EVENT_TABLE(DialogFexTracker,wxDialog) + EVT_BUTTON(BUTTON_START,DialogFexTracker::OnStart) +END_EVENT_TABLE() + + +//////////// +// OnStart +void DialogFexTracker::OnStart (wxCommandEvent &event) { + cfg->FeatureNumber = 0; + + swscanf( FeatureNumber->GetValue(), _T("%d"), &cfg->FeatureNumber ); + swscanf( WindowX->GetValue(), _T("%d"), &cfg->WindowX ); + swscanf( WindowY->GetValue(), _T("%d"), &cfg->WindowY ); + swscanf( SearchRange->GetValue(), _T("%d"), &cfg->SearchRange ); + swscanf( MaxIterations->GetValue(), _T("%d"), &cfg->MaxIterations ); + + swscanf( EdgeDetectSigma->GetValue(), _T("%f"), &cfg->EdgeDetectSigma ); + swscanf( MinDeterminant->GetValue(), _T("%f"), &cfg->MinDeterminant ); + swscanf( MinDisplacement->GetValue(), _T("%f"), &cfg->MinDisplacement ); + swscanf( MaxResidue->GetValue(), _T("%f"), &cfg->MaxResidue ); + swscanf( MinDistanceSquare->GetValue(), _T("%f"), &cfg->MinDistanceSquare ); + + EndModal(0); +} + diff --git a/core/dialog_fextracker.h b/core/dialog_fextracker.h new file mode 100644 index 000000000..01e287300 --- /dev/null +++ b/core/dialog_fextracker.h @@ -0,0 +1,54 @@ +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +#ifndef DIALOG_FEXTRACKER_H +#define DIALOG_FEXTRACKER_H + + +/////////// +// Headers +#include + + +////////////// +// Prototypes +class FexTrackerConfig; + + +///////// +// Class +class DialogFexTracker : public wxDialog { +private: + FexTrackerConfig * cfg; + + wxTextCtrl *FeatureNumber; + wxTextCtrl *EdgeDetectSigma; + wxTextCtrl *WindowX, *WindowY; + wxTextCtrl *SearchRange; + wxTextCtrl *MaxIterations; + wxTextCtrl *MinDeterminant; + wxTextCtrl *MinDisplacement; + wxTextCtrl *MaxResidue; + wxTextCtrl *MinDistanceSquare; + + void OnStart (wxCommandEvent &event); + +public: + DialogFexTracker(wxWindow *parent, FexTrackerConfig * cfg); + + DECLARE_EVENT_TABLE() +}; + + +/////// +// IDs +enum { + BUTTON_START = 1520, +}; + + +#endif diff --git a/core/fextracker_main_events.cpp b/core/fextracker_main_events.cpp new file mode 100644 index 000000000..6ccf9e4a2 --- /dev/null +++ b/core/fextracker_main_events.cpp @@ -0,0 +1,246 @@ +// AEGISUB +// +// Website: http://aegisub.cellosoft.com +// Contact: mailto:zeratul@cellosoft.com +// + + +/////////////////// +// Include headers +#include +#include +#include +#include +#include +#include "subs_grid.h" +#include "frame_main.h" +#include "video_display.h" +#include "video_slider.h" +#include "video_zoom.h" +#include "video_box.h" +#include "ass_file.h" +#include "dialog_style_manager.h" +#include "dialog_translation.h" +#include "dialog_jumpto.h" +#include "dialog_shift_times.h" +#include "dialog_search_replace.h" +#include "vfr.h" +#include "subs_edit_box.h" +#include "options.h" +#include "dialog_properties.h" +#include "main.h" +#include "fonts_collector.h" +#include "about.h" +#include "automation_gui.h" +#include "dialog_export.h" +#include "audio_box.h" +#include "aspell_wrap.h" +#include "dialog_spellcheck.h" +#include "dialog_selection.h" +#include "dialog_styling_assistant.h" +#include "dialog_resample.h" +#include "audio_display.h" +#include "toggle_bitmap.h" +#include "dialog_hotkeys.h" +#include "dialog_timing_processor.h" +#include "FexTracker.h" +#include "FexTrackingFeature.h" +#include "FexMovement.h" +#include "dialog_progress.h" +#include "dialog_fextracker.h" + + + +/////////////////// +// Tracker Menu +void FrameMain::OnVideoTrackerMenu(wxCommandEvent &event) { + wxMenu menu( _("FexTracker") ); + AppendBitmapMenuItem(&menu, Video_Track_Points, _("track points"), _(""), wxBITMAP(button_track_points)); + menu.AppendSeparator(); + AppendBitmapMenuItem(&menu, Video_Track_Point_Add, _("add points to movement"), _(""), wxBITMAP(button_track_point_add)); + AppendBitmapMenuItem(&menu, Video_Track_Point_Del, _("remove points from movement"), _(""), wxBITMAP(button_track_point_del)); + menu.AppendSeparator(); + AppendBitmapMenuItem(&menu, Video_Track_Movement, _("generate movement from points"), _(""), wxBITMAP(button_track_movement)); + PopupMenu(&menu); +} + + +/////////////////// +// Movement Menu +void FrameMain::OnVideoTrackerMenu2(wxCommandEvent &event) { + wxMenu menu( _("FexMovement") ); + AppendBitmapMenuItem(&menu, Video_Track_Movement_MoveAll, _("move subtitle"), _(""), wxBITMAP(button_track_move)); + AppendBitmapMenuItem(&menu, Video_Track_Movement_MoveOne, _("move subtitle only in this frame"), _(""), wxBITMAP(button_track_move)); + menu.AppendSeparator(); + AppendBitmapMenuItem(&menu, Video_Track_Split_Line, _("split line for movement"), _(""), wxBITMAP(button_track_split_line)); + PopupMenu(&menu); +} + + +/////////////////// +// Track current line +void FrameMain::OnVideoTrackPoints(wxCommandEvent &event) { + videoBox->videoDisplay->Stop(); + + // Get line + AssDialogue *curline = SubsBox->GetDialogue(EditBox->linen); + if (!curline) return; + + FexTrackerConfig config; + DialogFexTracker configDlg( this, &config ); + configDlg.ShowModal(); + + if( !config.FeatureNumber ) return; + + // Get Video + bool usedDirectshow; + VideoProvider *movie = new VideoProvider(videoBox->videoDisplay->videoName, wxString(_T("")), 1.0,usedDirectshow,true); + + // Create Tracker + if( curline->Tracker ) delete curline->Tracker; + curline->Tracker = new FexTracker( movie->GetWidth(), movie->GetHeight(), config.FeatureNumber ); + curline->Tracker->minFeatures = config.FeatureNumber; + curline->Tracker->Cfg = config; + + // Start progress + volatile bool canceled = false; + DialogProgress *progress = new DialogProgress(this,_("FexTracker"),&canceled,_("Tracking points"),0,1); + progress->Show(); + + // Allocate temp image + float* FloatImg = new float[ movie->GetWidth()*movie->GetHeight() ]; + + int StartFrame = VFR_Output.CorrectFrameAtTime(curline->Start.GetMS(),true); + int EndFrame = VFR_Output.CorrectFrameAtTime(curline->End.GetMS(),false); + + for( int Frame = StartFrame; Frame <= EndFrame; Frame ++ ) + { + progress->SetProgress( Frame-StartFrame, EndFrame-StartFrame ); + if( canceled ) break; + + movie->GetFloatFrame( FloatImg, Frame ); + curline->Tracker->ProcessImage( FloatImg ); + } + + delete FloatImg; + delete movie; + + // Clean up progress + if (!canceled) + progress->Destroy(); + else + { + delete curline->Tracker; + curline->Tracker = 0; + } + + videoBox->videoDisplay->RefreshVideo(); +} + + +/////////////////// +// Track current line +void FrameMain::OnVideoTrackMovement(wxCommandEvent &event) { + videoBox->videoDisplay->Stop(); + + // Get line + AssDialogue *curline = SubsBox->GetDialogue(EditBox->linen); + if (!curline) return; + if( !curline->Tracker ) return; + + // Create Movement + if( curline->Movement ) DeleteMovement( curline->Movement ); + curline->Movement = curline->Tracker->GetMovement(); + + // Remove Tracker + delete curline->Tracker; + curline->Tracker = 0; + + videoBox->videoDisplay->RefreshVideo(); +} + + +/////////////////// +// split current line +void FrameMain::OnVideoTrackSplitLine(wxCommandEvent &event) { + videoBox->videoDisplay->Stop(); + + // Get line + AssDialogue *curline = SubsBox->GetDialogue(EditBox->linen); + if (!curline) return; + if( !curline->Movement ) return; + + // Create split lines + int StartFrame = VFR_Output.CorrectFrameAtTime(curline->Start.GetMS(),true); + int EndFrame = VFR_Output.CorrectFrameAtTime(curline->End.GetMS(),false); + + AssFile *subs = AssFile::top; + int ResXValue,ResYValue; + swscanf( subs->GetScriptInfo(_T("PlayResX")), _T("%d"), &ResXValue ); + swscanf( subs->GetScriptInfo(_T("PlayResY")), _T("%d"), &ResYValue ); + int SrcXValue = videoBox->videoDisplay->provider->GetSourceWidth(); + int SrcYValue = videoBox->videoDisplay->provider->GetSourceHeight(); + + float sx = float(ResXValue)/float(SrcXValue); + float sy = float(ResYValue)/float(SrcYValue); + + for( int Frame = StartFrame; Frame < EndFrame; Frame ++ ) + { + int localframe = Frame - StartFrame; + + while( curline->Movement->Frames.size() <= localframe ) localframe--; + FexMovementFrame f = curline->Movement->Frames[localframe]; +// f.Pos.x /= videoBox->videoDisplay->GetW + + AssDialogue *cur = new AssDialogue( curline->data ); + cur->Start.SetMS(VFR_Output.CorrectTimeAtFrame(Frame,true)); + cur->End.SetMS(VFR_Output.CorrectTimeAtFrame(Frame,false)); + cur->Text = wxString::Format( _T("{\\pos(%.0f,%.0f)\\fscx%.2f\\fscy%.2f}"), f.Pos.x*sx, f.Pos.y*sy, f.Scale.x*100, f.Scale.y*100 ) + cur->Text; + cur->UpdateData(); + + SubsBox->InsertLine(cur,EditBox->linen + Frame - StartFrame,true,false); + } + + // Remove Movement + DeleteMovement( curline->Movement ); + curline->Movement = 0; + + // Remove this line + SubsBox->DeleteLines( EditBox->linen, EditBox->linen, false ); + + videoBox->videoDisplay->RefreshVideo(); +} + + +/////////////////// +// Increase Influence +void FrameMain::OnVideoTrackPointAdd(wxCommandEvent &event) { + videoBox->videoDisplay->TrackerEdit = 1; + videoBox->videoDisplay->bTrackerEditing = 0; +} + + +/////////////////// +// Decrease Influence +void FrameMain::OnVideoTrackPointDel(wxCommandEvent &event) { + videoBox->videoDisplay->TrackerEdit = -1; + videoBox->videoDisplay->bTrackerEditing = 0; +} + + +/////////////////// +// Move All +void FrameMain::OnVideoTrackMovementMoveAll(wxCommandEvent &event) { + videoBox->videoDisplay->MovementEdit = 1; + videoBox->videoDisplay->bTrackerEditing = 0; +} + + +/////////////////// +// Move One +void FrameMain::OnVideoTrackMovementMoveOne(wxCommandEvent &event) { + videoBox->videoDisplay->MovementEdit = 2; + videoBox->videoDisplay->bTrackerEditing = 0; +} + + diff --git a/core/frame_main.h b/core/frame_main.h index 794824804..7e18e85ea 100644 --- a/core/frame_main.h +++ b/core/frame_main.h @@ -110,7 +110,10 @@ private: void OnVideoTrackPoints(wxCommandEvent &event); void OnVideoTrackPointAdd(wxCommandEvent &event); void OnVideoTrackPointDel(wxCommandEvent &event); + void OnVideoTrackerMenu2(wxCommandEvent &event); void OnVideoTrackMovement(wxCommandEvent &event); + void OnVideoTrackMovementMoveAll(wxCommandEvent &event); + void OnVideoTrackMovementMoveOne(wxCommandEvent &event); void OnVideoTrackSplitLine(wxCommandEvent &event); void OnKeyDown(wxKeyEvent &event); @@ -333,7 +336,10 @@ enum { Video_Track_Points, Video_Track_Point_Add, Video_Track_Point_Del, + Video_Tracker_Menu2, Video_Track_Movement, + Video_Track_Movement_MoveAll, + Video_Track_Movement_MoveOne, Video_Track_Split_Line, Menu_File_Recent = 2000, diff --git a/core/frame_main_events.cpp b/core/frame_main_events.cpp index 24c1be30c..5ed956c96 100644 --- a/core/frame_main_events.cpp +++ b/core/frame_main_events.cpp @@ -76,6 +76,7 @@ #include "FexTrackingFeature.h" #include "FexMovement.h" #include "dialog_progress.h" +#include "dialog_fextracker.h" //////////////////// @@ -94,6 +95,9 @@ BEGIN_EVENT_TABLE(FrameMain, wxFrame) EVT_MENU(Video_Track_Point_Add, FrameMain::OnVideoTrackPointAdd) EVT_MENU(Video_Track_Point_Del, FrameMain::OnVideoTrackPointDel) EVT_MENU(Video_Track_Movement, FrameMain::OnVideoTrackMovement) + EVT_BUTTON(Video_Tracker_Menu2, FrameMain::OnVideoTrackerMenu2) + EVT_MENU(Video_Track_Movement_MoveAll, FrameMain::OnVideoTrackMovementMoveAll) + EVT_MENU(Video_Track_Movement_MoveOne, FrameMain::OnVideoTrackMovementMoveOne) EVT_MENU(Video_Track_Split_Line, FrameMain::OnVideoTrackSplitLine) EVT_CLOSE(FrameMain::OnCloseWindow) @@ -1135,153 +1139,6 @@ void FrameMain::OnVideoToggleScroll(wxCommandEvent &event) { } -/////////////////// -// Track current line -void FrameMain::OnVideoTrackerMenu(wxCommandEvent &event) { - wxMenu menu( _("FexTracker") ); - AppendBitmapMenuItem(&menu, Video_Track_Points, _("track points"), _(""), wxBITMAP(button_track_points)); - menu.AppendSeparator(); - AppendBitmapMenuItem(&menu, Video_Track_Point_Add, _("add points to movement"), _(""), wxBITMAP(button_track_point_add)); - AppendBitmapMenuItem(&menu, Video_Track_Point_Del, _("remove points from movement"), _(""), wxBITMAP(button_track_point_del)); - menu.AppendSeparator(); - AppendBitmapMenuItem(&menu, Video_Track_Movement, _("generate movement from points"), _(""), wxBITMAP(button_track_movement)); - AppendBitmapMenuItem(&menu, Video_Track_Split_Line, _("split line for movement"), _(""), wxBITMAP(button_track_split_line)); - PopupMenu(&menu); -} - - -/////////////////// -// Track current line -void FrameMain::OnVideoTrackPoints(wxCommandEvent &event) { - videoBox->videoDisplay->Stop(); - - // Get line - AssDialogue *curline = SubsBox->GetDialogue(EditBox->linen); - if (!curline) return; - - // Get Video - bool usedDirectshow; - VideoProvider *movie = new VideoProvider(videoBox->videoDisplay->videoName, wxString(_T("")), 1.0,usedDirectshow,true); - - // Create Tracker - if( curline->Tracker ) delete curline->Tracker; - curline->Tracker = new FexTracker( movie->GetWidth(), movie->GetHeight(), 250 ); - curline->Tracker->minFeatures = 250; - - // Start progress - volatile bool canceled = false; - DialogProgress *progress = new DialogProgress(this,_("FexTracker"),&canceled,_("Tracking points"),0,1); - progress->Show(); - - // Allocate temp image - float* FloatImg = new float[ movie->GetWidth()*movie->GetHeight() ]; - - int StartFrame = VFR_Output.CorrectFrameAtTime(curline->Start.GetMS(),true); - int EndFrame = VFR_Output.CorrectFrameAtTime(curline->End.GetMS(),false); - - for( int Frame = StartFrame; Frame <= EndFrame; Frame ++ ) - { - progress->SetProgress( Frame-StartFrame, EndFrame-StartFrame ); - if( canceled ) break; - - movie->GetFloatFrame( FloatImg, Frame ); - curline->Tracker->ProcessImage( FloatImg ); - } - - delete FloatImg; - delete movie; - - // Clean up progress - if (!canceled) - progress->Destroy(); - else - { - delete curline->Tracker; - curline->Tracker = 0; - } - - videoBox->videoDisplay->RefreshVideo(); -} - - -/////////////////// -// Track current line -void FrameMain::OnVideoTrackMovement(wxCommandEvent &event) { - videoBox->videoDisplay->Stop(); - - // Get line - AssDialogue *curline = SubsBox->GetDialogue(EditBox->linen); - if (!curline) return; - if( !curline->Tracker ) return; - - // Create Movement - if( curline->Movement ) DeleteMovement( curline->Movement ); - curline->Movement = curline->Tracker->GetMovement(); - - // Remove Tracker - delete curline->Tracker; - curline->Tracker = 0; - - videoBox->videoDisplay->RefreshVideo(); -} - - -/////////////////// -// split current line -void FrameMain::OnVideoTrackSplitLine(wxCommandEvent &event) { - videoBox->videoDisplay->Stop(); - - // Get line - AssDialogue *curline = SubsBox->GetDialogue(EditBox->linen); - if (!curline) return; - if( !curline->Movement ) return; - - // Create split lines - int StartFrame = VFR_Output.CorrectFrameAtTime(curline->Start.GetMS(),true); - int EndFrame = VFR_Output.CorrectFrameAtTime(curline->End.GetMS(),false); - - for( int Frame = StartFrame; Frame < EndFrame; Frame ++ ) - { - int localframe = Frame - StartFrame; - - while( curline->Movement->Frames.size() <= localframe ) localframe--; - FexMovementFrame f = curline->Movement->Frames[localframe]; -// f.Pos.x /= videoBox->videoDisplay->GetW - - AssDialogue *cur = new AssDialogue( curline->data ); - cur->Start.SetMS(VFR_Output.CorrectTimeAtFrame(Frame,true)); - cur->End.SetMS(VFR_Output.CorrectTimeAtFrame(Frame,false)); - cur->Text = wxString::Format( _T("{\\pos(%.0f,%.0f)\\fscx%.2f\\fscy%.2f}"), f.Pos.x, f.Pos.y, f.Scale.x*100, f.Scale.y*100 ) + cur->Text; - cur->UpdateData(); - - SubsBox->InsertLine(cur,EditBox->linen + Frame - StartFrame,true,false); - } - - // Remove Movement - DeleteMovement( curline->Movement ); - curline->Movement = 0; - - // Remove this line - SubsBox->DeleteLines( EditBox->linen, EditBox->linen, false ); - - videoBox->videoDisplay->RefreshVideo(); -} - - -/////////////////// -// Increase Influence -void FrameMain::OnVideoTrackPointAdd(wxCommandEvent &event) { - videoBox->videoDisplay->TrackerEdit = 1; -} - - -/////////////////// -// Decrease Influence -void FrameMain::OnVideoTrackPointDel(wxCommandEvent &event) { - videoBox->videoDisplay->TrackerEdit = -1; -} - - /////////////////////////////// // Choose a different language void FrameMain::OnChooseLanguage (wxCommandEvent &event) { diff --git a/core/res.rc b/core/res.rc index bbf9fc79c..3f6149a6f 100644 --- a/core/res.rc +++ b/core/res.rc @@ -85,6 +85,8 @@ button_track_point_add BITMAP "bitmaps/button_track_point_add.bmp" button_track_point_del BITMAP "bitmaps/button_track_point_del.bmp" button_track_movement BITMAP "bitmaps/button_track_movement.bmp" button_track_split_line BITMAP "bitmaps/button_track_split_line.bmp" +button_track_trail BITMAP "bitmaps/button_track_trail.bmp" +button_track_move BITMAP "bitmaps/button_track_move.bmp" button_bold BITMAP "bitmaps/button_bold.bmp" button_italics BITMAP "bitmaps/button_italics.bmp" diff --git a/core/video_box.cpp b/core/video_box.cpp index 7f6253aa6..df7cf8f56 100644 --- a/core/video_box.cpp +++ b/core/video_box.cpp @@ -62,6 +62,8 @@ VideoBox::VideoBox(wxPanel *parent) { wxBitmapButton *VideoTrackerMenuButton = new wxBitmapButton(videoPage,Video_Tracker_Menu,wxBITMAP(button_track_points),wxDefaultPosition,wxSize(25,-1)); VideoTrackerMenuButton->SetToolTip(_("FexTracker")); + wxBitmapButton *VideoTrackerMenu2Button = new wxBitmapButton(videoPage,Video_Tracker_Menu2,wxBITMAP(button_track_trail),wxDefaultPosition,wxSize(25,-1)); + VideoTrackerMenu2Button->SetToolTip(_("FexMovement")); // Seek videoSlider = new VideoSlider(videoPage,-1); @@ -97,6 +99,7 @@ VideoBox::VideoBox(wxPanel *parent) { videoBottomSizer->Add(VideoPosition,1,wxLEFT|wxALIGN_CENTER,5); videoBottomSizer->Add(VideoSubsPos,1,wxALIGN_CENTER,0); videoBottomSizer->Add(VideoTrackerMenuButton,0,wxTOP|wxBOTTOM|wxALIGN_CENTER,2); + videoBottomSizer->Add(VideoTrackerMenu2Button,0,wxTOP|wxBOTTOM|wxALIGN_CENTER,2); VideoSizer = new wxBoxSizer(wxVERTICAL); VideoSizer->Add(videoDisplay,0,wxEXPAND,0); VideoSizer->Add(videoSliderSizer,0,wxEXPAND,0); diff --git a/core/video_display.cpp b/core/video_display.cpp index dae9d34f4..34729477d 100644 --- a/core/video_display.cpp +++ b/core/video_display.cpp @@ -233,27 +233,51 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) { return; } - if( event.ButtonDown(wxMOUSE_BTN_LEFT) ) - bTrackerEditing = 1; - if( event.ButtonUp(wxMOUSE_BTN_LEFT) ) - bTrackerEditing = 0; - // Coords int x = event.GetX(); int y = event.GetY(); + if( event.ButtonDown(wxMOUSE_BTN_LEFT) ) + { + MouseDownX = x; + MouseDownY = y; + bTrackerEditing = 1; + } + if( event.ButtonUp(wxMOUSE_BTN_LEFT) ) + bTrackerEditing = 0; + // Do tracker influence if needed if( bTrackerEditing ) { AssDialogue *curline = grid->GetDialogue(grid->editBox->linen); int StartFrame, EndFrame, localframe; if( curline - && curline->Tracker && (StartFrame = VFR_Output.CorrectFrameAtTime(curline->Start.GetMS(),true)) <= frame_n && (EndFrame = VFR_Output.CorrectFrameAtTime(curline->End.GetMS(),false)) >= frame_n - && (localframe = frame_n - StartFrame) < curline->Tracker->GetFrame() ) - curline->Tracker->InfluenceFeatures( localframe, float(x)/provider->GetZoom(), float(y)/provider->GetZoom(), TrackerEdit ); + { + localframe = frame_n - StartFrame; + if( curline->Tracker && localframe < curline->Tracker->GetFrame() ) + curline->Tracker->InfluenceFeatures( localframe, float(x)/provider->GetZoom(), float(y)/provider->GetZoom(), TrackerEdit ); + else if( curline->Movement && localframe < curline->Movement->Frames.size() ) + {// no /provider->GetZoom() to improve precision + if( MovementEdit==1 ) + { + for( int i=0;iMovement->Frames.size();i++ ) + { + curline->Movement->Frames[i].Pos.x += float(x-MouseDownX); + curline->Movement->Frames[i].Pos.y += float(y-MouseDownY); + } + } + else if( MovementEdit==2 ) + { + curline->Movement->Frames[localframe].Pos.x += float(x-MouseDownX); + curline->Movement->Frames[localframe].Pos.y += float(y-MouseDownY); + } + } + MouseDownX = x; + MouseDownY = y; + } } // Text of current coords diff --git a/core/video_display.h b/core/video_display.h index 68e44c910..3cbfab63c 100644 --- a/core/video_display.h +++ b/core/video_display.h @@ -104,8 +104,12 @@ public: bool loaded; bool IsPlaying; double fps; - double TrackerEdit; + bool bTrackerEditing; + int MovementEdit; + double TrackerEdit; + int MouseDownX, MouseDownY; + VideoSlider *ControlSlider; wxComboBox *zoomBox; wxTextCtrl *PositionDisplay;