mirror of
https://github.com/opencv/opencv.git
synced 2025-08-05 22:19:14 +08:00
Backported some C API cleanup from 5.x to 4.x to reduce conflicts in 4.x->5.x merge.
This commit is contained in:
parent
43551b72d7
commit
d3792dad86
@ -858,8 +858,8 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
|
||||
mp.x = int(event.scrollingDeltaX / 0.100006);
|
||||
mp.y = int(event.scrollingDeltaY / 0.100006);
|
||||
}
|
||||
if( mp.x && !mp.y && CV_EVENT_MOUSEWHEEL == type ) {
|
||||
type = CV_EVENT_MOUSEHWHEEL;
|
||||
if( mp.x && !mp.y && cv::EVENT_MOUSEWHEEL == type ) {
|
||||
type = cv::EVENT_MOUSEHWHEEL;
|
||||
}
|
||||
mouseCallback(type, mp.x, mp.y, flags, mouseParam);
|
||||
} else if( mp.x >= 0 && mp.y >= 0 && mp.x < imageSize.width && mp.y < imageSize.height ) {
|
||||
@ -872,32 +872,32 @@ static NSSize constrainAspectRatio(NSSize base, NSSize constraint) {
|
||||
return;
|
||||
|
||||
int flags = 0;
|
||||
if([event modifierFlags] & NSShiftKeyMask) flags |= CV_EVENT_FLAG_SHIFTKEY;
|
||||
if([event modifierFlags] & NSControlKeyMask) flags |= CV_EVENT_FLAG_CTRLKEY;
|
||||
if([event modifierFlags] & NSAlternateKeyMask) flags |= CV_EVENT_FLAG_ALTKEY;
|
||||
if([event modifierFlags] & NSShiftKeyMask) flags |= cv::EVENT_FLAG_SHIFTKEY;
|
||||
if([event modifierFlags] & NSControlKeyMask) flags |= cv::EVENT_FLAG_CTRLKEY;
|
||||
if([event modifierFlags] & NSAlternateKeyMask) flags |= cv::EVENT_FLAG_ALTKEY;
|
||||
|
||||
//modified code using ternary operator:
|
||||
if ([event type] == NSLeftMouseDown) {
|
||||
[self cvSendMouseEvent:event
|
||||
type:([event modifierFlags] & NSControlKeyMask) ? CV_EVENT_RBUTTONDOWN : CV_EVENT_LBUTTONDOWN
|
||||
flags:flags | (([event modifierFlags] & NSControlKeyMask) ? CV_EVENT_FLAG_RBUTTON : CV_EVENT_FLAG_LBUTTON)];
|
||||
}
|
||||
type:([event modifierFlags] & NSControlKeyMask) ? cv::EVENT_RBUTTONDOWN : cv::EVENT_LBUTTONDOWN
|
||||
flags:flags | (([event modifierFlags] & NSControlKeyMask) ? cv::EVENT_FLAG_RBUTTON : cv::EVENT_FLAG_LBUTTON)];
|
||||
}
|
||||
|
||||
if ([event type] == NSLeftMouseUp) {
|
||||
[self cvSendMouseEvent:event
|
||||
type:([event modifierFlags] & NSControlKeyMask) ? CV_EVENT_RBUTTONUP : CV_EVENT_LBUTTONUP
|
||||
flags:flags | (([event modifierFlags] & NSControlKeyMask) ? CV_EVENT_FLAG_RBUTTON : CV_EVENT_FLAG_LBUTTON)];
|
||||
}
|
||||
if ([event type] == NSLeftMouseUp) {
|
||||
[self cvSendMouseEvent:event
|
||||
type:([event modifierFlags] & NSControlKeyMask) ? cv::EVENT_RBUTTONUP : cv::EVENT_LBUTTONUP
|
||||
flags:flags | (([event modifierFlags] & NSControlKeyMask) ? cv::EVENT_FLAG_RBUTTON : cv::EVENT_FLAG_LBUTTON)];
|
||||
}
|
||||
|
||||
if([event type] == NSRightMouseDown){[self cvSendMouseEvent:event type:CV_EVENT_RBUTTONDOWN flags:flags | CV_EVENT_FLAG_RBUTTON];}
|
||||
if([event type] == NSRightMouseUp) {[self cvSendMouseEvent:event type:CV_EVENT_RBUTTONUP flags:flags | CV_EVENT_FLAG_RBUTTON];}
|
||||
if([event type] == NSOtherMouseDown){[self cvSendMouseEvent:event type:CV_EVENT_MBUTTONDOWN flags:flags];}
|
||||
if([event type] == NSOtherMouseUp) {[self cvSendMouseEvent:event type:CV_EVENT_MBUTTONUP flags:flags];}
|
||||
if([event type] == NSMouseMoved) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags];}
|
||||
if([event type] == NSLeftMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_LBUTTON];}
|
||||
if([event type] == NSRightMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_RBUTTON];}
|
||||
if([event type] == NSOtherMouseDragged) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEMOVE flags:flags | CV_EVENT_FLAG_MBUTTON];}
|
||||
if([event type] == NSEventTypeScrollWheel) {[self cvSendMouseEvent:event type:CV_EVENT_MOUSEWHEEL flags:flags ];}
|
||||
if([event type] == NSRightMouseDown){[self cvSendMouseEvent:event type:cv::EVENT_RBUTTONDOWN flags:flags | cv::EVENT_FLAG_RBUTTON];}
|
||||
if([event type] == NSRightMouseUp) {[self cvSendMouseEvent:event type:cv::EVENT_RBUTTONUP flags:flags | cv::EVENT_FLAG_RBUTTON];}
|
||||
if([event type] == NSOtherMouseDown){[self cvSendMouseEvent:event type:cv::EVENT_MBUTTONDOWN flags:flags];}
|
||||
if([event type] == NSOtherMouseUp) {[self cvSendMouseEvent:event type:cv::EVENT_MBUTTONUP flags:flags];}
|
||||
if([event type] == NSMouseMoved) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags];}
|
||||
if([event type] == NSLeftMouseDragged) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags | cv::EVENT_FLAG_LBUTTON];}
|
||||
if([event type] == NSRightMouseDragged) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags | cv::EVENT_FLAG_RBUTTON];}
|
||||
if([event type] == NSOtherMouseDragged) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEMOVE flags:flags | cv::EVENT_FLAG_MBUTTON];}
|
||||
if([event type] == NSEventTypeScrollWheel) {[self cvSendMouseEvent:event type:cv::EVENT_MOUSEWHEEL flags:flags ];}
|
||||
}
|
||||
|
||||
-(void)scrollWheel:(NSEvent *)theEvent {
|
||||
|
@ -1917,7 +1917,7 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
|
||||
{
|
||||
GdkEventMotion* event_motion = (GdkEventMotion*)event;
|
||||
|
||||
cv_event = CV_EVENT_MOUSEMOVE;
|
||||
cv_event = cv::EVENT_MOUSEMOVE;
|
||||
pt32f.x = cvFloor(event_motion->x);
|
||||
pt32f.y = cvFloor(event_motion->y);
|
||||
state = event_motion->state;
|
||||
@ -1933,21 +1933,21 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
|
||||
|
||||
if( event_button->type == GDK_BUTTON_PRESS )
|
||||
{
|
||||
cv_event = event_button->button == 1 ? CV_EVENT_LBUTTONDOWN :
|
||||
event_button->button == 2 ? CV_EVENT_MBUTTONDOWN :
|
||||
event_button->button == 3 ? CV_EVENT_RBUTTONDOWN : 0;
|
||||
cv_event = event_button->button == 1 ? cv::EVENT_LBUTTONDOWN :
|
||||
event_button->button == 2 ? cv::EVENT_MBUTTONDOWN :
|
||||
event_button->button == 3 ? cv::EVENT_RBUTTONDOWN : 0;
|
||||
}
|
||||
else if( event_button->type == GDK_BUTTON_RELEASE )
|
||||
{
|
||||
cv_event = event_button->button == 1 ? CV_EVENT_LBUTTONUP :
|
||||
event_button->button == 2 ? CV_EVENT_MBUTTONUP :
|
||||
event_button->button == 3 ? CV_EVENT_RBUTTONUP : 0;
|
||||
cv_event = event_button->button == 1 ? cv::EVENT_LBUTTONUP :
|
||||
event_button->button == 2 ? cv::EVENT_MBUTTONUP :
|
||||
event_button->button == 3 ? cv::EVENT_RBUTTONUP : 0;
|
||||
}
|
||||
else if( event_button->type == GDK_2BUTTON_PRESS )
|
||||
{
|
||||
cv_event = event_button->button == 1 ? CV_EVENT_LBUTTONDBLCLK :
|
||||
event_button->button == 2 ? CV_EVENT_MBUTTONDBLCLK :
|
||||
event_button->button == 3 ? CV_EVENT_RBUTTONDBLCLK : 0;
|
||||
cv_event = event_button->button == 1 ? cv::EVENT_LBUTTONDBLCLK :
|
||||
event_button->button == 2 ? cv::EVENT_MBUTTONDBLCLK :
|
||||
event_button->button == 3 ? cv::EVENT_RBUTTONDBLCLK : 0;
|
||||
}
|
||||
state = event_button->state;
|
||||
}
|
||||
@ -1960,9 +1960,9 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
|
||||
#if defined(GTK_VERSION3_4)
|
||||
// NOTE: in current implementation doesn't possible to put into callback function delta_x and delta_y separately
|
||||
double delta = (event->scroll.delta_x + event->scroll.delta_y);
|
||||
cv_event = (event->scroll.delta_x==0) ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL;
|
||||
cv_event = (event->scroll.delta_x==0) ? cv::EVENT_MOUSEWHEEL : cv::EVENT_MOUSEHWHEEL;
|
||||
#else
|
||||
cv_event = CV_EVENT_MOUSEWHEEL;
|
||||
cv_event = cv::EVENT_MOUSEWHEEL;
|
||||
#endif //GTK_VERSION3_4
|
||||
|
||||
state = event->scroll.state;
|
||||
@ -1972,11 +1972,11 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
|
||||
case GDK_SCROLL_SMOOTH: flags |= (((int)delta << 16));
|
||||
break;
|
||||
#endif //GTK_VERSION3_4
|
||||
case GDK_SCROLL_LEFT: cv_event = CV_EVENT_MOUSEHWHEEL;
|
||||
case GDK_SCROLL_LEFT: cv_event = cv::EVENT_MOUSEHWHEEL;
|
||||
/* FALLTHRU */
|
||||
case GDK_SCROLL_UP: flags |= ~0xffff;
|
||||
break;
|
||||
case GDK_SCROLL_RIGHT: cv_event = CV_EVENT_MOUSEHWHEEL;
|
||||
case GDK_SCROLL_RIGHT: cv_event = cv::EVENT_MOUSEHWHEEL;
|
||||
/* FALLTHRU */
|
||||
case GDK_SCROLL_DOWN: flags |= (((int)1 << 16));
|
||||
break;
|
||||
@ -2011,16 +2011,16 @@ static gboolean icvOnMouse( GtkWidget *widget, GdkEvent *event, gpointer user_da
|
||||
{
|
||||
// handle non-keyboard (mouse) modifiers first
|
||||
flags |=
|
||||
BIT_MAP(state, GDK_BUTTON1_MASK, CV_EVENT_FLAG_LBUTTON) |
|
||||
BIT_MAP(state, GDK_BUTTON2_MASK, CV_EVENT_FLAG_MBUTTON) |
|
||||
BIT_MAP(state, GDK_BUTTON3_MASK, CV_EVENT_FLAG_RBUTTON);
|
||||
BIT_MAP(state, GDK_BUTTON1_MASK, cv::EVENT_FLAG_LBUTTON) |
|
||||
BIT_MAP(state, GDK_BUTTON2_MASK, cv::EVENT_FLAG_MBUTTON) |
|
||||
BIT_MAP(state, GDK_BUTTON3_MASK, cv::EVENT_FLAG_RBUTTON);
|
||||
// keyboard modifiers
|
||||
state &= gtk_accelerator_get_default_mod_mask();
|
||||
flags |=
|
||||
BIT_MAP(state, GDK_SHIFT_MASK, CV_EVENT_FLAG_SHIFTKEY) |
|
||||
BIT_MAP(state, GDK_CONTROL_MASK, CV_EVENT_FLAG_CTRLKEY) |
|
||||
BIT_MAP(state, GDK_MOD1_MASK, CV_EVENT_FLAG_ALTKEY) |
|
||||
BIT_MAP(state, GDK_MOD2_MASK, CV_EVENT_FLAG_ALTKEY);
|
||||
BIT_MAP(state, GDK_SHIFT_MASK, cv::EVENT_FLAG_SHIFTKEY) |
|
||||
BIT_MAP(state, GDK_CONTROL_MASK, cv::EVENT_FLAG_CTRLKEY) |
|
||||
BIT_MAP(state, GDK_MOD1_MASK, cv::EVENT_FLAG_ALTKEY) |
|
||||
BIT_MAP(state, GDK_MOD2_MASK, cv::EVENT_FLAG_ALTKEY);
|
||||
window->on_mouse( cv_event, pt.x, pt.y, flags, window->on_mouse_param );
|
||||
}
|
||||
}
|
||||
|
@ -1624,13 +1624,13 @@ MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
case WM_MOUSEHWHEEL:
|
||||
if (window.on_mouse)
|
||||
{
|
||||
int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
|
||||
(wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
|
||||
(wParam & MK_MBUTTON ? CV_EVENT_FLAG_MBUTTON : 0)|
|
||||
(wParam & MK_CONTROL ? CV_EVENT_FLAG_CTRLKEY : 0)|
|
||||
(wParam & MK_SHIFT ? CV_EVENT_FLAG_SHIFTKEY : 0)|
|
||||
(GetKeyState(VK_MENU) < 0 ? CV_EVENT_FLAG_ALTKEY : 0);
|
||||
int event = (uMsg == WM_MOUSEWHEEL ? CV_EVENT_MOUSEWHEEL : CV_EVENT_MOUSEHWHEEL);
|
||||
int flags = (wParam & MK_LBUTTON ? cv::EVENT_FLAG_LBUTTON : 0)|
|
||||
(wParam & MK_RBUTTON ? cv::EVENT_FLAG_RBUTTON : 0)|
|
||||
(wParam & MK_MBUTTON ? cv::EVENT_FLAG_MBUTTON : 0)|
|
||||
(wParam & MK_CONTROL ? cv::EVENT_FLAG_CTRLKEY : 0)|
|
||||
(wParam & MK_SHIFT ? cv::EVENT_FLAG_SHIFTKEY : 0)|
|
||||
(GetKeyState(VK_MENU) < 0 ? cv::EVENT_FLAG_ALTKEY : 0);
|
||||
int event = (uMsg == WM_MOUSEWHEEL ? cv::EVENT_MOUSEWHEEL : cv::EVENT_MOUSEHWHEEL);
|
||||
|
||||
// Set the wheel delta of mouse wheel to be in the upper word of 'event'
|
||||
int delta = GET_WHEEL_DELTA_WPARAM(wParam);
|
||||
@ -1822,22 +1822,22 @@ static LRESULT CALLBACK HighGUIProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM
|
||||
{
|
||||
POINT pt;
|
||||
|
||||
int flags = (wParam & MK_LBUTTON ? CV_EVENT_FLAG_LBUTTON : 0)|
|
||||
(wParam & MK_RBUTTON ? CV_EVENT_FLAG_RBUTTON : 0)|
|
||||
(wParam & MK_MBUTTON ? CV_EVENT_FLAG_MBUTTON : 0)|
|
||||
(wParam & MK_CONTROL ? CV_EVENT_FLAG_CTRLKEY : 0)|
|
||||
(wParam & MK_SHIFT ? CV_EVENT_FLAG_SHIFTKEY : 0)|
|
||||
(GetKeyState(VK_MENU) < 0 ? CV_EVENT_FLAG_ALTKEY : 0);
|
||||
int event = uMsg == WM_LBUTTONDOWN ? CV_EVENT_LBUTTONDOWN :
|
||||
uMsg == WM_RBUTTONDOWN ? CV_EVENT_RBUTTONDOWN :
|
||||
uMsg == WM_MBUTTONDOWN ? CV_EVENT_MBUTTONDOWN :
|
||||
uMsg == WM_LBUTTONUP ? CV_EVENT_LBUTTONUP :
|
||||
uMsg == WM_RBUTTONUP ? CV_EVENT_RBUTTONUP :
|
||||
uMsg == WM_MBUTTONUP ? CV_EVENT_MBUTTONUP :
|
||||
uMsg == WM_LBUTTONDBLCLK ? CV_EVENT_LBUTTONDBLCLK :
|
||||
uMsg == WM_RBUTTONDBLCLK ? CV_EVENT_RBUTTONDBLCLK :
|
||||
uMsg == WM_MBUTTONDBLCLK ? CV_EVENT_MBUTTONDBLCLK :
|
||||
CV_EVENT_MOUSEMOVE;
|
||||
int flags = (wParam & MK_LBUTTON ? cv::EVENT_FLAG_LBUTTON : 0)|
|
||||
(wParam & MK_RBUTTON ? cv::EVENT_FLAG_RBUTTON : 0)|
|
||||
(wParam & MK_MBUTTON ? cv::EVENT_FLAG_MBUTTON : 0)|
|
||||
(wParam & MK_CONTROL ? cv::EVENT_FLAG_CTRLKEY : 0)|
|
||||
(wParam & MK_SHIFT ? cv::EVENT_FLAG_SHIFTKEY : 0)|
|
||||
(GetKeyState(VK_MENU) < 0 ? cv::EVENT_FLAG_ALTKEY : 0);
|
||||
int event = uMsg == WM_LBUTTONDOWN ? cv::EVENT_LBUTTONDOWN :
|
||||
uMsg == WM_RBUTTONDOWN ? cv::EVENT_RBUTTONDOWN :
|
||||
uMsg == WM_MBUTTONDOWN ? cv::EVENT_MBUTTONDOWN :
|
||||
uMsg == WM_LBUTTONUP ? cv::EVENT_LBUTTONUP :
|
||||
uMsg == WM_RBUTTONUP ? cv::EVENT_RBUTTONUP :
|
||||
uMsg == WM_MBUTTONUP ? cv::EVENT_MBUTTONUP :
|
||||
uMsg == WM_LBUTTONDBLCLK ? cv::EVENT_LBUTTONDBLCLK :
|
||||
uMsg == WM_RBUTTONDBLCLK ? cv::EVENT_RBUTTONDBLCLK :
|
||||
uMsg == WM_MBUTTONDBLCLK ? cv::EVENT_MBUTTONDBLCLK :
|
||||
cv::EVENT_MOUSEMOVE;
|
||||
if (uMsg == WM_LBUTTONDOWN || uMsg == WM_RBUTTONDOWN || uMsg == WM_MBUTTONDOWN)
|
||||
SetCapture(hwnd);
|
||||
if (uMsg == WM_LBUTTONUP || uMsg == WM_RBUTTONUP || uMsg == WM_MBUTTONUP)
|
||||
|
@ -3372,9 +3372,9 @@ VideoCapture_DShow::VideoCapture_DShow(int index, const VideoCaptureParameters&
|
||||
CoInitialize(0);
|
||||
|
||||
if (!params.empty()) {
|
||||
int tmpW = params.get<int>(CV_CAP_PROP_FRAME_WIDTH, -1);
|
||||
int tmpH = params.get<int>(CV_CAP_PROP_FRAME_HEIGHT, -1);
|
||||
int tmpFOURCC = params.get<int>(CV_CAP_PROP_FOURCC, -1);
|
||||
int tmpW = params.get<int>(CAP_PROP_FRAME_WIDTH, -1);
|
||||
int tmpH = params.get<int>(CAP_PROP_FRAME_HEIGHT, -1);
|
||||
int tmpFOURCC = params.get<int>(CAP_PROP_FOURCC, -1);
|
||||
if (tmpW != -1 && tmpH != -1) {
|
||||
g_VI.setupDeviceFourcc(index, tmpW, tmpH, tmpFOURCC);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user