moved events for fextracker & fexmovement into its own file
added second button for fexmovement added functionality to manually move sub for all frames / for one frame Originally committed to SVN as r45.
This commit is contained in:
parent
97b8832376
commit
74a399aaa9
19 changed files with 476 additions and 156 deletions
FexTracker
core
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -17,6 +17,7 @@ class FEXTRACKER_API FexTrackerConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
inline FexTrackerConfig() :
|
inline FexTrackerConfig() :
|
||||||
|
FeatureNumber(0),
|
||||||
EdgeDetectSigma(1.f),
|
EdgeDetectSigma(1.f),
|
||||||
WindowX(3), WindowY(3),
|
WindowX(3), WindowY(3),
|
||||||
SearchRange(15),
|
SearchRange(15),
|
||||||
|
@ -29,6 +30,8 @@ public:
|
||||||
MinDistanceSquare(100.f)
|
MinDistanceSquare(100.f)
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
int FeatureNumber;
|
||||||
|
|
||||||
int WindowX, WindowY; //static const int window_size = 7;
|
int WindowX, WindowY; //static const int window_size = 7;
|
||||||
int SearchRange;
|
int SearchRange;
|
||||||
|
|
||||||
|
|
BIN
core/bitmaps/button_track_move.bmp
Normal file
BIN
core/bitmaps/button_track_move.bmp
Normal file
Binary file not shown.
After (image error) Size: 1.3 KiB |
Binary file not shown.
Before (image error) Size: 1.3 KiB After (image error) Size: 1.3 KiB |
Binary file not shown.
Before (image error) Size: 1.3 KiB After (image error) Size: 1.3 KiB |
Binary file not shown.
Before (image error) Size: 1.3 KiB After (image error) Size: 1.3 KiB |
BIN
core/bitmaps/button_track_trail.bmp
Normal file
BIN
core/bitmaps/button_track_trail.bmp
Normal file
Binary file not shown.
After (image error) Size: 1.3 KiB |
121
core/dialog_fextracker.cpp
Normal file
121
core/dialog_fextracker.cpp
Normal file
|
@ -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);
|
||||||
|
}
|
||||||
|
|
54
core/dialog_fextracker.h
Normal file
54
core/dialog_fextracker.h
Normal file
|
@ -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 <wx/wxprec.h>
|
||||||
|
|
||||||
|
|
||||||
|
//////////////
|
||||||
|
// 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
|
246
core/fextracker_main_events.cpp
Normal file
246
core/fextracker_main_events.cpp
Normal file
|
@ -0,0 +1,246 @@
|
||||||
|
// AEGISUB
|
||||||
|
//
|
||||||
|
// Website: http://aegisub.cellosoft.com
|
||||||
|
// Contact: mailto:zeratul@cellosoft.com
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////
|
||||||
|
// Include headers
|
||||||
|
#include <wx/wxprec.h>
|
||||||
|
#include <wx/mimetype.h>
|
||||||
|
#include <wx/filename.h>
|
||||||
|
#include <wx/tglbtn.h>
|
||||||
|
#include <wx/rawbmp.h>
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -110,7 +110,10 @@ private:
|
||||||
void OnVideoTrackPoints(wxCommandEvent &event);
|
void OnVideoTrackPoints(wxCommandEvent &event);
|
||||||
void OnVideoTrackPointAdd(wxCommandEvent &event);
|
void OnVideoTrackPointAdd(wxCommandEvent &event);
|
||||||
void OnVideoTrackPointDel(wxCommandEvent &event);
|
void OnVideoTrackPointDel(wxCommandEvent &event);
|
||||||
|
void OnVideoTrackerMenu2(wxCommandEvent &event);
|
||||||
void OnVideoTrackMovement(wxCommandEvent &event);
|
void OnVideoTrackMovement(wxCommandEvent &event);
|
||||||
|
void OnVideoTrackMovementMoveAll(wxCommandEvent &event);
|
||||||
|
void OnVideoTrackMovementMoveOne(wxCommandEvent &event);
|
||||||
void OnVideoTrackSplitLine(wxCommandEvent &event);
|
void OnVideoTrackSplitLine(wxCommandEvent &event);
|
||||||
|
|
||||||
void OnKeyDown(wxKeyEvent &event);
|
void OnKeyDown(wxKeyEvent &event);
|
||||||
|
@ -333,7 +336,10 @@ enum {
|
||||||
Video_Track_Points,
|
Video_Track_Points,
|
||||||
Video_Track_Point_Add,
|
Video_Track_Point_Add,
|
||||||
Video_Track_Point_Del,
|
Video_Track_Point_Del,
|
||||||
|
Video_Tracker_Menu2,
|
||||||
Video_Track_Movement,
|
Video_Track_Movement,
|
||||||
|
Video_Track_Movement_MoveAll,
|
||||||
|
Video_Track_Movement_MoveOne,
|
||||||
Video_Track_Split_Line,
|
Video_Track_Split_Line,
|
||||||
|
|
||||||
Menu_File_Recent = 2000,
|
Menu_File_Recent = 2000,
|
||||||
|
|
|
@ -76,6 +76,7 @@
|
||||||
#include "FexTrackingFeature.h"
|
#include "FexTrackingFeature.h"
|
||||||
#include "FexMovement.h"
|
#include "FexMovement.h"
|
||||||
#include "dialog_progress.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_Add, FrameMain::OnVideoTrackPointAdd)
|
||||||
EVT_MENU(Video_Track_Point_Del, FrameMain::OnVideoTrackPointDel)
|
EVT_MENU(Video_Track_Point_Del, FrameMain::OnVideoTrackPointDel)
|
||||||
EVT_MENU(Video_Track_Movement, FrameMain::OnVideoTrackMovement)
|
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_MENU(Video_Track_Split_Line, FrameMain::OnVideoTrackSplitLine)
|
||||||
|
|
||||||
EVT_CLOSE(FrameMain::OnCloseWindow)
|
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
|
// Choose a different language
|
||||||
void FrameMain::OnChooseLanguage (wxCommandEvent &event) {
|
void FrameMain::OnChooseLanguage (wxCommandEvent &event) {
|
||||||
|
|
|
@ -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_point_del BITMAP "bitmaps/button_track_point_del.bmp"
|
||||||
button_track_movement BITMAP "bitmaps/button_track_movement.bmp"
|
button_track_movement BITMAP "bitmaps/button_track_movement.bmp"
|
||||||
button_track_split_line BITMAP "bitmaps/button_track_split_line.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_bold BITMAP "bitmaps/button_bold.bmp"
|
||||||
button_italics BITMAP "bitmaps/button_italics.bmp"
|
button_italics BITMAP "bitmaps/button_italics.bmp"
|
||||||
|
|
|
@ -62,6 +62,8 @@ VideoBox::VideoBox(wxPanel *parent) {
|
||||||
|
|
||||||
wxBitmapButton *VideoTrackerMenuButton = new wxBitmapButton(videoPage,Video_Tracker_Menu,wxBITMAP(button_track_points),wxDefaultPosition,wxSize(25,-1));
|
wxBitmapButton *VideoTrackerMenuButton = new wxBitmapButton(videoPage,Video_Tracker_Menu,wxBITMAP(button_track_points),wxDefaultPosition,wxSize(25,-1));
|
||||||
VideoTrackerMenuButton->SetToolTip(_("FexTracker"));
|
VideoTrackerMenuButton->SetToolTip(_("FexTracker"));
|
||||||
|
wxBitmapButton *VideoTrackerMenu2Button = new wxBitmapButton(videoPage,Video_Tracker_Menu2,wxBITMAP(button_track_trail),wxDefaultPosition,wxSize(25,-1));
|
||||||
|
VideoTrackerMenu2Button->SetToolTip(_("FexMovement"));
|
||||||
|
|
||||||
// Seek
|
// Seek
|
||||||
videoSlider = new VideoSlider(videoPage,-1);
|
videoSlider = new VideoSlider(videoPage,-1);
|
||||||
|
@ -97,6 +99,7 @@ VideoBox::VideoBox(wxPanel *parent) {
|
||||||
videoBottomSizer->Add(VideoPosition,1,wxLEFT|wxALIGN_CENTER,5);
|
videoBottomSizer->Add(VideoPosition,1,wxLEFT|wxALIGN_CENTER,5);
|
||||||
videoBottomSizer->Add(VideoSubsPos,1,wxALIGN_CENTER,0);
|
videoBottomSizer->Add(VideoSubsPos,1,wxALIGN_CENTER,0);
|
||||||
videoBottomSizer->Add(VideoTrackerMenuButton,0,wxTOP|wxBOTTOM|wxALIGN_CENTER,2);
|
videoBottomSizer->Add(VideoTrackerMenuButton,0,wxTOP|wxBOTTOM|wxALIGN_CENTER,2);
|
||||||
|
videoBottomSizer->Add(VideoTrackerMenu2Button,0,wxTOP|wxBOTTOM|wxALIGN_CENTER,2);
|
||||||
VideoSizer = new wxBoxSizer(wxVERTICAL);
|
VideoSizer = new wxBoxSizer(wxVERTICAL);
|
||||||
VideoSizer->Add(videoDisplay,0,wxEXPAND,0);
|
VideoSizer->Add(videoDisplay,0,wxEXPAND,0);
|
||||||
VideoSizer->Add(videoSliderSizer,0,wxEXPAND,0);
|
VideoSizer->Add(videoSliderSizer,0,wxEXPAND,0);
|
||||||
|
|
|
@ -233,27 +233,51 @@ void VideoDisplay::OnMouseEvent(wxMouseEvent& event) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( event.ButtonDown(wxMOUSE_BTN_LEFT) )
|
|
||||||
bTrackerEditing = 1;
|
|
||||||
if( event.ButtonUp(wxMOUSE_BTN_LEFT) )
|
|
||||||
bTrackerEditing = 0;
|
|
||||||
|
|
||||||
// Coords
|
// Coords
|
||||||
int x = event.GetX();
|
int x = event.GetX();
|
||||||
int y = event.GetY();
|
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
|
// Do tracker influence if needed
|
||||||
if( bTrackerEditing )
|
if( bTrackerEditing )
|
||||||
{
|
{
|
||||||
AssDialogue *curline = grid->GetDialogue(grid->editBox->linen);
|
AssDialogue *curline = grid->GetDialogue(grid->editBox->linen);
|
||||||
int StartFrame, EndFrame, localframe;
|
int StartFrame, EndFrame, localframe;
|
||||||
if( curline
|
if( curline
|
||||||
&& curline->Tracker
|
|
||||||
&& (StartFrame = VFR_Output.CorrectFrameAtTime(curline->Start.GetMS(),true)) <= frame_n
|
&& (StartFrame = VFR_Output.CorrectFrameAtTime(curline->Start.GetMS(),true)) <= frame_n
|
||||||
&& (EndFrame = VFR_Output.CorrectFrameAtTime(curline->End.GetMS(),false)) >= frame_n
|
&& (EndFrame = VFR_Output.CorrectFrameAtTime(curline->End.GetMS(),false)) >= frame_n
|
||||||
&& (localframe = frame_n - StartFrame) < curline->Tracker->GetFrame()
|
|
||||||
)
|
)
|
||||||
|
{
|
||||||
|
localframe = frame_n - StartFrame;
|
||||||
|
if( curline->Tracker && localframe < curline->Tracker->GetFrame() )
|
||||||
curline->Tracker->InfluenceFeatures( localframe, float(x)/provider->GetZoom(), float(y)/provider->GetZoom(), TrackerEdit );
|
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;i<curline->Movement->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
|
// Text of current coords
|
||||||
|
|
|
@ -104,8 +104,12 @@ public:
|
||||||
bool loaded;
|
bool loaded;
|
||||||
bool IsPlaying;
|
bool IsPlaying;
|
||||||
double fps;
|
double fps;
|
||||||
double TrackerEdit;
|
|
||||||
bool bTrackerEditing;
|
bool bTrackerEditing;
|
||||||
|
int MovementEdit;
|
||||||
|
double TrackerEdit;
|
||||||
|
int MouseDownX, MouseDownY;
|
||||||
|
|
||||||
VideoSlider *ControlSlider;
|
VideoSlider *ControlSlider;
|
||||||
wxComboBox *zoomBox;
|
wxComboBox *zoomBox;
|
||||||
wxTextCtrl *PositionDisplay;
|
wxTextCtrl *PositionDisplay;
|
||||||
|
|
Loading…
Reference in a new issue