Changeset View
Changeset View
Standalone View
Standalone View
kstars/ekos/guide/internalguide/gmath.cpp
Show First 20 Lines • Show All 579 Lines • ▼ Show 20 Line(s) | 579 | { | |||
---|---|---|---|---|---|
580 | qCritical() << "Not enough memory for float image array!"; | 580 | qCritical() << "Not enough memory for float image array!"; | ||
581 | return nullptr; | 581 | return nullptr; | ||
582 | } | 582 | } | ||
583 | 583 | | |||
584 | switch (imageData->property("dataType").toInt()) | 584 | switch (imageData->property("dataType").toInt()) | ||
585 | { | 585 | { | ||
586 | case TBYTE: | 586 | case TBYTE: | ||
587 | { | 587 | { | ||
588 | uint8_t *buffer = imageData->getImageBuffer(); | 588 | uint8_t const *buffer = imageData->getImageBuffer(); | ||
589 | for (uint32_t i = 0; i < imgSize; i++) | 589 | for (uint32_t i = 0; i < imgSize; i++) | ||
590 | imgFloat[i] = buffer[i]; | 590 | imgFloat[i] = buffer[i]; | ||
591 | } | 591 | } | ||
592 | break; | 592 | break; | ||
593 | 593 | | |||
594 | case TSHORT: | 594 | case TSHORT: | ||
595 | { | 595 | { | ||
596 | int16_t *buffer = reinterpret_cast<int16_t *>(imageData->getImageBuffer()); | 596 | int16_t const *buffer = reinterpret_cast<int16_t const *>(imageData->getImageBuffer()); | ||
597 | for (uint32_t i = 0; i < imgSize; i++) | 597 | for (uint32_t i = 0; i < imgSize; i++) | ||
598 | imgFloat[i] = buffer[i]; | 598 | imgFloat[i] = buffer[i]; | ||
599 | } | 599 | } | ||
600 | break; | 600 | break; | ||
601 | 601 | | |||
602 | case TUSHORT: | 602 | case TUSHORT: | ||
603 | { | 603 | { | ||
604 | uint16_t *buffer = reinterpret_cast<uint16_t *>(imageData->getImageBuffer()); | 604 | uint16_t const *buffer = reinterpret_cast<uint16_t const*>(imageData->getImageBuffer()); | ||
605 | for (uint32_t i = 0; i < imgSize; i++) | 605 | for (uint32_t i = 0; i < imgSize; i++) | ||
606 | imgFloat[i] = buffer[i]; | 606 | imgFloat[i] = buffer[i]; | ||
607 | } | 607 | } | ||
608 | break; | 608 | break; | ||
609 | 609 | | |||
610 | case TLONG: | 610 | case TLONG: | ||
611 | { | 611 | { | ||
612 | int32_t *buffer = reinterpret_cast<int32_t *>(imageData->getImageBuffer()); | 612 | int32_t const *buffer = reinterpret_cast<int32_t const*>(imageData->getImageBuffer()); | ||
613 | for (uint32_t i = 0; i < imgSize; i++) | 613 | for (uint32_t i = 0; i < imgSize; i++) | ||
614 | imgFloat[i] = buffer[i]; | 614 | imgFloat[i] = buffer[i]; | ||
615 | } | 615 | } | ||
616 | break; | 616 | break; | ||
617 | 617 | | |||
618 | case TULONG: | 618 | case TULONG: | ||
619 | { | 619 | { | ||
620 | uint32_t *buffer = reinterpret_cast<uint32_t *>(imageData->getImageBuffer()); | 620 | uint32_t const *buffer = reinterpret_cast<uint32_t const*>(imageData->getImageBuffer()); | ||
621 | for (uint32_t i = 0; i < imgSize; i++) | 621 | for (uint32_t i = 0; i < imgSize; i++) | ||
622 | imgFloat[i] = buffer[i]; | 622 | imgFloat[i] = buffer[i]; | ||
623 | } | 623 | } | ||
624 | break; | 624 | break; | ||
625 | 625 | | |||
626 | case TFLOAT: | 626 | case TFLOAT: | ||
627 | { | 627 | { | ||
628 | float *buffer = reinterpret_cast<float *>(imageData->getImageBuffer()); | 628 | float const *buffer = reinterpret_cast<float const*>(imageData->getImageBuffer()); | ||
629 | for (uint32_t i = 0; i < imgSize; i++) | 629 | for (uint32_t i = 0; i < imgSize; i++) | ||
630 | imgFloat[i] = buffer[i]; | 630 | imgFloat[i] = buffer[i]; | ||
631 | } | 631 | } | ||
632 | break; | 632 | break; | ||
633 | 633 | | |||
634 | case TLONGLONG: | 634 | case TLONGLONG: | ||
635 | { | 635 | { | ||
636 | int64_t *buffer = reinterpret_cast<int64_t *>(imageData->getImageBuffer()); | 636 | int64_t const *buffer = reinterpret_cast<int64_t const*>(imageData->getImageBuffer()); | ||
637 | for (uint32_t i = 0; i < imgSize; i++) | 637 | for (uint32_t i = 0; i < imgSize; i++) | ||
638 | imgFloat[i] = buffer[i]; | 638 | imgFloat[i] = buffer[i]; | ||
639 | } | 639 | } | ||
640 | break; | 640 | break; | ||
641 | 641 | | |||
642 | case TDOUBLE: | 642 | case TDOUBLE: | ||
643 | { | 643 | { | ||
644 | double *buffer = reinterpret_cast<double *>(imageData->getImageBuffer()); | 644 | double const *buffer = reinterpret_cast<double const*>(imageData->getImageBuffer()); | ||
645 | for (uint32_t i = 0; i < imgSize; i++) | 645 | for (uint32_t i = 0; i < imgSize; i++) | ||
646 | imgFloat[i] = buffer[i]; | 646 | imgFloat[i] = buffer[i]; | ||
647 | } | 647 | } | ||
648 | break; | 648 | break; | ||
649 | 649 | | |||
650 | default: | 650 | default: | ||
651 | delete[] imgFloat; | 651 | delete[] imgFloat; | ||
652 | return nullptr; | 652 | return nullptr; | ||
▲ Show 20 Lines • Show All 162 Lines • ▼ Show 20 Line(s) | |||||
815 | Vector cgmath::findLocalStarPosition(void) const | 815 | Vector cgmath::findLocalStarPosition(void) const | ||
816 | { | 816 | { | ||
817 | static const double P0 = 0.906, P1 = 0.584, P2 = 0.365, P3 = 0.117, P4 = 0.049, P5 = -0.05, P6 = -0.064, P7 = -0.074, | 817 | static const double P0 = 0.906, P1 = 0.584, P2 = 0.365, P3 = 0.117, P4 = 0.049, P5 = -0.05, P6 = -0.064, P7 = -0.074, | ||
818 | P8 = -0.094; | 818 | P8 = -0.094; | ||
819 | 819 | | |||
820 | Vector ret; | 820 | Vector ret; | ||
821 | int i, j; | 821 | int i, j; | ||
822 | double resx, resy, mass, threshold, pval; | 822 | double resx, resy, mass, threshold, pval; | ||
823 | T *psrc = nullptr; | 823 | T const *psrc = nullptr; | ||
824 | T *porigin = nullptr; | 824 | T const *porigin = nullptr; | ||
825 | T *pptr; | 825 | T const *pptr; | ||
826 | 826 | | |||
827 | QRect trackingBox = guideView->getTrackingBox(); | 827 | QRect trackingBox = guideView->getTrackingBox(); | ||
828 | 828 | | |||
829 | if (trackingBox.isValid() == false) | 829 | if (trackingBox.isValid() == false) | ||
830 | return Vector(-1, -1, -1); | 830 | return Vector(-1, -1, -1); | ||
831 | 831 | | |||
832 | FITSData *imageData = guideView->getImageData(); | 832 | FITSData *imageData = guideView->getImageData(); | ||
833 | 833 | | |||
Show All 17 Lines | 844 | { | |||
851 | //ret = Vector(star->x, star->y, 0) - Vector(trackingBox.x(), trackingBox.y(), 0); | 851 | //ret = Vector(star->x, star->y, 0) - Vector(trackingBox.x(), trackingBox.y(), 0); | ||
852 | } | 852 | } | ||
853 | else | 853 | else | ||
854 | ret = Vector(-1, -1, -1); | 854 | ret = Vector(-1, -1, -1); | ||
855 | 855 | | |||
856 | return ret; | 856 | return ret; | ||
857 | } | 857 | } | ||
858 | 858 | | |||
859 | T *pdata = reinterpret_cast<T *>(imageData->getImageBuffer()); | 859 | T const *pdata = reinterpret_cast<T const*>(imageData->getImageBuffer()); | ||
860 | 860 | | |||
861 | qCDebug(KSTARS_EKOS_GUIDE) << "Tracking Square " << trackingBox; | 861 | qCDebug(KSTARS_EKOS_GUIDE) << "Tracking Square " << trackingBox; | ||
862 | 862 | | |||
863 | double square_square = trackingBox.width() * trackingBox.width(); | 863 | double square_square = trackingBox.width() * trackingBox.width(); | ||
864 | 864 | | |||
865 | psrc = porigin = pdata + trackingBox.y() * video_width + trackingBox.x(); | 865 | psrc = porigin = pdata + trackingBox.y() * video_width + trackingBox.x(); | ||
866 | 866 | | |||
867 | resx = resy = 0; | 867 | resx = resy = 0; | ||
868 | threshold = mass = 0; | 868 | threshold = mass = 0; | ||
869 | 869 | | |||
870 | // several threshold adaptive smart algorithms | 870 | // several threshold adaptive smart algorithms | ||
871 | switch (square_alg_idx) | 871 | switch (square_alg_idx) | ||
872 | { | 872 | { | ||
873 | case CENTROID_THRESHOLD: | 873 | case CENTROID_THRESHOLD: | ||
874 | { | 874 | { | ||
875 | int width = trackingBox.width(); | 875 | int width = trackingBox.width(); | ||
876 | int height = trackingBox.width(); | 876 | int height = trackingBox.width(); | ||
877 | float i0, i1, i2, i3, i4, i5, i6, i7, i8; | 877 | float i0, i1, i2, i3, i4, i5, i6, i7, i8; | ||
878 | int ix = 0, iy = 0; | 878 | int ix = 0, iy = 0; | ||
879 | int xM4; | 879 | int xM4; | ||
880 | T *p; | 880 | T const *p; | ||
881 | double average, fit, bestFit = 0; | 881 | double average, fit, bestFit = 0; | ||
882 | int minx = 0; | 882 | int minx = 0; | ||
883 | int maxx = width; | 883 | int maxx = width; | ||
884 | int miny = 0; | 884 | int miny = 0; | ||
885 | int maxy = height; | 885 | int maxy = height; | ||
886 | for (int x = minx; x < maxx; x++) | 886 | for (int x = minx; x < maxx; x++) | ||
887 | for (int y = miny; y < maxy; y++) | 887 | for (int y = miny; y < maxy; y++) | ||
888 | { | 888 | { | ||
▲ Show 20 Lines • Show All 920 Lines • Show Last 20 Lines |