static BOOL xf_event_execute_action_script(xfContext* xfc, XEvent* event) { int index; int count; char* name; FILE* actionScript; BOOL match = FALSE; const char* xeventName; char buffer[1024] = { 0 }; char command[1024] = { 0 }; if (!xfc->actionScript || !xfc->xevents) return FALSE; if (event->type > (sizeof(X11_EVENT_STRINGS) / sizeof(const char*))) return FALSE; xeventName = X11_EVENT_STRINGS[event->type]; count = ArrayList_Count(xfc->xevents); for (index = 0; index < count; index++) { name = (char*) ArrayList_GetItem(xfc->xevents, index); if (_stricmp(name, xeventName) == 0) { match = TRUE; break; } } if (!match) return FALSE; sprintf_s(command, sizeof(command), "%s xevent %s %lu", xfc->actionScript, xeventName, (unsigned long) xfc->window->handle); actionScript = popen(command, "r"); if (!actionScript) return FALSE; while (fgets(buffer, sizeof(buffer), actionScript)) { strtok(buffer, "\n"); } pclose(actionScript); return TRUE; }
void tsmf_presentation_sync(TSMF_PRESENTATION* presentation) { UINT32 index; UINT32 count; ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { TSMF_STREAM* stream = (TSMF_STREAM *) ArrayList_GetItem(presentation->stream_list, index); WaitForSingleObject(stream->ready, 500); } ArrayList_Unlock(presentation->stream_list); }
void RDPListener::on_property_call(Glib::VariantBase &property, const Glib::RefPtr<Gio::DBus::Connection> &, const Glib::ustring &, const Glib::ustring &, const Glib::ustring &, const Glib::ustring &property_name) { if (property_name == "Port") { property = Glib::Variant<uint16_t>::create(port); } else if (property_name == "NumConnectedPeers") { property = Glib::Variant<uint32_t>::create(ArrayList_Count(this->server->clients)); } else if (property_name == "RequiresAuthentication") { property = Glib::Variant<bool>::create(authenticating); } }
int AreaFilter_CreateHull (AreaFilter* self, ArrayList* points) { int u = AreaFilter_MakeChain (self, points, AreaFilter_CompareLow); if (ArrayList_Count(points) == 0) return (0); /* int k; for (k = 0 ; k < u ; ++k) WriteLine ("point %d: %f %f", k, ((FilterPoint*)ArrayList_GetItem(points, k)[k])->x, ((FilterPoint*)ArrayList_GetItem(points, k)[k])->y); */ ArrayList* pointsHigh = ArrayList_new(ArrayList_Count(points)+1-u, NULL); //WriteLine ("points.Length = %d, u = %d", ArrayList_Count(points), u); ArrayList_Copy (points, u, pointsHigh, 0, ArrayList_Count(points) - u); ArrayList_SetItem(pointsHigh, ArrayList_Count(pointsHigh) - 1, ArrayList_GetItem(points, 0)); int h = AreaFilter_MakeChain (self, pointsHigh, AreaFilter_CompareHigh); int p; for ( p = u ; p < ArrayList_Count(points) ; ++p) { ArrayList_SetItem(points, p, ArrayList_GetItem(pointsHigh, p-u)); } /* WriteLine ("h = %d, u = %d", h, u); int k; for (k = 0 ; k < (h + u) ; ++k) WriteLine ("point %d: %f %f", k, ((FilterPoint*)ArrayList_GetItem(points, k)[k])->x, ((FilterPoint*)ArrayList_GetItem(points, k)[k])->y); */ return (h + u); }
void tsmf_presentation_set_geometry_info(TSMF_PRESENTATION *presentation, UINT32 x, UINT32 y, UINT32 width, UINT32 height, int num_rects, RDP_RECT *rects) { UINT32 index; UINT32 count; TSMF_STREAM *stream; /* The server may send messages with invalid width / height. * Ignore those messages. */ if (!width || !height) return; if ((width == presentation->width) && (height == presentation->height) && (x == presentation->x) && (y == presentation->y) && (num_rects == presentation->nr_rects) && (0 == memcmp(rects, presentation->rects, num_rects * sizeof(RDP_RECT)))) { return; } presentation->x = x; presentation->y = y; presentation->width = width; presentation->height = height; presentation->nr_rects = num_rects; presentation->rects = realloc(presentation->rects, sizeof(RDP_RECT) * num_rects); if (presentation->rects) memcpy(presentation->rects, rects, sizeof(RDP_RECT) * num_rects); ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { stream = (TSMF_STREAM *) ArrayList_GetItem(presentation->stream_list, index); if (!stream->decoder) continue; if (stream->decoder->UpdateRenderingArea) { stream->decoder->UpdateRenderingArea(stream->decoder, x, y, width, height, num_rects, rects); } } ArrayList_Unlock(presentation->stream_list); }
void tsmf_presentation_start(TSMF_PRESENTATION* presentation) { UINT32 index; UINT32 count; TSMF_STREAM* stream; ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { stream = (TSMF_STREAM *) ArrayList_GetItem(presentation->stream_list, index); tsmf_stream_start(stream); } ArrayList_Unlock(presentation->stream_list); }
BOOL tsmf_presentation_restarted(TSMF_PRESENTATION* presentation) { UINT32 index; UINT32 count; TSMF_STREAM* stream; BOOL ret = TRUE; ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index); ret &= tsmf_stream_restart(stream); } ArrayList_Unlock(presentation->stream_list); return ret; }
void tsmf_presentation_volume_changed(TSMF_PRESENTATION* presentation, UINT32 newVolume, UINT32 muted) { UINT32 index; UINT32 count; TSMF_STREAM* stream; presentation->volume = newVolume; presentation->muted = muted; ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { stream = (TSMF_STREAM *) ArrayList_GetItem(presentation->stream_list, index); tsmf_stream_change_volume(stream, newVolume, muted); } ArrayList_Unlock(presentation->stream_list); }
int shadow_client_boardcast_quit(rdpShadowServer* server, int nExitCode) { wMessageQueue* queue = NULL; int count = 0; int index = 0; ArrayList_Lock(server->clients); for (index = 0; index < ArrayList_Count(server->clients); index++) { queue = ((rdpShadowClient*)ArrayList_GetItem(server->clients, index))->MsgQueue; if (MessageQueue_PostQuit(queue, nExitCode)) { count++; } } ArrayList_Unlock(server->clients); return count; }
ArrayList* MultiMatch_CreatePointList (MultiMatch* self, ArrayList* matches) { ArrayList* points = ArrayList_new0 (FilterPoint_delete); // Create a point list. int i; for(i=0; i<ArrayList_Count(matches); i++) { Match* m = (Match*) ArrayList_GetItem(matches, i); FilterPoint* p = FilterPoint_new0 (); p->x = m->kp1->x; p->y = m->kp1->y; p->user = m; WriteLine ("%f %f # CPOINTS", p->x, p->y); ArrayList_AddItem(points, p); } return (points); }
RpcClientCall* rpc_client_call_find_by_id(rdpRpc* rpc, UINT32 CallId) { int index; int count; RpcClientCall* clientCall; ArrayList_Lock(rpc->client->ClientCallList); clientCall = NULL; count = ArrayList_Count(rpc->client->ClientCallList); for (index = 0; index < count; index++) { clientCall = (RpcClientCall*) ArrayList_GetItem(rpc->client->ClientCallList, index); if (clientCall->CallId == CallId) break; } ArrayList_Unlock(rpc->client->ClientCallList); return clientCall; }
void dvcman_free(IWTSVirtualChannelManager* pChannelMgr) { int i; int count; IWTSPlugin* pPlugin; DVCMAN_LISTENER* listener; DVCMAN_CHANNEL* channel; DVCMAN* dvcman = (DVCMAN*) pChannelMgr; ArrayList_Lock(dvcman->channels); count = ArrayList_Count(dvcman->channels); for (i = 0; i < count; i++) { channel = (DVCMAN_CHANNEL*) ArrayList_GetItem(dvcman->channels, i); dvcman_channel_free(channel); } ArrayList_Unlock(dvcman->channels); ArrayList_Free(dvcman->channels); for (i = 0; i < dvcman->num_listeners; i++) { listener = (DVCMAN_LISTENER*) dvcman->listeners[i]; free(listener->channel_name); free(listener); } for (i = 0; i < dvcman->num_plugins; i++) { pPlugin = dvcman->plugins[i]; if (pPlugin->Terminated) pPlugin->Terminated(pPlugin); } StreamPool_Free(dvcman->pool); free(dvcman); }
static void winpr_unref_named_pipe(WINPR_NAMED_PIPE* pNamedPipe) { int index; NamedPipeServerSocketEntry* baseSocket; if (!pNamedPipe) return; assert(pNamedPipe->name); assert(g_NamedPipeServerSockets); //WLog_VRB(TAG, "%p (%s)", pNamedPipe, pNamedPipe->name); ArrayList_Lock(g_NamedPipeServerSockets); for (index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++) { baseSocket = (NamedPipeServerSocketEntry*) ArrayList_GetItem( g_NamedPipeServerSockets, index); assert(baseSocket->name); if (!strcmp(baseSocket->name, pNamedPipe->name)) { assert(baseSocket->references > 0); assert(baseSocket->serverfd != -1); if (--baseSocket->references == 0) { //WLog_DBG(TAG, "removing shared server socked resource"); //WLog_DBG(TAG, "closing shared serverfd %d", baseSocket->serverfd); ArrayList_Remove(g_NamedPipeServerSockets, baseSocket); close(baseSocket->serverfd); free(baseSocket->name); free(baseSocket); } break; } } ArrayList_Unlock(g_NamedPipeServerSockets); }
HANDLE CreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) { int i; if (!lpFileName) return INVALID_HANDLE_VALUE; if (pthread_once(&_HandleCreatorsInitialized, _HandleCreatorsInit) != 0) { SetLastError(ERROR_DLL_INIT_FAILED); return INVALID_HANDLE_VALUE; } if (_HandleCreators == NULL) { SetLastError(ERROR_DLL_INIT_FAILED); return INVALID_HANDLE_VALUE; } ArrayList_Lock(_HandleCreators); for (i=0; i <= ArrayList_Count(_HandleCreators); i++) { HANDLE_CREATOR* creator = ArrayList_GetItem(_HandleCreators, i); if (creator && creator->IsHandled(lpFileName)) { HANDLE newHandle = creator->CreateFileA(lpFileName, dwDesiredAccess, dwShareMode, lpSecurityAttributes, dwCreationDisposition, dwFlagsAndAttributes, hTemplateFile); ArrayList_Unlock(_HandleCreators); return newHandle; } } ArrayList_Unlock(_HandleCreators); return INVALID_HANDLE_VALUE; }
VOID WINAPI FreeRDP_WTSCloseServer(HANDLE hServer) { int index; int count; rdpPeerChannel* channel; WTSVirtualChannelManager* vcm; vcm = (WTSVirtualChannelManager*) hServer; if (vcm) { HashTable_Remove(g_ServerHandles, (void*) (UINT_PTR) vcm->SessionId); ArrayList_Lock(vcm->dynamicVirtualChannels); count = ArrayList_Count(vcm->dynamicVirtualChannels); for (index = 0; index < count; index++) { channel = (rdpPeerChannel*) ArrayList_GetItem(vcm->dynamicVirtualChannels, index); WTSVirtualChannelClose(channel); } ArrayList_Unlock(vcm->dynamicVirtualChannels); ArrayList_Free(vcm->dynamicVirtualChannels); if (vcm->drdynvc_channel) { WTSVirtualChannelClose(vcm->drdynvc_channel); vcm->drdynvc_channel = NULL; } MessageQueue_Free(vcm->queue); free(vcm); } }
/** * Function description * * @return 0 on success, otherwise a Win32 error code */ UINT tsmf_presentation_sync(TSMF_PRESENTATION* presentation) { UINT32 index; UINT32 count; UINT error; ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { TSMF_STREAM* stream = (TSMF_STREAM *) ArrayList_GetItem(presentation->stream_list, index); if (WaitForSingleObject(stream->ready, 500) == WAIT_FAILED) { error = GetLastError(); WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error); return error; } } ArrayList_Unlock(presentation->stream_list); return CHANNEL_RC_OK; }
TSMF_STREAM *tsmf_stream_find_by_id(TSMF_PRESENTATION *presentation, UINT32 stream_id) { UINT32 index; UINT32 count; BOOL found = FALSE; TSMF_STREAM *stream; ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { stream = (TSMF_STREAM *) ArrayList_GetItem(presentation->stream_list, index); if (stream->stream_id == stream_id) { found = TRUE; break; } } ArrayList_Unlock(presentation->stream_list); return (found) ? stream : NULL; }
static void winpr_unref_named_pipe(WINPR_NAMED_PIPE* pNamedPipe) { int index; NamedPipeServerSocketEntry *baseSocket; if (!pNamedPipe) return; assert(pNamedPipe->name); assert(g_NamedPipeServerSockets); //fprintf(stderr, "%s: %p (%s)\n", __FUNCTION__, pNamedPipe, pNamedPipe->name); ArrayList_Lock(g_NamedPipeServerSockets); for (index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++) { baseSocket = (NamedPipeServerSocketEntry*) ArrayList_GetItem( g_NamedPipeServerSockets, index); assert(baseSocket->name); if (!strcmp(baseSocket->name, pNamedPipe->name)) { assert(baseSocket->references > 0); assert(baseSocket->serverfd != -1); if (--baseSocket->references == 0) { //fprintf(stderr, "%s: removing shared server socked resource\n", __FUNCTION__); //fprintf(stderr, "%s: closing shared serverfd %d\n", __FUNCTION__, baseSocket->serverfd); ArrayList_Remove(g_NamedPipeServerSockets, baseSocket); close(baseSocket->serverfd); free(baseSocket->name); free(baseSocket); } break; } } ArrayList_Unlock(g_NamedPipeServerSockets); }
int AreaFilter_MakeChain (AreaFilter* self, ArrayList* points, int (*comp)(const FilterPoint*, const FilterPoint*)) { IComparator comparator; comparator.compareTo = (int ( *)(IComparator *,const void *,const void *)) comp; ArrayList_Sort(points, &comparator); int s = 1; int pCount = ArrayList_Count(points); int i; for (i = 2 ; i < pCount ; ++i) { int j; for (j = s ; j >= 1 && AreaFilter_ccw (points, i, j, j - 1) ; --j) ; s = j + 1; // Swap FilterPoint* t = (FilterPoint*) ArrayList_GetItem(points, s); ArrayList_SetItem(points, s, ArrayList_GetItem(points, i)); ArrayList_SetItem(points, i, t); } return (s); }
int x11_shadow_pointer_position_update(x11ShadowSubsystem* subsystem) { SHADOW_MSG_OUT_POINTER_POSITION_UPDATE* msg; UINT32 msgId = SHADOW_MSG_OUT_POINTER_POSITION_UPDATE_ID; rdpShadowClient* client; rdpShadowServer* server; int count = 0; int index = 0; msg = (SHADOW_MSG_OUT_POINTER_POSITION_UPDATE*) calloc(1, sizeof(SHADOW_MSG_OUT_POINTER_POSITION_UPDATE)); if (!msg) return -1; msg->xPos = subsystem->pointerX; msg->yPos = subsystem->pointerY; msg->Free = x11_shadow_message_free; server = subsystem->server; ArrayList_Lock(server->clients); for (index = 0; index < ArrayList_Count(server->clients); index++) { client = (rdpShadowClient*)ArrayList_GetItem(server->clients, index); /* Skip the client which send us the latest mouse event */ if (client == subsystem->lastMouseClient) continue; if (shadow_client_post_msg(client, NULL, msgId, (SHADOW_MSG_OUT*) msg, NULL)) count++; } ArrayList_Unlock(server->clients); return count; }
// Find and return a list of MatchSet objects. // // This is the heart of the matching process. // // minimumMatches: minimum number of matches required in final results. // bestMatches: number of best matches to keep, or zero to keep all. // useRANSAC: whether ransac filtering should be used (true recommended // for 2d rigid transformed images, such as panoramas). ArrayList* MultiMatch_LocateMatchSets (MultiMatch* self, int minimumMatches, int bestMatches, bool useRANSAC, bool useAreaFiltration) { // mod 06 Mar 2008 TKS to allow alternative primary matchers if( ArrayList_Count( self->globalMatches ) == 0 ) { MultiMatch_BuildGlobalKD (self); MultiMatch_BuildGlobalMatchList (self); } MultiMatch_PartitionMatches (self); self->filteredMatchSets = ArrayList_new0 (NULL); // Walk all image combinations. int n0; for ( n0 = 0 ; n0 < self->imageCount ; ++n0) { int n1; for ( n1 = n0 + 1 ; n1 < self->imageCount ; ++n1) { MatchSet* ms = (MatchSet*) self->matchSets[n0][n1]; if (ms == NULL || ms->matches == NULL) continue; if (useRANSAC) { ArrayList* ransacMatches = NULL; int maxX = ms->xDim1 >= ms->xDim2 ? ms->xDim1 : ms->xDim2; int maxY = ms->yDim1 >= ms->yDim2 ? ms->yDim1 : ms->yDim2; // TODO: 16.0 -> configurable ImageMatchModel* bestRansac = MatchDriver_FilterMatchSet (ms->matches, 16.0, maxX, maxY); ms->bestMatchFit = bestRansac; if (bestRansac != NULL) ransacMatches = bestRansac->fittingGround; if (ransacMatches == NULL) { if (self->verbose) WriteLine ("RANSAC says: no good matches from " "%d original matches", ArrayList_Count(ms->matches)); continue; } else { if (self->verbose) WriteLine ("RANSAC purged: %d to %d", ArrayList_Count(ms->matches), ArrayList_Count(ransacMatches)); } // Overwrite matches with RANSAC checked ones. ms->matches = ransacMatches; } // Number of RANSAC-ok matches before count-filtering. int beforeBestFilterCount = ArrayList_Count(ms->matches); // TODO: replace with area filtering WriteLine ("Filtering... (%s, %s)", ms->file1, ms->file2); // First filtration: Join matches int beforeJoinFiltering = ArrayList_Count(ms->matches); ms->matches = MatchKeys_FilterJoins (ms->matches); WriteLine (" A. Join Filtration: %d to %d", beforeJoinFiltering, ArrayList_Count(ms->matches)); #if 0 // Second: Area filtration if (useAreaFiltration && bestMatches > 0) { int beforeAreaFiltering = ms.Matches.Count; double pixelCount = ms.xDim1 * ms.yDim1; double areaPixels; ms.Matches = FilterMatchesByArea (ms.Matches, bestMatches, out areaPixels); Console.WriteLine (" B. Area Filtration: {0} to {1}, covering {2:N2} % of image \"{3}\"", beforeAreaFiltering, ms.Matches.Count, (areaPixels * 100.0) / pixelCount, System.IO.Path.GetFileName (ms.File1)); } #endif #if 0 if (useAreaFiltration && bestMatches > 0) { int beforeFiltering = ms.Matches.Count; ms.Matches = FilterMatchesByCoverage (ms, ms.Matches, bestMatches); Console.WriteLine (" B. Coverage Filtration: {0} to {1} on image \"{2}\"", beforeFiltering, ms.Matches.Count, System.IO.Path.GetFileName (ms.File1)); } else #endif if (bestMatches > 0) { int beforeScoreFiltering = ArrayList_Count(ms->matches); ms->matches = MultiMatch_FilterMatches (self, ms->matches, bestMatches); WriteLine (" B. Score Filtration: %d to %d", beforeScoreFiltering, ArrayList_Count(ms->matches)); } WriteLine ("Filtered partition [%d,%d] from %d matches down to %d", n0, n1, beforeBestFilterCount, ArrayList_Count(ms->matches)); if (ArrayList_Count(ms->matches) >= minimumMatches) ArrayList_AddItem(self->filteredMatchSets, ms); } } return (self->filteredMatchSets); }
void MultiMatch_LoadKeysetsFromMemory (MultiMatch* self, ArrayList* memlist) { self->imageCount = ArrayList_Count(memlist); self->keySets = memlist; }
static TSMF_SAMPLE* tsmf_stream_pop_sample(TSMF_STREAM* stream, int sync) { UINT32 index; UINT32 count; TSMF_STREAM *s; TSMF_SAMPLE* sample; BOOL pending = FALSE; TSMF_PRESENTATION* presentation = stream->presentation; if (!stream) return NULL; if (Queue_Count(stream->sample_list) < 1) return NULL; if (sync) { if (stream->decoder) { if (stream->decoder->GetDecodedData) { if (stream->major_type == TSMF_MAJOR_TYPE_AUDIO) { /* Check if some other stream has earlier sample that needs to be played first */ /* Start time is more reliable than end time as some stream types seem to have incorrect * end times from the server */ if (stream->last_start_time > AUDIO_TOLERANCE) { ArrayList_Lock(presentation->stream_list); count = ArrayList_Count(presentation->stream_list); for (index = 0; index < count; index++) { s = (TSMF_STREAM *) ArrayList_GetItem(presentation->stream_list, index); /* Start time is more reliable than end time as some stream types seem to have incorrect * end times from the server */ if (s != stream && !s->eos && s->last_start_time && s->last_start_time < stream->last_start_time - AUDIO_TOLERANCE) { DEBUG_TSMF("Pending due to audio tolerance"); pending = TRUE; break; } } ArrayList_Unlock(presentation->stream_list); } } else { /* Start time is more reliable than end time as some stream types seem to have incorrect * end times from the server */ if (stream->last_start_time > presentation->audio_start_time) { DEBUG_TSMF("Pending due to stream start time > audio start time"); pending = TRUE; } } } } } if (pending) return NULL; sample = (TSMF_SAMPLE *) Queue_Dequeue(stream->sample_list); /* Only update stream last end time if the sample end time is valid and greater than the current stream end time */ if (sample && (sample->end_time > stream->last_end_time) && (!sample->invalidTimestamps)) stream->last_end_time = sample->end_time; /* Only update stream last start time if the sample start time is valid and greater than the current stream start time */ if (sample && (sample->start_time > stream->last_start_time) && (!sample->invalidTimestamps)) stream->last_start_time = sample->start_time; return sample; }
int main (int argc, char* argv[]) { WriteLine ("autopano-sift, Automatic panorama generation program\n"); if (argc+1 < 3) { Usage (); exit (1); } // output to stdout flag bool streamout = false; // Automatic pre-aligning of images bool preAlign = false; int bottomDefault = -1; int generateHorizon = 0; // Use RANSAC algorithm match filtration. bool useRansac = true; // Use area based weighting for final match selection. bool useAreaFiltration = true; // Truncate match coordinates to integer numbers. bool useIntegerCoordinates = false; // Use the absolute pathname of the image files in the output PTO // file. bool useAbsolutePathnames = false; // Use "keep-best" filtration, keep the maxMatches best. int maxMatches = 16; // default: 16 // Refinement options bool refine = false; bool refineMiddle = true; bool keepUnrefinable = true; int optionCount = 0; int optionN = 1; while (optionN < argc && strlen(argv[optionN]) >= 2 && argv[optionN][0] == '-' && argv[optionN][1] == '-') { char* optionStr = argv[optionN]; if (strcmp (optionStr, "--ransac") == 0) { useRansac = YesNoOption ("--ransac", argv[optionN + 1]); optionN += 2; } else if (strcmp (optionStr, "--maxmatches") == 0) { if (sscanf(argv[optionN + 1], "%d", &maxMatches) != 1) { WriteLine ("Parameter to maxmatches option invalid. See the usage help."); exit (1); } if (maxMatches < 0) { WriteLine ("Maximum number of matches must be positive or zero (unlimited)."); exit (1); } optionN += 2; } else if (strcmp (optionStr, "--disable-areafilter") == 0) { useAreaFiltration = false; optionN += 1; } else if (strcmp (optionStr, "--integer-coordinates") == 0) { useIntegerCoordinates = true; optionN += 1; } else if (strcmp (optionStr, "--absolute-pathnames") == 0) { useAbsolutePathnames = YesNoOption ("--absolute-pathnames", argv[optionN + 1]); optionN += 2; } else if (strcmp (optionStr, "--align") == 0) { preAlign = true; optionN += 1; } else if (strcmp (optionStr, "--bottom-is-left") == 0) { bottomDefault = 0; optionN += 1; } else if (strcmp (optionStr, "--bottom-is-right") == 0) { bottomDefault = 1; optionN += 1; } else if (strcmp (optionStr, "--generate-horizon") == 0) { if (sscanf(argv[optionN + 1], "%d", &generateHorizon) != 1) { WriteLine ("Parameter to generate-horizon option invalid. See the usage help."); exit (1); } if (generateHorizon < 0) { WriteLine ("The number of horizon lines to generate must be positive."); exit (1); } optionN += 2; } else if (strcmp (optionStr, "--refine") == 0) { refine = true; optionN += 1; } else if (strcmp (optionStr, "--refine-by-middle") == 0) { refineMiddle = true; optionN += 1; } else if (strcmp (optionStr, "--refine-by-mean") == 0) { refineMiddle = false; optionN += 1; } else if (strcmp (optionStr, "--keep-unrefinable") == 0) { keepUnrefinable = YesNoOption ("--keep-unrefinable", argv[optionN + 1]); optionN += 2; } else { WriteLine ("Usage error. Run \"autopano.exe\" without arguments for help."); exit (1); } } optionCount = optionN; // is there an output name and at least one input name? if( argc - optionN < 2 ){ WriteLine ("Error. Output name and at least one image name required."); Usage(); exit(1); } // next arg is either output file name or "-" for stdout // anything else beginning with '-' is an error if( argv[optionCount][0] == '-' ){ if( strcmp( argv[optionCount], "-" ) == 0 )streamout = true; else { WriteLine ("Option error. Run without arguments for help."); exit (1); } } if (bottomDefault != -1 && preAlign == false) { WriteLine ("Please enable automatic alignment (\"--align\") before using the"); WriteLine ("--bottom-is-* options. Thank you. Run \"autopano.exe\" without"); WriteLine ("arguments for usage help."); exit (1); } if (generateHorizon > 0 && preAlign == false) { WriteLine ("Please enable automatic alignment (\"--align\") before using the"); WriteLine ("--generate-horizon option. Thank you. Run \"autopano.exe\" without"); WriteLine ("arguments for usage help."); exit (1); } MultiMatch* mm = MultiMatch_new0 (); ArrayList* keyfiles = ArrayList_new0(NULL); int i; for( i=0; i<argc - 1 - optionCount; i++) { ArrayList_AddItem(keyfiles, argv[i+optionCount+1]); } WriteLine ("Loading keyfiles"); MultiMatch_LoadKeysets (mm, keyfiles); WriteLine ("\nMatching...%s", useRansac == true ? " RANSAC enabled" : ""); ArrayList* msList = MultiMatch_LocateMatchSets (mm, 3, maxMatches, useRansac, useAreaFiltration); // Connected component check WriteLine ("\nConnected component check..."); ArrayList* components = MultiMatch_ComponentCheck (mm, msList); WriteLine ("Connected component identification resulted in %d component%s:", ArrayList_Count(components), ArrayList_Count(components) > 1 ? "s" : ""); int compN = 1; int j; for(j=0; j<ArrayList_Count(components); j++) { Component* comp = (Component*) ArrayList_GetItem(components, j); char* compstr = Component_ToString(comp); WriteLine ("component %d: %s", compN++, compstr); free(compstr); } if (ArrayList_Count(components) > 1) { WriteLine (""); WriteLine ("Warning: There is one or more components that are not connected through control"); WriteLine (" points. An optimization of the resulting PTO will not be possible"); WriteLine (" without prior adding of control points between the components listed"); WriteLine (" above. Please see the manual page for autopano(1) for details."); WriteLine (""); } else WriteLine (""); // BondBall algorithm BondBall* bb = NULL; if (preAlign) { bb = MultiMatch_BuildBondBall (mm, msList, bottomDefault); if (bb == NULL) { WriteLine ("WARNING: Failed to build bondball as requested. No pre-aligning of images"); WriteLine (" takes place.\n"); } } if (refine) { WriteLine ("Refining keypoints"); RefineKeypoints (msList, refineMiddle, keepUnrefinable); } FILE* pto; if ( streamout ) { pto = stdout; } else { WriteLine ("Creating output file \"%s\"", argv[optionCount]); pto = fopen(argv[optionCount], "w"); } WritePTOFile (pto, mm, msList, bb, generateHorizon, useIntegerCoordinates, useAbsolutePathnames); ArrayList_delete(keyfiles); ArrayList_delete(components); BondBall_delete(bb); MultiMatch_delete(mm); if ( !streamout ) fclose(pto); return 0; }
static BOOL tsmf_sample_playback(TSMF_SAMPLE* sample) { BOOL ret = FALSE; UINT32 width; UINT32 height; UINT32 pixfmt = 0; TSMF_STREAM* stream = sample->stream; if (stream->decoder) { if (stream->decoder->DecodeEx) { /* Try to "sync" video buffers to audio buffers by looking at the running time for each stream * The difference between the two running times causes an offset between audio and video actual * render times. So, we try to adjust timestamps on the video buffer to match those on the audio buffer. */ if (stream->major_type == TSMF_MAJOR_TYPE_VIDEO) { TSMF_STREAM* temp_stream = NULL; TSMF_PRESENTATION* presentation = stream->presentation; ArrayList_Lock(presentation->stream_list); int count = ArrayList_Count(presentation->stream_list); int index = 0; for (index = 0; index < count; index++) { UINT64 time_diff; temp_stream = (TSMF_STREAM*) ArrayList_GetItem(presentation->stream_list, index); if (temp_stream->major_type == TSMF_MAJOR_TYPE_AUDIO) { UINT64 video_time = (UINT64) stream->decoder->GetRunningTime(stream->decoder); UINT64 audio_time = (UINT64) temp_stream->decoder->GetRunningTime(temp_stream->decoder); UINT64 max_adjust = VIDEO_ADJUST_MAX; if (video_time < audio_time) max_adjust = -VIDEO_ADJUST_MAX; if (video_time > audio_time) time_diff = video_time - audio_time; else time_diff = audio_time - video_time; time_diff = time_diff < VIDEO_ADJUST_MAX ? time_diff : max_adjust; sample->start_time += time_diff; sample->end_time += time_diff; break; } } ArrayList_Unlock(presentation->stream_list); } ret = stream->decoder->DecodeEx(stream->decoder, sample->data, sample->data_size, sample->extensions, sample->start_time, sample->end_time, sample->duration); } else { ret = stream->decoder->Decode(stream->decoder, sample->data, sample->data_size, sample->extensions); } } if (!ret) { WLog_ERR(TAG, "decode error, queue ack anyways"); if (!tsmf_sample_queue_ack(sample)) { WLog_ERR(TAG, "error queuing sample for ack"); return FALSE; } return TRUE; } free(sample->data); sample->data = NULL; if (stream->major_type == TSMF_MAJOR_TYPE_VIDEO) { if (stream->decoder->GetDecodedFormat) { pixfmt = stream->decoder->GetDecodedFormat(stream->decoder); if (pixfmt == ((UINT32) -1)) { WLog_ERR(TAG, "unable to decode video format"); if (!tsmf_sample_queue_ack(sample)) { WLog_ERR(TAG, "error queuing sample for ack"); } return FALSE; } sample->pixfmt = pixfmt; } if (stream->decoder->GetDecodedDimension) { ret = stream->decoder->GetDecodedDimension(stream->decoder, &width, &height); if (ret && (width != stream->width || height != stream->height)) { DEBUG_TSMF("video dimension changed to %d x %d", width, height); stream->width = width; stream->height = height; } } } if (stream->decoder->GetDecodedData) { sample->data = stream->decoder->GetDecodedData(stream->decoder, &sample->decoded_size); switch (sample->stream->major_type) { case TSMF_MAJOR_TYPE_VIDEO: ret = tsmf_sample_playback_video(sample) && tsmf_sample_queue_ack(sample); break; case TSMF_MAJOR_TYPE_AUDIO: ret = tsmf_sample_playback_audio(sample) && tsmf_sample_queue_ack(sample); break; } } else { TSMF_STREAM* stream = sample->stream; UINT64 ack_anticipation_time = get_current_time(); BOOL buffer_filled = TRUE; /* Classify the buffer as filled once it reaches minimum level */ if (stream->decoder->BufferLevel) { if (stream->currentBufferLevel < stream->minBufferLevel) buffer_filled = FALSE; } if (buffer_filled) { ack_anticipation_time += (sample->duration/2 < MAX_ACK_TIME) ? sample->duration/2 : MAX_ACK_TIME; } else { ack_anticipation_time += (sample->duration/2 < MAX_ACK_TIME) ? sample->duration/2 : MAX_ACK_TIME; } switch (sample->stream->major_type) { case TSMF_MAJOR_TYPE_VIDEO: { break; } case TSMF_MAJOR_TYPE_AUDIO: { break; } } sample->ack_time = ack_anticipation_time; if (!tsmf_sample_queue_ack(sample)) { WLog_ERR(TAG, "error queuing sample for ack"); ret = FALSE; } } return ret; }
IKDTreeDomain* KDTree_GoodCandidate (ArrayList* exset, int* splitDim) { IKDTreeDomain* first = (IKDTreeDomain*) ArrayList_GetItem(exset, 0); if (first == NULL) { FatalError ("Not of type IKDTreeDomain (TODO: custom exception)"); } int dim = IKDTreeDomain_GetDimensionCount(first); // initialize temporary hr search min/max values double* minHr = (double*)malloc(sizeof(double)* dim); double* maxHr = (double*)malloc(sizeof(double)* dim); int i; for (i = 0 ; i < dim ; ++i) { minHr[i] = Double_PositiveInfinity; maxHr[i] = Double_NegativeInfinity; } int j; for(j=0; j<ArrayList_Count(exset); j++) { IKDTreeDomain* dom = (IKDTreeDomain*) ArrayList_GetItem(exset, j); int k; for (k = 0 ; k < dim ; ++k) { double dimE = IKDTreeDomain_GetDimensionElement (dom, k); if (dimE < minHr[k]) minHr[k] = dimE; if (dimE > maxHr[k]) maxHr[k] = dimE; } } // find the maximum range dimension double* diffHr = (double*)malloc(sizeof(double)* dim); int maxDiffDim = 0; double maxDiff = 0.0; int k; for (k = 0 ; k < dim ; ++k) { diffHr[k] = maxHr[k] - minHr[k]; if (diffHr[k] > maxDiff) { maxDiff = diffHr[k]; maxDiffDim = k; } } free(maxHr); maxHr = NULL; // the splitting dimension is maxDiffDim // now find a exemplar as close to the arithmetic middle as possible double middle = (maxDiff / 2.0) + minHr[maxDiffDim]; IKDTreeDomain* exemplar = NULL; double exemMinDiff = Double_PositiveInfinity; free(minHr); minHr=NULL; int l; for(l=0; l<ArrayList_Count(exset); l++) { IKDTreeDomain* dom = (IKDTreeDomain*) ArrayList_GetItem(exset, l); double curDiff = abs (IKDTreeDomain_GetDimensionElement (dom, maxDiffDim) - middle); if (curDiff < exemMinDiff) { exemMinDiff = curDiff; exemplar = dom; } } free(diffHr); diffHr = NULL; // return the values *splitDim = maxDiffDim; return (exemplar); }
HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD nMaxInstances, DWORD nOutBufferSize, DWORD nInBufferSize, DWORD nDefaultTimeOut, LPSECURITY_ATTRIBUTES lpSecurityAttributes) { int index; HANDLE hNamedPipe = INVALID_HANDLE_VALUE; char* lpPipePath; struct sockaddr_un s; WINPR_NAMED_PIPE* pNamedPipe = NULL; int serverfd = -1; NamedPipeServerSocketEntry* baseSocket = NULL; if (!lpName) return INVALID_HANDLE_VALUE; InitWinPRPipeModule(); pNamedPipe = (WINPR_NAMED_PIPE*) calloc(1, sizeof(WINPR_NAMED_PIPE)); if (!pNamedPipe) return INVALID_HANDLE_VALUE; WINPR_HANDLE_SET_TYPE(pNamedPipe, HANDLE_TYPE_NAMED_PIPE); if (!(pNamedPipe->name = _strdup(lpName))) goto out; if (!(pNamedPipe->lpFileName = GetNamedPipeNameWithoutPrefixA(lpName))) goto out; if (!(pNamedPipe->lpFilePath = GetNamedPipeUnixDomainSocketFilePathA(lpName))) goto out; pNamedPipe->dwOpenMode = dwOpenMode; pNamedPipe->dwPipeMode = dwPipeMode; pNamedPipe->nMaxInstances = nMaxInstances; pNamedPipe->nOutBufferSize = nOutBufferSize; pNamedPipe->nInBufferSize = nInBufferSize; pNamedPipe->nDefaultTimeOut = nDefaultTimeOut; pNamedPipe->dwFlagsAndAttributes = dwOpenMode; pNamedPipe->clientfd = -1; pNamedPipe->ServerMode = TRUE; ArrayList_Lock(g_NamedPipeServerSockets); for (index = 0; index < ArrayList_Count(g_NamedPipeServerSockets); index++) { baseSocket = (NamedPipeServerSocketEntry*) ArrayList_GetItem( g_NamedPipeServerSockets, index); if (!strcmp(baseSocket->name, lpName)) { serverfd = baseSocket->serverfd; //WLog_DBG(TAG, "using shared socked resource for pipe %p (%s)", pNamedPipe, lpName); break; } } /* If this is the first instance of the named pipe... */ if (serverfd == -1) { /* Create the UNIX domain socket and start listening. */ if (!(lpPipePath = GetNamedPipeUnixDomainSocketBaseFilePathA())) goto out; if (!PathFileExistsA(lpPipePath)) { CreateDirectoryA(lpPipePath, 0); UnixChangeFileMode(lpPipePath, 0xFFFF); } free(lpPipePath); if (PathFileExistsA(pNamedPipe->lpFilePath)) { DeleteFileA(pNamedPipe->lpFilePath); } if ((serverfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) { WLog_ERR(TAG, "CreateNamedPipeA: socket error, %s", strerror(errno)); goto out; } ZeroMemory(&s, sizeof(struct sockaddr_un)); s.sun_family = AF_UNIX; strcpy(s.sun_path, pNamedPipe->lpFilePath); if (bind(serverfd, (struct sockaddr*) &s, sizeof(struct sockaddr_un)) == -1) { WLog_ERR(TAG, "CreateNamedPipeA: bind error, %s", strerror(errno)); goto out; } if (listen(serverfd, 2) == -1) { WLog_ERR(TAG, "CreateNamedPipeA: listen error, %s", strerror(errno)); goto out; } UnixChangeFileMode(pNamedPipe->lpFilePath, 0xFFFF); if (!(baseSocket = (NamedPipeServerSocketEntry*) malloc(sizeof(NamedPipeServerSocketEntry)))) goto out; if (!(baseSocket->name = _strdup(lpName))) { free(baseSocket); goto out; } baseSocket->serverfd = serverfd; baseSocket->references = 0; ArrayList_Add(g_NamedPipeServerSockets, baseSocket); //WLog_DBG(TAG, "created shared socked resource for pipe %p (%s). base serverfd = %d", pNamedPipe, lpName, serverfd); } pNamedPipe->serverfd = dup(baseSocket->serverfd); //WLog_DBG(TAG, "using serverfd %d (duplicated from %d)", pNamedPipe->serverfd, baseSocket->serverfd); pNamedPipe->pfnUnrefNamedPipe = winpr_unref_named_pipe; baseSocket->references++; if (dwOpenMode & FILE_FLAG_OVERLAPPED) { #if 0 int flags = fcntl(pNamedPipe->serverfd, F_GETFL); if (flags != -1) fcntl(pNamedPipe->serverfd, F_SETFL, flags | O_NONBLOCK); #endif } hNamedPipe = (HANDLE) pNamedPipe; out: if (hNamedPipe == INVALID_HANDLE_VALUE) { if (pNamedPipe) { free((void*)pNamedPipe->name); free((void*)pNamedPipe->lpFileName); free((void*)pNamedPipe->lpFilePath); free(pNamedPipe); } if (serverfd != -1) close(serverfd); } ArrayList_Unlock(g_NamedPipeServerSockets); return hNamedPipe; }
// selectMiddlePoint: if true, select the middle point in the patch, // otherwise build the mean // neverLosePoints: if true, and if we cannot do the refinement, still use // the control point. void RefineKeypoints (ArrayList* msList, bool selectMiddlePoint, bool neverLosePoints) { DisplayImage* pic1 = NULL; DisplayImage* pic2 = NULL; char* pic1Name = NULL; char* pic2Name = NULL; /* Keep stats for the refineHandler delegate */ int totalRefines = 0; int doneRefines = 0; int i; for(i=0; i<ArrayList_Count(msList); i++) { MatchSet* ms = (MatchSet*) ArrayList_GetItem(msList, i); int j; for(j=0; j<ArrayList_Count(ms->matches); j++) { ArrayList_GetItem(ms->matches, j); totalRefines += 1; } } for(i=0; i<ArrayList_Count(msList); i++) { MatchSet* ms = (MatchSet*) ArrayList_GetItem(msList, i); WriteLine (" between \"%s\" and \"%s\"", ms->file1, ms->file2); if (pic1Name != ms->file1) { pic1Name = ms->file1; pic1 = DisplayImage_new (ms->file1); } if (pic2Name != ms->file2) { pic2Name = ms->file2; pic2 = DisplayImage_new (ms->file2); } /*WriteLine ("pair: %s, %s, %d keypoint matches", ms->file1, ms->file2, ArrayList_Count(ms->Matches));*/ ArrayList* refinedMatches = ArrayList_new0 (NULL); int j; for(j=0; j<ArrayList_Count(ms->matches); j++) { Match* m = (Match*) ArrayList_GetItem(ms->matches, j); int p1x = (int) (m->kp1->x + 0.5); int p1y = (int) (m->kp1->y + 0.5); int p1radius; DisplayImage* patch1 = ExtractPatch (pic1, p1x, p1y, m->kp1->scale, &p1radius); int p2x = (int) (m->kp2->x + 0.5); int p2y = (int) (m->kp2->y + 0.5); int p2radius; DisplayImage* patch2 = ExtractPatch (pic2, p2x, p2y, m->kp2->scale, &p2radius); /* Call the refine handler delegate in case there is one to * inform the callee of a single refining step (for progress * bar displays and such). */ doneRefines += 1; if (refineHandler != NULL) refineHandler (doneRefines, totalRefines); // Skip over keypoint matches we cannot refine as part of the // image lies outside. if (patch1 == NULL || patch2 == NULL) { if (neverLosePoints) ArrayList_AddItem(refinedMatches, m); DisplayImage_delete(patch1); DisplayImage_delete(patch2); continue; } // Otherwise, run the SIFT algorithm on both small patches. ArrayList* p1kp = ExtractKeypoints (patch1); ArrayList* p2kp = ExtractKeypoints (patch2); /*WriteLine ("p1kp = %d, p2kp = %d", ArrayList_Count(p1kp), ArrayList_Count(p2kp));*/ // Apply the matching, RANSAC enabled. MultiMatch* mm = MultiMatch_new0 (); mm->verbose = false; ArrayList* matches = NULL; matches = MultiMatch_TwoPatchMatch (mm, p1kp, patch1->width, patch1->height, p2kp, patch2->width, patch2->height, true); DisplayImage_delete(patch1); DisplayImage_delete(patch2); /* In case there are less than three keypoints in the * two patches, we ignore them all. */ if (0 /*was exception ???*/ ) { matches = NULL; } if (matches == NULL || ArrayList_Count(matches) != 1) { if (neverLosePoints) ArrayList_AddItem(refinedMatches, m); continue; } MatchSet* pSet = (MatchSet*) ArrayList_GetItem(matches, 0); // Now get the real new control point coordinates from the // patches. We have two options and assume all points are // equal quality-wise: // a) Select the one that is most in the middle // (selectMiddlePoint == true) // b) Build the mean of all the control point matches in the // patches (selectMiddlePoint == false). double kp1X = 0.0; double kp1Y = 0.0; double kp2X = 0.0; double kp2Y = 0.0; double kpMidDist = Double_PositiveInfinity; int k; for(k=0; k<ArrayList_Count(pSet->matches); k++) { Match* pM = (Match*) ArrayList_GetItem(pSet->matches, k); if (selectMiddlePoint) { double dist = sqrt ( pow (pM->kp1->x - p1radius, 2.0) + pow (pM->kp1->y - p1radius, 2.0)); if (dist < kpMidDist) { kpMidDist = dist; kp1X = pM->kp1->x; kp1Y = pM->kp1->y; kp2X = pM->kp2->x; kp2Y = pM->kp2->y; } } else { kp1X += pM->kp1->x; kp1Y += pM->kp1->y; kp2X += pM->kp2->x; kp2Y += pM->kp2->y; } /*WriteLine ("(%g, %g) matches (%g, %g)", pM->kp1->x, pM->kp1->y, pM->kp2->x, pM->kp2->y);*/ } if (selectMiddlePoint == false) { kp1X /= (double) ArrayList_Count(pSet->matches); kp1Y /= (double) ArrayList_Count(pSet->matches); kp2X /= (double) ArrayList_Count(pSet->matches); kp2Y /= (double) ArrayList_Count(pSet->matches); } kp1X += p1x - p1radius; kp1Y += p1y - p1radius; kp2X += p2x - p2radius; kp2Y += p2y - p2radius; Match* mn = Match_clone (m); // Adjust the original keypoints location to be the mean of // all the highly precise superresolution points. mn->kp1->x = kp1X; mn->kp1->y = kp1Y; mn->kp2->x = kp2X; mn->kp2->y = kp2Y; /*WriteLine ("MASTER POINT MATCH: (%g,%g) to (%g,%g)", kp1X, kp1Y, kp2X, kp2Y);*/ ArrayList_AddItem(refinedMatches, mn); /* DisplayImage_Save (patch1, "patch-1.jpg"); DisplayImage_Save (patch2, "patch-2.jpg"); exit (0); */ } ms->matches = refinedMatches; } }
int x11_shadow_screen_grab(x11ShadowSubsystem* subsystem) { int count; int status; int x, y; int width, height; XImage* image; rdpShadowScreen* screen; rdpShadowServer* server; rdpShadowSurface* surface; RECTANGLE_16 invalidRect; RECTANGLE_16 surfaceRect; const RECTANGLE_16 *extents; server = subsystem->server; surface = server->surface; screen = server->screen; count = ArrayList_Count(server->clients); if (count < 1) return 1; surfaceRect.left = 0; surfaceRect.top = 0; surfaceRect.right = surface->width; surfaceRect.bottom = surface->height; XLockDisplay(subsystem->display); /* * Ignore BadMatch error during image capture. The screen size may be * changed outside. We will resize to correct resolution at next frame */ XSetErrorHandler(x11_shadow_error_handler_for_capture); if (subsystem->use_xshm) { image = subsystem->fb_image; XCopyArea(subsystem->display, subsystem->root_window, subsystem->fb_pixmap, subsystem->xshm_gc, 0, 0, subsystem->width, subsystem->height, 0, 0); status = shadow_capture_compare(surface->data, surface->scanline, surface->width, surface->height, (BYTE*) &(image->data[surface->width * 4]), image->bytes_per_line, &invalidRect); } else { image = XGetImage(subsystem->display, subsystem->root_window, surface->x, surface->y, surface->width, surface->height, AllPlanes, ZPixmap); if (!image) { /* * BadMatch error happened. The size may have been changed again. * Give up this frame and we will resize again in next frame */ goto fail_capture; } status = shadow_capture_compare(surface->data, surface->scanline, surface->width, surface->height, (BYTE*) image->data, image->bytes_per_line, &invalidRect); } /* Restore the default error handler */ XSetErrorHandler(NULL); XSync(subsystem->display, False); XUnlockDisplay(subsystem->display); region16_union_rect(&(surface->invalidRegion), &(surface->invalidRegion), &invalidRect); region16_intersect_rect(&(surface->invalidRegion), &(surface->invalidRegion), &surfaceRect); if (!region16_is_empty(&(surface->invalidRegion))) { extents = region16_extents(&(surface->invalidRegion)); x = extents->left; y = extents->top; width = extents->right - extents->left; height = extents->bottom - extents->top; freerdp_image_copy(surface->data, PIXEL_FORMAT_XRGB32, surface->scanline, x, y, width, height, (BYTE*) image->data, PIXEL_FORMAT_XRGB32, image->bytes_per_line, x, y, NULL); //x11_shadow_blend_cursor(subsystem); count = ArrayList_Count(server->clients); shadow_subsystem_frame_update((rdpShadowSubsystem *)subsystem); if (count == 1) { rdpShadowClient* client; client = (rdpShadowClient*) ArrayList_GetItem(server->clients, 0); if (client) { subsystem->captureFrameRate = shadow_encoder_preferred_fps(client->encoder); } } region16_clear(&(surface->invalidRegion)); } if (!subsystem->use_xshm) XDestroyImage(image); return 1; fail_capture: XSetErrorHandler(NULL); XSync(subsystem->display, False); XUnlockDisplay(subsystem->display); return 0; }
void WritePTOFile (FILE* pto, MultiMatch* mm, ArrayList* msList, BondBall* bb, int generateHorizon, bool integerCoordinates, bool useAbsolutePathnames) { fprintf(pto, "# Hugin project file\n"); fprintf(pto, "# automatically generated by autopano-sift, available at\n"); fprintf(pto, "# http://cs.tu-berlin.de/~nowozin/autopano-sift/\n\n"); fprintf(pto, "p f2 w3000 h1500 v360 n\"JPEG q90\"\n"); fprintf(pto, "m g1 i0\n\n"); int imageIndex = 0; HashTable* imageNameTab = HashTable_new0 (NULL, NULL); ArrayList* resolutions = ArrayList_new0 (Resolution_delete); int i; for(i=0; i<ArrayList_Count(mm->keySets); i++) { KeypointXMLList* kx = (KeypointXMLList*) ArrayList_GetItem(mm->keySets, i); HashTable_AddItem(imageNameTab, kx->imageFile, (void*)imageIndex); ArrayList_AddItem(resolutions, Resolution_new (kx->xDim, kx->yDim)); char* imageFile = kx->imageFile; // If the resolution was already there, use the first image with // the exact same resolution as reference for camera-related // values. int refIdx; for (refIdx = 0 ; refIdx < (ArrayList_Count(resolutions) - 1) ; ++refIdx) { if (Resolution_CompareTo((Resolution*) ArrayList_GetItem(resolutions, refIdx), kx->xDim, kx->yDim) == 0) break; } if (refIdx == (ArrayList_Count(resolutions) - 1)) refIdx = -1; Position* pos = bb == NULL ? NULL : (Position*) HashTable_GetItem(bb->positions, imageFile); /* if (pos != NULL) { WriteLine ("yaw %g, pitch %g, rotation %g", pos->yaw, pos->pitch, pos->rotation); }*/ double yaw = 0.0, pitch = 0.0, rotation = 0.0; if (pos != NULL) { yaw = pos->yaw; pitch = pos->pitch; rotation = pos->rotation; } if (imageIndex == 0 || refIdx == -1) { fprintf(pto, "i w%d h%d f0 a0 b-0.01 c0 d0 e0 p%g r%g v180 y%g u10 n\"%s\"\n", kx->xDim, kx->yDim, pitch, rotation, yaw, imageFile); } else { fprintf(pto, "i w%d h%d f0 a=%d b=%d c=%d d0 e0 p%g r%g v=%d y%g u10 n\"%s\"\n", kx->xDim, kx->yDim, refIdx, refIdx, refIdx, pitch, rotation, refIdx, yaw, imageFile); } imageIndex += 1; } fprintf(pto, "\nv p1 r1 y1\n\n"); fprintf(pto, "# match list automatically generated\n"); int j; for(j=0; j<ArrayList_Count(msList); j++) { MatchSet* ms = (MatchSet*) ArrayList_GetItem(msList, j); int k; for(k=0; k<ArrayList_Count(ms->matches); k++) { Match* m = (Match*) ArrayList_GetItem(ms->matches, k); if (integerCoordinates == false) { fprintf(pto, "c n%d N%d x%.6f y%.6f X%.6f Y%.6f t0\n", (int)HashTable_GetItem(imageNameTab, ms->file1), (int)HashTable_GetItem(imageNameTab, ms->file2), m->kp1->x, m->kp1->y, m->kp2->x, m->kp2->y); } else { fprintf(pto, "c n%d N%d x%d y%d X%d Y%d t0\n", (int)HashTable_GetItem(imageNameTab, ms->file1), (int)HashTable_GetItem(imageNameTab, ms->file2), (int) (m->kp1->x + 0.5), (int) (m->kp1->y + 0.5), (int) (m->kp2->x + 0.5), (int) (m->kp2->y + 0.5)); } } } // Generate horizon if we should if (bb != NULL && generateHorizon > 0) { WriteLine ("Creating horizon..."); int kMain = 2; int hPoints = generateHorizon; int horizonPointsMade = 0; bool hasGood = true; while (hPoints > 0 && hasGood) { hasGood = false; int kStep = 2 * kMain; int p; for (p = 0 ; hPoints > 0 && p < kMain ; ++p) { double stepSize = ((double) ArrayList_Count(bb->firstRow)) / ((double) kStep); double beginIndex = p * stepSize; double endIndex = (((double) ArrayList_Count(bb->firstRow)) / (double) kMain) + p * stepSize; // Round to next integer and check if their image distance // is larger than 1. If its not, we skip over this useless // horizon point. int bi = (int) (beginIndex + 0.5); int ei = (int) (endIndex + 0.5); if ((ei - bi) <= 1) continue; hasGood = true; bi %= ArrayList_Count(bb->firstRow); ei %= ArrayList_Count(bb->firstRow); fprintf(pto, "c n%s N%s x%d y%d X%d Y%d t2\n", (char*)HashTable_GetItem(imageNameTab, ArrayList_GetItem(bb->firstRow, bi)), (char*)HashTable_GetItem(imageNameTab, ArrayList_GetItem(bb->firstRow, ei)), ((Resolution*) ArrayList_GetItem(resolutions,bi))->x / 2, ((Resolution*) ArrayList_GetItem(resolutions,bi))->y / 2, ((Resolution*) ArrayList_GetItem(resolutions,ei))->x / 2, ((Resolution*) ArrayList_GetItem(resolutions,ei))->y / 2); horizonPointsMade += 1; hPoints -= 1; } // Increase density for next generation lines kMain *= 2; } WriteLine (" made %d horizon lines.\n", horizonPointsMade); } fprintf(pto, "\n# :-)\n\n"); WriteLine ("\nYou can now load the output file into hugin."); WriteLine ("Notice: You absolutely must adjust the field-of-view value for the images"); ArrayList_delete(resolutions); HashTable_delete(imageNameTab); }