void ZVision::onMouseMove(const Common::Point &pos) { _menu->onMouseMove(pos); Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); bool cursorWasChanged = false; // Graph of the function governing rotation velocity: // // |---------------- working window ------------------| // ^ |---------| // | | // +Max velocity | rotation screen edge offset // | /| // | / | // | / | // | / | // | / | // | / | // | / | // | / | // | / | // Zero velocity |______________________________ ______________________________/_________|__________________________> // | Position -> | / // | | / // | | / // | | / // | | / // | | / // | | / // | | / // | | / // -Max velocity | |/ // | // | // ^ // Clip the horizontal mouse position to the working window Common::Point clippedPos = pos; clippedPos.x = CLIP<int16>(pos.x, _workingWindow.left + 1, _workingWindow.right - 1); if (_workingWindow.contains(clippedPos)) { cursorWasChanged = _scriptManager->onMouseMove(clippedPos, imageCoord); RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { if (clippedPos.x >= _workingWindow.left && clippedPos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { int16 mspeed = _scriptManager->getStateValue(StateKey_RotateSpeed) >> 4; if (mspeed <= 0) { mspeed = 25; } _mouseVelocity = MIN(((Common::Rational(mspeed, ROTATION_SCREEN_EDGE_OFFSET) * (clippedPos.x - _workingWindow.left)) - mspeed).toInt(), -1); _cursorManager->changeCursor(CursorIndex_Left); cursorWasChanged = true; } else if (clippedPos.x <= _workingWindow.right && clippedPos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) {
void ZVision::onMouseMove(const Common::Point &pos) { Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); bool cursorWasChanged = _scriptManager->onMouseMove(pos, imageCoord); // Graph of the function governing rotation velocity: // // |---------------- working window ------------------| // ^ |---------| // | | // +Max velocity | rotation screen edge offset // | /| // | / | // | / | // | / | // | / | // | / | // | / | // | / | // | / | // Zero velocity |______________________________ ______________________________/_________|__________________________> // | Position -> | / // | | / // | | / // | | / // | | / // | | / // | | / // | | / // | | / // -Max velocity | |/ // | // | // ^ if (_workingWindow.contains(pos)) { RenderTable::RenderState renderState = _renderManager->getRenderTable()->getRenderState(); if (renderState == RenderTable::PANORAMA) { if (pos.x >= _workingWindow.left && pos.x < _workingWindow.left + ROTATION_SCREEN_EDGE_OFFSET) { // Linear function of distance to the left edge (y = -mx + b) // We use fixed point math to get better accuracy Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.left)) - MAX_ROTATION_SPEED; _renderManager->setBackgroundVelocity(velocity.toInt()); _cursorManager->setLeftCursor(); cursorWasChanged = true; } else if (pos.x <= _workingWindow.right && pos.x > _workingWindow.right - ROTATION_SCREEN_EDGE_OFFSET) { // Linear function of distance to the right edge (y = mx) // We use fixed point math to get better accuracy Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.x - _workingWindow.right + ROTATION_SCREEN_EDGE_OFFSET); _renderManager->setBackgroundVelocity(velocity.toInt()); _cursorManager->setRightCursor(); cursorWasChanged = true; } else { _renderManager->setBackgroundVelocity(0); } } else if (renderState == RenderTable::TILT) { if (pos.y >= _workingWindow.top && pos.y < _workingWindow.top + ROTATION_SCREEN_EDGE_OFFSET) { // Linear function of distance to top edge // We use fixed point math to get better accuracy Common::Rational velocity = (Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.top)) - MAX_ROTATION_SPEED; _renderManager->setBackgroundVelocity(velocity.toInt()); _cursorManager->setUpCursor(); cursorWasChanged = true; } else if (pos.y <= _workingWindow.bottom && pos.y > _workingWindow.bottom - ROTATION_SCREEN_EDGE_OFFSET) { // Linear function of distance to the bottom edge (y = mx) // We use fixed point math to get better accuracy Common::Rational velocity = Common::Rational(MAX_ROTATION_SPEED, ROTATION_SCREEN_EDGE_OFFSET) * (pos.y - _workingWindow.bottom + ROTATION_SCREEN_EDGE_OFFSET); _renderManager->setBackgroundVelocity(velocity.toInt()); _cursorManager->setDownCursor(); cursorWasChanged = true; } else { _renderManager->setBackgroundVelocity(0); } } } else { _renderManager->setBackgroundVelocity(0); } if (!cursorWasChanged) { _cursorManager->revertToIdle(); } }
void ZVision::onMouseUp(const Common::Point &pos) { _cursorManager->cursorDown(false); Common::Point imageCoord(_renderManager->screenSpaceToImageSpace(pos)); _scriptManager->onMouseUp(pos, imageCoord); }
void main() { define_cameraInfo(cameraInfomation); mat H_rel_abs(5, 5); mat H_abs_phi(5, 5); mat H_phi_sphi(5, 5); mat H_T(5, 5); mat H_M(5, 5); mat H_sphi_phi(5, 5); define_H(H_rel_abs, H_abs_phi, H_phi_sphi, H_T, H_M, H_sphi_phi, cameraInfomation); mat sol(5, 1, fill::zeros); mat input(5, 1); //-------------------------------------------------------------------------- int lens = cameraInfomation.K;//마이크로렌즈갯수 int sensor = cameraInfomation.N;//마이크로레즈 한개당 센서 갯수 mat imageCoord(4, 3); imageCoord <<0 << 0 << 2000 << endr << 0 << 1000 << 2000 << endr << 1000 << 1000 << 2000 << endr << 1000 <<1000 << 2000 << endr; int world_x = 1000, world_y = 1000; //이미지 크기 int input_width, input_height; colorimg** inputimg = ReadImage_color("C:\\Users\\김송란\\Documents\\GitHub\\Study\\lightfield\\cat.jpg", &input_width, &input_height); mat Pl1(1, 3), Pl2(1, 3); //s,t,u,v 저장할 변수 mat unitvector(1, 3); mat Pp1(1, 3), Pp2(1, 3), Pp3(1, 3); //평면의 모서리 3개 좌표 변수 mat nomalvector(1, 3); //법선벡터 mat x(1, 3);//직선과 평면이 만나는 점 colorimg** outimg = (colorimg**)IntAlloc2(lens*sensor, lens*sensor); colorimg** SubApertureImg = (colorimg**)IntAlloc2(lens*sensor, lens*sensor); mat a, b, c, d, sub_xy; int InOutFlag = 0; for (int k = 0; k < lens; k++) { for (int l = 0; l < lens; l++) { for (int i = 0; i < sensor; i++) { for (int j = 0; j < sensor; j++) { input << i << endr << j << endr << k << endr << l << endr << 1 << endr; sol = H_sphi_phi * H_M * H_T * H_phi_sphi * H_abs_phi * H_rel_abs *input; //cout << "행렬 원소 보기: " << endl << sol << endl; LineEquation(sol(0,0), sol(1,0), sol(2,0), sol(3,0), cameraInfomation.D, Pl1, Pl2, unitvector);//직선의 방정식 PlaneEquation(imageCoord, Pp1, Pp2, Pp3, nomalvector); //이미지평면의 방정식 CrossLinePlane(unitvector, nomalvector, Pp1, Pl1, x); //직선과 이미지평면이 만나는 점 InterpolationCoor(x, a, b, c, d, sub_xy, input_width, input_height, world_x, world_y); //선형보간법 좌표 생성 InOutFlag=detectInOut(imageCoord, x); rawimage(InOutFlag,sensor*k+i,sensor*l+j,input_width,input_height, inputimg, outimg, a, b, c, d, sub_xy); //이미지생성 } } } } for (int i = 0; i < sensor; i++) { for (int j = 0; j < sensor; j++) { MakeSubApertureImages(i, j, lens, sensor, outimg, SubApertureImg); } } WriteImage_color("C:\\Users\\김송란\\Documents\\GitHub\\Study\\lightfield\\영상출력테스트5.bmp", outimg, lens*sensor, lens*sensor); WriteImage_color("C:\\Users\\김송란\\Documents\\GitHub\\Study\\lightfield\\영상출력테스트sub5.bmp", SubApertureImg, lens*sensor, lens*sensor); }